Liking cljdoc? Tell your friends :D

tea-time.core

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!).
raw docstring

after!clj

(after! delay f)

Calls f after delay seconds.

Calls f after delay seconds.
sourceraw docstring

at-linear-micros!clj

(at-linear-micros! t f)

Calls f at t microseconds on the linear timescale.

Calls f at t microseconds on the linear timescale.
sourceraw docstring

at-unix!clj

(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.
sourceraw docstring

at-unix-micros!clj

(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.
sourceraw docstring

ceilclj

(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.
sourceraw docstring

Deferrablecljprotocol

defer!clj

(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!clj

(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
source

Everyclj

source

every!clj

(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.
sourceraw docstring

linear-timeclj

Rebindable alias for real-linear-time

Rebindable alias for real-linear-time
sourceraw docstring

linear-time-microsclj

Rebindable alias for real-linear-time-micros

Rebindable alias for real-linear-time-micros
sourceraw docstring

max-task-idclj

source

micros->secondsclj

(micros->seconds t)

Convert microseconds to seconds, as doubles.

Convert microseconds to seconds, as doubles.
sourceraw docstring

next-tickclj

(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.
sourceraw docstring

Onceclj

source

park-interval-microsclj

Time we might sleep when nothing is scheduled, in micros.

Time we might sleep when nothing is scheduled, in micros.
sourceraw docstring

poll-task!clj

(poll-task!)

Removes the next task from the queue.

Removes the next task from the queue.
sourceraw docstring

real-linear-timeclj

(real-linear-time)

The current linear time in seconds, taken from System/nanoTime

The current linear time in seconds, taken from System/nanoTime
sourceraw docstring

real-linear-time-microsclj

(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.
sourceraw docstring

real-unix-timeclj

(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
sourceraw docstring

real-unix-time-microsclj

(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
sourceraw docstring

reset-tasks!clj

(reset-tasks!)

Resets the task queue to empty, without triggering side effects.

Resets the task queue to empty, without triggering side effects.
sourceraw docstring

run-tasks!clj

(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.
sourceraw docstring

runningclj

Whether the threadpool is currently supposed to be alive.

Whether the threadpool is currently supposed to be alive.
sourceraw docstring

schedule!clj

(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.
sourceraw docstring

schedule-sneaky!clj

(schedule-sneaky! task)

Schedules a task. Does not awaken any threads.

Schedules a task. Does *not* awaken any threads.
sourceraw docstring

seconds->microsclj

(seconds->micros t)

Convert seconds to microseconds, as longs.

Convert seconds to microseconds, as longs.
sourceraw docstring

start!clj

(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.
sourceraw docstring

stop!clj

(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.
sourceraw docstring

Taskcljprotocol

cancel!clj

(cancel! task)

Cancel this task.

Cancel this task.

runclj

(run task)

Executes this task.

Executes this task.

succclj

(succ task)

The successive task to this one.

The successive task to this one.
source

task-idclj

(task-id)

Return a new task ID.

Return a new task ID.
sourceraw docstring

tasksclj

Scheduled operations.

Scheduled operations.
sourceraw docstring

thread-countclj

Number of threads in the threadpool

Number of threads in the threadpool
sourceraw docstring

threadpoolclj

source

threadpool-usersclj

Number of callers who would like a threadpool open right now

Number of callers who would like a threadpool open right now
sourceraw docstring

unix-micros->linear-microsclj

(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.
sourceraw docstring

unix-timeclj

Rebindable alias for real-unix-time

Rebindable alias for real-unix-time
sourceraw docstring

unix-time-microsclj

Rebindable alias for real-unix-time-micros

Rebindable alias for real-unix-time-micros
sourceraw docstring

with-threadpoolcljmacro

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close