-
-
Save elfenlaid/14ab3cc6bc4e6a93d0ae to your computer and use it in GitHub Desktop.
This file contains 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 waitForFuture [timeout & refs] (doseq [r refs] (deref r timeout nil))) | |
(def phrase (ref "hello")) | |
(waitForFuture 1 | |
(future (dosync (println "will rename phrase") (Thread/sleep 100) (ref-set phrase "world"))) | |
(future (dosync (println (ensure phrase)) (Thread/sleep 3000) (println (ensure phrase))))) | |
will rename phrase | |
hello | |
nil | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
will rename phrase | |
hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment