Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
hiredman committed Nov 5, 2010
1 parent 0a2b645 commit 17ad6c5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README
Expand Up @@ -21,6 +21,18 @@ geister.core> @*1
7
geister.core>

async-loop:
like clojure's built in loop. use async-recur instead of recur. each loop iteration
is queued up as a seperate async task.
geister.core> (async-loop [[x & xs] (range 10) t 0]
(if x
(async-recur xs (+ x t))
t))
geister.core.Task@90ce3f54
geister.core> @*1
45
geister.core>

async tasks are chainable:
geister.core> (chain (task (+ 1 2)) (fn [x] (task (inc x))))
geister.core.Task@aadbba2f
Expand All @@ -35,6 +47,18 @@ geister.core> @*1
(3 7)
geister.core>

exceptions are propagated through chains of async tasks. if you deref an async task
and any async tasks that it depended on threw an exception, then that exception will
be thrown.
geister.core> (async [x (task "foo")
y (task (+ 1 2))]
(+ y x))
geister.core.Task@463b2d3c
geister.core> (try @*1 (catch Exception e (println e)))
#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>
nil
geister.core>

by default tasks are queued on clojure's pooledExecutor (same as send). you can rebind
*task-handler* to change how and where async tasks are executed.

Expand Down

0 comments on commit 17ad6c5

Please sign in to comment.