Clocks and scheduled tasks. Provides functions for getting the current time and running functions (Tasks) at specific times and periods. Includes a threadpool for task execution, controlled by (start!) and (stop!).
(after! delay f)
Calls f after delay seconds
(defer this new-time)
Schedule a task for a new time.
(every! interval f)
(every! interval delay f)
Calls f every interval seconds, after delay.
A current time on a linear scale with no fixed epoch; counts in seconds. Unlike unix-time, which can pause, skip, or flow backwards, advances consistently at (close) to wall clock time.
(next-tick anchor dt)
(next-tick anchor dt now)
Given a period dt, beginning at some point in time anchor, finds the next tick after time now, such that the next tick is separate from anchor by an exact multiple of dt. If now is omitted, defaults to (unix-time).
(once! t f)
Calls f at t seconds.
Removes the next task from the queue.
Resets the task queue to empty, without triggering side effects.
While running, takes tasks from the queue and executes them when ready. Will park the current thread when no tasks are available.
Schedule a task. May awaken a thread from the threadpool to investigate.
Schedules a task. Does not awaken any threads.
Starts the threadpool to execute tasks on the queue automatically.
Stops the task threadpool. Waits for threads to exit.
Cancel this task.
Executes this task.
The successive task to this one.
Return a new task ID.
The current unix epoch time in seconds, taken from System/currentTimeMillis.