Permalink
Browse files

Complete the README.md.

  • Loading branch information...
1 parent 240e8a6 commit 1c730101d2c5ec3fd5e7d5b9cfdf2714a648d33a @Ruiyun committed Jul 16, 2012
Showing with 31 additions and 2 deletions.
  1. +31 −2 README.md
View
33 README.md
@@ -24,11 +24,40 @@ Then execute
lein deps
-And here is an example to show how to work with ruiyun.tools.timer.
+Quick tutorial
+==============
+
+You can simply start a period task with every 5 seconds immediately like this:
```clojure
(use 'ruiyun.tools.timer)
- TBD..
+ (run-task! #(println "Say hello every 5 seconds.") :period 5000)
+```
+
+If you want delay the first run with 2 seconds:
+
+```clojure
+ (run-task! #(println \"Say hello after 2 seconds.\") :dealy 2000)
+```
+
+Use this if you want to execute a task at an absolute time:
+
+```clojure
+ (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:
+
+```clojure
+ (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:
+
+```clojure
+ (cancel! greeting-timer)
```
Documentation

0 comments on commit 1c73010

Please sign in to comment.