Liking cljdoc? Tell your friends :D
Clojure only.

loom-otp.timer

Timer functions for delayed and periodic operations.

Timers are implemented as processes:

  • One-shot timers: unlinked process that sleeps then executes
  • Interval timers: linked process that loops, stopping when caller dies

All timer functions return a Timer record that can be passed to cancel.

Timer functions for delayed and periodic operations.

Timers are implemented as processes:
- One-shot timers: unlinked process that sleeps then executes
- Interval timers: linked process that loops, stopping when caller dies

All timer functions return a Timer record that can be passed to cancel.
raw docstring

cancelclj

(cancel timer)

Cancel a timer. Returns true if timer process existed, false otherwise.

Cancel a timer. Returns true if timer process existed, false otherwise.
sourceraw docstring

start-timerclj

(start-timer
  {:keys [after-ms every-ms link catch-all] :or {after-ms 0} :as opts}
  f
  &
  args)

Create and start a timer. Returns a Timer record.

Options:

  • :after-ms - ms before first fire (default: 0)
  • :every-ms - ms between fires (nil = one-shot)
  • :link - link to caller (default: true if :every-ms, false otherwise)
  • :catch-all - catch exceptions in f and continue (default: false)

Examples: (start-timer {:after-ms 1000} f) ; one-shot after 1s (start-timer {:after-ms 1000 :every-ms 1000} f) ; every 1s (start-timer {:after-ms 0 :every-ms 1000} f) ; immediately, then every 1s (start-timer {:after-ms 1000 :link true} f x y) ; one-shot, linked (start-timer {:every-ms 1000 :catch-all true} f) ; interval, survives exceptions

Create and start a timer. Returns a Timer record.

Options:
- :after-ms  - ms before first fire (default: 0)
- :every-ms  - ms between fires (nil = one-shot)
- :link      - link to caller (default: true if :every-ms, false otherwise)
- :catch-all - catch exceptions in f and continue (default: false)

Examples:
(start-timer {:after-ms 1000} f)                      ; one-shot after 1s
(start-timer {:after-ms 1000 :every-ms 1000} f)       ; every 1s
(start-timer {:after-ms 0 :every-ms 1000} f)          ; immediately, then every 1s
(start-timer {:after-ms 1000 :link true} f x y)       ; one-shot, linked
(start-timer {:every-ms 1000 :catch-all true} f)      ; interval, survives exceptions
sourceraw docstring

tcclj

(tc n unit)

Time constant - convert time unit to milliseconds. (tc 5 :seconds) => 5000 (tc 2 :minutes) => 120000

Time constant - convert time unit to milliseconds.
(tc 5 :seconds) => 5000
(tc 2 :minutes) => 120000
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close