Created
October 30, 2011 15:57
-
-
Save reiddraper/1326062 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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