   "Specifies that a list of dependencies have been satisfied. Uses an agent so
   it's safe to call this from within a transaction."
   [& deps]
+  (log/info (format "satisfying deps: %s" deps))
   (send-off dep-state* satisfy* (set deps)))
 
 (defn reset-deps


(defn- satisfy*
  [{:keys [satisfied todo done]} new-deps]
  ;(log/info (format "new-deps: %s" new-deps))
  (let [satisfied (set/union satisfied new-deps)
        ;_ (log/info (format "satisfied: %s" satisfied))
        execute-tasks (fn [[final-done final-todo] [key deps task]]
                        ;(log/info (format "Satisfied? = %s --- sat: %s deps: %s" (set/superset? satisfied deps) satisfied deps))
                        (if (set/superset? satisfied deps)
                          (do
                            ;(log/info "Satisfying deps: " deps)
                            (task)
                            [(conj final-done [key deps task]) final-todo])
                          [final-done (conj final-todo [key deps task])]))
        [t-done t-todo] (reduce execute-tasks [done []] todo)]
    {:satisfied satisfied
     :done t-done
     :todo t-todo}))


(defn wait-until-deps-satisfied
  "Makes the current thread sleep until specified deps have been satisfied.
  Thread enters a sleep cycle sleeping for wait-time seconds before each dep check.
  If timeout is a positive value throws timeout exception if deps haven't been
  satisfied by timeout secs. The default wait-time is 0.1 seconds, and the
  default timeout is 10 seconds."
  ([deps] (wait-until-deps-satisfied deps 10 0.1))
  ([deps timeout] (wait-until-deps-satisfied deps timeout 0.1))
  ([deps timeout wait-time]
   (let [timeout (* 1000 timeout)
         wait-time (* 1000 wait-time)]
     (if (<= timeout 0)
       (while (not (deps-satisfied? deps))
         (Thread/sleep wait-time))
       (loop [sleep-time 0]
         (when (> sleep-time timeout)
           (throw (Exception. (str "The following deps took too long (" timeout
                                   " seconds) to be satisfied: " deps))))
         (when-not (deps-satisfied? deps)
           (Thread/sleep wait-time)
           (recur (+ sleep-time wait-time))))))))
