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!).
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.
Calls f after delay seconds.
(at-linear-micros! t f)
Calls f at t microseconds on the linear timescale.
Calls f at t microseconds on the linear timescale.
(at-unix! t f)
Calls f at t seconds on the unix timescale. We convert this time to the linear timescale, so it may behave oddly across leap seconds.
Calls f at t seconds on the unix timescale. We convert this time to the linear timescale, so it may behave oddly across leap seconds.
(at-unix-micros! t f)
Calls f at t microseconds on the unix timescale. We convert this time to the linear timescale, so it may behave oddly across leap seconds.
Calls f at t microseconds on the unix timescale. We convert this time to the linear timescale, so it may behave oddly across leap seconds.
(ceil x)
Ceiling. For integers, identity. For other things, uses Math/ceil and coerces to long.
Ceiling. For integers, identity. For other things, uses Math/ceil and coerces to long.
(defer! this delay)
Schedule a task for a new time measured in seconds from now
Schedule a task for a new time measured in seconds from now
(defer-micros! this delay)
Schedule a task for a new time measured in microseconds from now
Schedule a task for a new time measured in microseconds from now
(every! interval f)
(every! interval delay f)
Calls f every interval seconds, after delay, also in seconds. If no delay is provided, starts immediately.
Calls f every interval seconds, after delay, also in seconds. If no delay is provided, starts immediately.
Rebindable alias for real-linear-time
Rebindable alias for real-linear-time
Rebindable alias for real-linear-time-micros
Rebindable alias for real-linear-time-micros
(micros->seconds t)
Convert microseconds to seconds, as doubles.
Convert microseconds to seconds, as doubles.
(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 (linear-time), and both anchor and dt are in seconds. If now is passed, anchor, dt, and now can be in any unit, so long as they all agree.
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 (linear-time), and both anchor and dt are in seconds. If now is passed, anchor, dt, and now can be in any unit, so long as they all agree.
Time we might sleep when nothing is scheduled, in micros.
Time we might sleep when nothing is scheduled, in micros.
(poll-task!)
Removes the next task from the queue.
Removes the next task from the queue.
(real-linear-time)
The current linear time in seconds, taken from System/nanoTime
The current linear time in seconds, taken from System/nanoTime
(real-linear-time-micros)
A current time on a linear scale with no fixed epoch; counts in microseconds. Unlike unix-time, which can pause, skip, or flow backwards, advances mostly monotonically at (close) to physical time, one second per second.
A current time on a linear scale with no fixed epoch; counts in microseconds. Unlike unix-time, which can pause, skip, or flow backwards, advances mostly monotonically at (close) to physical time, one second per second.
(real-unix-time)
The current unix epoch time in seconds, taken from System/currentTimeMillis
The current unix epoch time in seconds, taken from System/currentTimeMillis
(real-unix-time-micros)
The current unix epoch time in microseconds, taken from System/currentTimeMillis
The current unix epoch time in microseconds, taken from System/currentTimeMillis
(reset-tasks!)
Resets the task queue to empty, without triggering side effects.
Resets the task queue to empty, without triggering side effects.
(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.
While running, takes tasks from the queue and executes them when ready. Will park the current thread when no tasks are available.
Whether the threadpool is currently supposed to be alive.
Whether the threadpool is currently supposed to be alive.
(schedule! task)
Schedule a task. May awaken a thread from the threadpool to investigate.
Schedule a task. May awaken a thread from the threadpool to investigate.
(schedule-sneaky! task)
Schedules a task. Does not awaken any threads.
Schedules a task. Does *not* awaken any threads.
(seconds->micros t)
Convert seconds to microseconds, as longs.
Convert seconds to microseconds, as longs.
(start!)
Starts the threadpool to execute tasks on the queue automatically. Repeated calls to start are noops.
Starts the threadpool to execute tasks on the queue automatically. Repeated calls to start are noops.
(stop!)
Stops the task threadpool. Waits for threads to exit. Repeated calls to stop are noops.
Stops the task threadpool. Waits for threads to exit. Repeated calls to stop are noops.
(cancel! task)
Cancel this task.
Cancel this task.
(run task)
Executes this task.
Executes this task.
(succ task)
The successive task to this one.
The successive task to this one.
Number of threads in the threadpool
Number of threads in the threadpool
Number of callers who would like a threadpool open right now
Number of callers who would like a threadpool open right now
(unix-micros->linear-micros unix)
Converts an instant in the unix timescale to an instant on the linear timescale, approximately.
Converts an instant in the unix timescale to an instant on the linear timescale, approximately.
Rebindable alias for real-unix-time
Rebindable alias for real-unix-time
Rebindable alias for real-unix-time-micros
Rebindable alias for real-unix-time-micros
(with-threadpool & body)
Ensures the threadpool is running within body
, which is evaluated in an
implicit do
. Multiple threads can call with-threadpool
concurrently. If any thread is within with-threadpool
, the pool will run,
and when no threads are within with-threadpool
, the pool will shut down.
You'll probably put this in the main entry points to your program, so the threadpool runs for the entire life of the program.
Ensures the threadpool is running within `body`, which is evaluated in an implicit `do`. Multiple threads can call with-threadpool concurrently. If any thread is within `with-threadpool`, the pool will run, and when no threads are within `with-threadpool`, the pool will shut down. You'll probably put this in the main entry points to your program, so the threadpool runs for the entire life of the program.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close