Skip to content

An easy to use Java Timer wrapper for Clojure.

Notifications You must be signed in to change notification settings

WickedShell/tools-timer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tools-timer

Build Status

The tools-timer is a Java Timer and TimerTask wrapper for Clojure.

API Warning

The API is currently undergoing some tweaks to simplify the interface. These should be concluded with the 1.0.3 stable release.

Installation

Add the following to your project.clj:

[tools-timer "1.0.4"]

Quick tutorial

You can simply start a period task in every 5 seconds immediately like this:

(use 'tools-timer.core)
(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.") :delay 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 :name "The timer for greeting"))
(run-task! #(println "Say hello after 2 seconds.") :delay 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)

Documentation

For more detailed information on ruiyun.tools.timer, please refer to the [documentation].

Contributors

Forked from ruiyun.tools.timer, by Ruiyun Wen

License

Copyright (C) 2012 Ruiyun Wen

Distributed under the Eclipse Public License, the same as Clojure.

About

An easy to use Java Timer wrapper for Clojure.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Clojure 100.0%