trivial-timer
2021-05-31
Easy scheduling of tasks (functions).
Trivial Timer Manual
[in package TRIVIAL-TIMER]
Description
Trivial Timer allows for easy scheduling of tasks (functions). The default tolerance is +- 10ms as defined by *ms-tolerance*.
Installing trivial-timer
This project is available in the latest QuickLisp distribution, so installing it is reduced to calling:
(ql:quickload :trivial-timer)
Working Example
(in-package :trivial-timer) (initialize-timer) (defun timer-callback (registered-time delay) (log:info "I was called by the timer ~a ms after registration. Expected was ~a ms." (- (get-internal-real-time) registered-time) delay)) (let ((delay 1000)) (register-timer-call delay #'timer-callback)) => I was called by the timer 992 ms after registration. Expected was 1000 ms.
Exported Symbols
-
[variable] MS-TOLERANCE 10
Time tolerance (default +/- 10ms)
-
[function] INITIALIZE-TIMER
Initialization of trivial-timer. This MUST be called before any other function from this library.
-
[function] SHUTDOWN-TIMER
Shutdown the timer. No further calls can be registered. Atention: Stopping is an asynchronous request, meaning that some registered call might still be executed after calling shutdown-timer
-
[function] REGISTER-TIMER-CALL OFFSET CALL &KEY RECURRING
Register a function call to be executed in offset milliseconds from now.
If recurring is T then call will be repeated every offset milliseconds.
Returns the ID of the registration (to be used with cancel-timer-call). -
[function] REGISTER-TIMER-RECURRING-CALL OFFSET CALL
Register a function call to be (recurrently) executed every offset milliseconds.
Returns the ID of the registration (to be used with cancel-timer-call). -
[function] CANCEL-TIMER-CALL ID
Cancel a timer call identified by ID.
Returns T if the call identified by ID was removed.
License Information
This library is released under the MIT License. Please refer to the LICENSE to get the full licensing text.
Contributing to this project
Please refer to the CONTRIBUTING document for more information.