-
-
Save jsab/ff8f4689d48192ab8a6f to your computer and use it in GitHub Desktop.
experiment with closing and putting in core.async
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
(require '[clojure.core.async :refer [>! <! chan go timeout]]) | |
(defn test-closers | |
[buffer delay] | |
(let [ch (chan buffer)] | |
(go (dotimes [n buffer] | |
(>! ch :buffer)) | |
(>! ch 1) | |
(println 1) | |
(>! ch 2) | |
(println :done)) | |
(go (<! ch) | |
(when delay | |
(<! (timeout delay)) | |
(println "waited" delay)) | |
(close! ch))) | |
nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment