4c1055d72377
Hurr durr. Hurr.
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Fri, 26 Aug 2011 18:40:45 -0400 |
parents | cb2d6c82204a |
children | 5e3e3e14ea5c |
branches/tags | (none) |
files | src/clojurecraft/events.clj |
Changes
--- a/src/clojurecraft/events.clj Fri Aug 26 18:37:57 2011 -0400 +++ b/src/clojurecraft/events.clj Fri Aug 26 18:40:45 2011 -0400 @@ -23,19 +23,3 @@ (defn clear-handlers [bot event-type] (dosync (alter (:event-handlers bot) dissoc event-type))) - -; Loops ---------------------------------------------------------------------------- -(defn- run-loop [bot function sleep-ms loop-id] - (while (and (nil? (:exit @(:connection bot))) - (@(:loops bot) loop-id)) - (handle-action-group bot ((deref function) bot)) - (Thread/sleep sleep-ms)) - (dosync (alter (:loops bot) dissoc loop-id))) - - -(defn remove-loop [bot loop-id] - (dosync (alter (:loops bot) assoc loop-id nil))) - -(defn add-loop [bot function sleep-ms loop-id] - (dosync (alter (:loops bot) assoc loop-id :running)) - (.start (Thread. #(run-loop bot function sleep-ms loop-id))))