Liking cljdoc? Tell your friends :D

ruiyun.tools.timer

ruiyun.tools.timer is an easy to use Java Timer wrapper for clojure. You can simply start a period task in every 5 seconds immediately like this:

(run-task! #(println "Say hello every 5 seconds.") :period 5000)

If you want delay the first run with 2 seconds:

(run-task! #(println "Say hello after 2 seconds.") :dealy 2000)

Use this if you want to execute a task at an absolute time:

(run-task! #(println "Say hello at 2013-01-01T00:00:00 in beijing.") :at #inst "2013-01-01T00:00:00+08:00")

And, you can use the same timer in more than one tasks:

(def greeting-timer (timer "The timer for greeting")) (run-task! #(println "Say hello after 2 seconds.") :dealy 2000 :by greeting-timer) (run-task! #(println "Say hello every 5 seconds.") :period 5000 :by greeting-timer)

Finally, you can cancel a timer's tasks:

(cancel! greeting-timer)

ruiyun.tools.timer is an easy to use Java Timer wrapper for clojure.
You can simply start a period task in every 5 seconds immediately like this:

  (run-task! #(println "Say hello every 5 seconds.") :period 5000)

If you want delay the first run with 2 seconds:

  (run-task! #(println "Say hello after 2 seconds.") :dealy 2000)

Use this if you want to execute a task at an absolute time:

  (run-task! #(println "Say hello at 2013-01-01T00:00:00 in beijing.") :at #inst "2013-01-01T00:00:00+08:00")

And, you can use the same timer in more than one tasks:

  (def greeting-timer (timer "The timer for greeting"))
  (run-task! #(println "Say hello after 2 seconds.") :dealy 2000 :by greeting-timer)
  (run-task! #(println "Say hello every 5 seconds.") :period 5000 :by greeting-timer)

Finally, you can cancel a timer's tasks:

  (cancel! greeting-timer)
raw docstring

cancel!clj

(cancel! timer)

Terminates a timer, discarding any currently scheduled tasks.

Terminates a timer, discarding any currently scheduled tasks.
sourceraw docstring

deamon-timerclj

(deamon-timer)
(deamon-timer name)

Create a new java.util.Timer object with deamon option.

Create a new java.util.Timer object with deamon option.
sourceraw docstring

run-task!clj

(run-task! task & {:keys [by at delay period on-exception]})

Execute a timer task, then return the timer user passed or be auto created. Normally, User need set one of the two options: :at <time> :delay <milliseconds> If set none of them, the task will launch immediately.

Optional, user can set: :period <milliseconds>

If user want share a timer between tow or more tasks, he can set an exist timer: :by <a timer>

Sometimes user task may cause exception, it's a good reason to use an exception handler: :on-exception <handle function with an exception argument>

Execute a timer task, then return the timer user passed or be auto created.
Normally, User need set one of the two options:
  :at <time>
  :delay <milliseconds>
If set none of them, the task will launch immediately.

Optional, user can set:
  :period <milliseconds>

If user want share a timer between tow or more tasks, he can set an exist timer:
  :by <a timer>

Sometimes user task may cause exception, it's a good reason to use an exception handler:
  :on-exception <handle function with an exception argument>
sourceraw docstring

timerclj

(timer)
(timer name)

Create a new java.util.Timer object.

Create a new java.util.Timer object.
sourceraw docstring

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

× close