Created
August 28, 2013 16:56
-
-
Save bostonou/6368388 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 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