Skip to content

Instantly share code, notes, and snippets.

@bostonou
Created August 28, 2013 16:56
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/6368388 to your computer and use it in GitHub Desktop.
Save bostonou/6368388 to your computer and use it in GitHub Desktop.
(defn channel=?
[a c]
(let [begin (System/currentTimeMillis)
v (= a (<!! c))]
(println "Waited" (- (System/currentTimeMillis) begin) "ms")
v))
(let [b (thread (<!! (timeout 500)) 10)]
(channel=? 10 b))
; => Waited 505ms
; => true
(let [b (thread (<!! (timeout 500)) 5)]
(channel=? 10 b))
; => Waited 503ms
; => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment