Skip to content

Instantly share code, notes, and snippets.

@bostonou
Created August 28, 2013 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bostonou/6368353 to your computer and use it in GitHub Desktop.
Save bostonou/6368353 to your computer and use it in GitHub Desktop.
(defn future=?
[a f]
(let [begin (System/currentTimeMillis)
v (= a @f)]
(println "Waited" (- (System/currentTimeMillis) begin) "ms")
v))
(let [b (future (Thread/sleep 500) 10)]
(future=? 10 b))
; => Waited 501 ms
; => true
(let [b (future (Thread/sleep 500) 5)]
(future=? 10 b))
; => Waited 501 ms
; => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment