More idiomatic looping

This commit is contained in:
Jeremy Penner 2013-03-09 09:26:09 -06:00
parent 1118b012f1
commit 492b5393a1

View file

@ -13,18 +13,14 @@
(defn post-event [event]
(post-event-to *evq* event))
(defn handle-next-event [evq & dispatchersInit]
(defn handle-next-event [evq & dispatchers]
(dosync (let [queueold @evq]
(if (seq queueold)
(let [queuenew (pop queueold) event (peek queueold)]
(loop [dispatchers dispatchersInit]
(if (seq dispatchers)
(do
((first dispatchers) event)
(recur (next dispatchers)))
(do
(doseq [dispatcher dispatchers]
(dispatcher event))
(ref-set evq queuenew)
true))))
true)
false))))
(defn handle-events [evq & dispatchers]