Liking cljdoc? Tell your friends :D

manifold.time

This namespace contains methods for converting units of time, with milliseconds as the base representation, and for deferring execution of functions to some time in the future. In practice, the methods here are not necessary to use Manifold effectively - manifold.deferred/timeout and manifold.stream/periodically are more directly useful - but they are available for anyone who should need them.

This namespace contains methods for converting units of time, with milliseconds as the base representation, and for deferring execution of functions to some time in the future.  In practice, the methods here are not necessary to use Manifold effectively - `manifold.deferred/timeout` and `manifold.stream/periodically` are more directly useful - but they are available for anyone who should need them.
raw docstring

*clock*clj

source

addclj

(add timestamp value unit)

Takes a timestamp, and adds value multiples of unit to the value.

Takes a `timestamp`, and adds `value` multiples of `unit` to the value.
sourceraw docstring

atclj

(at timestamp f)

Schedules no-arg function f to be invoked at timestamp, which is the milliseconds since the epoch. Returns a deferred representing the returned value of the function (unwrapped if f itself returns a deferred).

Schedules no-arg function `f` to be invoked at `timestamp`, which is the milliseconds
since the epoch.  Returns a deferred representing the returned value of the function
(unwrapped if `f` itself returns a deferred).
sourceraw docstring

daysclj

(days n)

Converts days -> milliseconds

Converts days -> milliseconds
sourceraw docstring

everyclj

(every period f)
(every period initial-delay f)

Schedules no-arg function f to be invoked every period milliseconds, after initial-delay milliseconds, which defaults to 0. Returns a zero-argument function which, when invoked, cancels the repeated invocation.

If the invocation of f ever throws an exception, repeated invocation is automatically cancelled.

Schedules no-arg function `f` to be invoked every `period` milliseconds, after `initial-delay`
milliseconds, which defaults to `0`.  Returns a zero-argument function which, when invoked,
cancels the repeated invocation.

If the invocation of `f` ever throws an exception, repeated invocation is automatically
cancelled.
sourceraw docstring

floorclj

(floor timestamp unit)

Takes a timestamp, and rounds it down to the nearest even multiple of the unit.

(floor 1001 :second) => 1000 (floor (seconds 61) :minute) => 60000

Takes a `timestamp`, and rounds it down to the nearest even multiple of the `unit`.

(floor 1001 :second) => 1000
(floor (seconds 61) :minute) => 60000

sourceraw docstring

format-durationclj

(format-duration n)

Takes a duration in milliseconds, and returns a formatted string describing the interval, i.e. '5d 3h 1m'

Takes a duration in milliseconds, and returns a formatted string
describing the interval, i.e. '5d 3h 1m'
sourceraw docstring

hoursclj

(hours n)

Converts hours -> milliseconds

Converts hours -> milliseconds
sourceraw docstring

hzclj

(hz n)

Converts frequency -> period in milliseconds

Converts frequency -> period in milliseconds
sourceraw docstring

IMockClockcljprotocol

advanceclj

(advance clock time)

Advances the mock clock by the specified interval of time.

Advancing the clock is a continuous action - the clock doesn't just jump from now to new-now = (+ (now clock) time). Rather, for each scheduled event within [now; new-now] the clock is reset to the time of the event and the event function is executed.

For example, if you have a periodic function scheduled with

(every 1 #(swap! counter inc))

and advance the clock by 5, the counter will be incremented 6 times in total: once initially, as the initial delay is 0 and 5 times for every 1 ms step of the clock.

Advances the mock clock by the specified interval of `time`.

Advancing the clock is a continuous action - the clock doesn't just jump
from `now` to `new-now = (+ (now clock) time)`. Rather, for each scheduled
event within `[now; new-now]` the clock is reset to the time of the event
and the event function is executed.

For example, if you have a periodic function scheduled with

  (every 1 #(swap! counter inc))

and advance the clock by 5, the counter will be incremented 6 times in
total: once initially, as the initial delay is 0 and 5 times for every 1 ms
step of the clock.

nowclj

(now clock)

Returns the current time for the clock

Returns the current time for the clock
source

inclj

(in interval f)

Schedules no-arg function f to be invoked in interval milliseconds. Returns a deferred representing the returned value of the function (unwrapped if f itself returns a deferred). If the returned deferred is completed before the interval has passed, the timeout function will be cancelled.

Schedules no-arg function `f` to be invoked in `interval` milliseconds.  Returns a deferred
representing the returned value of the function (unwrapped if `f` itself returns a deferred).
If the returned deferred is completed before the interval has passed, the timeout function
will be cancelled.
sourceraw docstring

microsecondsclj

(microseconds n)

Converts microseconds -> milliseconds

Converts microseconds -> milliseconds
sourceraw docstring

millisecondsclj

(milliseconds n)

Converts milliseconds -> milliseconds

Converts milliseconds -> milliseconds
sourceraw docstring

minutesclj

(minutes n)

Converts minutes -> milliseconds

Converts minutes -> milliseconds
sourceraw docstring

mock-clockclj

(mock-clock)
(mock-clock initial-time)

Creates a clock designed for testing scheduled behaviors. It can replace the default scheduler using with-clock, and can be advanced to a particular time via advance. By default, the initial time is 0.

Creates a clock designed for testing scheduled behaviors.  It can replace the default
scheduler using `with-clock`, and can be advanced to a particular time via `advance`.  By
default, the initial time is `0`.
sourceraw docstring

nanosecondsclj

(nanoseconds n)

Converts nanoseconds -> milliseconds

Converts nanoseconds -> milliseconds
sourceraw docstring

scheduled-executor->clockclj

(scheduled-executor->clock e)
source

secondsclj

(seconds n)

Converts seconds -> milliseconds

Converts seconds -> milliseconds
sourceraw docstring

with-clockcljmacro

(with-clock clock & body)

Ensures that all calls to every and in are made through the specified clock, rather than the default one.

Ensures that all calls to `every` and `in` are made through the specified clock, rather
than the default one.
sourceraw docstring

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

× close