Permalink
Browse files

Move defn above .

  • Loading branch information...
1 parent 0c741c4 commit 2c501c82065968df785b0fd028f1230b121a8c8e @jeremyheiler committed Apr 21, 2012
Showing with 12 additions and 9 deletions.
  1. +12 −9 src/trabajo/core.clj
View
@@ -112,13 +112,24 @@
(recur (if (nil? qs) queues qs) p)))
(recur q+qs (request-promise-from-work-manager))))))
+(defn running?
+ "Returns true if the work-manager thread is running, otherwise false."
+ []
+ (dosync
+ (if-let [t (:thread @work-manager)]
+ (.isAlive? t)
+ false)))
+
(defn start
"Starts a work manager that polls jobs on the given queue."
[n & queues]
(dosync
(if-not (running?)
(let [t (Thread. #(process queues))]
- (alter work-manager assoc :thread t :max-workers n)
+ (ref-set work-manager
+ {:thread t
+ :promises (clojure.lang.PersistentQueue/EMPTY)
+ :max-workers n})
(.start t))
(throw (IllegalStateException. "A work manager has already been started.")))))
@@ -129,11 +140,3 @@
(when-let [t (:thread @work-manager)]
(.interrupt t))))
-(defn running?
- "Returns true if the work-manager thread is running, otherwise false."
- []
- (dosync
- (if-let [t (:thread @work-manager)]
- (.isAlive? t)
- false)))
-

0 comments on commit 2c501c8

Please sign in to comment.