Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(require '[manifold.deferred :as d])
(defn long-boring-computation []
(let [result (d/deferred)]
(dotimes [_ 100]
(when-not (d/realized? result)
;; block the thread is still a bad idea :(
(Thread/sleep 1e3)))
(d/success! result "I'm done with this"))
(def f1 (long-boring-computation))
;; we're already running
(d/error! f1 (Exception. "I don't need this, sorry"))
;; will stop on the next iteration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment