 
 (defn run [this settings cleanup?]
   (def last-acq this)
+  (def last-state (.state this))
     (reset! (.state this) {:stop false :pause false :finished false})
     (let [out-queue (LinkedBlockingQueue. 10)
           acq-thread (Thread. #(binding [state (.state this)]

                           (if (instance? Throwable item)
                             (throw item)
                             item))))]
    (future (dotimes [i n]
              (try (.put queue (function))
                   (catch Throwable t
                          (.put queue t)


;; globals

(def ^:dynamic state nil)

(def attached-runnables (atom (vec nil)))

