Skip to content

Instantly share code, notes, and snippets.

@reiddraper
Created October 30, 2011 15:57
Show Gist options
  • Select an option

  • Save reiddraper/1326062 to your computer and use it in GitHub Desktop.

Select an option

Save reiddraper/1326062 to your computer and use it in GitHub Desktop.
(defn slow []
(do (. Thread (sleep 700)) "slow call"))
(defn fast []
(do (. Thread (sleep 100)) "fast call"))
(defn thread-deliver [fun prom]
(.start (Thread. (fn [] (deliver prom (fun))))))
(defn main [a aw b overall default]
(let [p (promise)]
(thread-deliver a p)
(let [r (deref p aw nil)]
(cond r r
:else (do
(thread-deliver b p)
(deref p (- overall aw) default))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment