riemann.time
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!).
every!
(every! interval f)
(every! interval delay f)
Calls f every interval seconds, after delay.
linear-time-real
(linear-time-real)
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
(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).
reset-tasks!
(reset-tasks!)
Resets the task queue to empty, without triggering side effects.
run-tasks!
(run-tasks! i)
While running, takes tasks from the queue and executes them when ready. Will park the current thread when no tasks are available.
schedule!
(schedule! task)
Schedule a task. May awaken a thread from the threadpool to investigate.
Task
protocol
members
cancel
(cancel task)
Cancel this task.
run
(run task)
Executes this task.
succ
(succ task)
The successive task to this one.
unix-time-real
(unix-time-real)
The current unix epoch time in seconds, taken from System/currentTimeMillis.