Skip to content

Instantly share code, notes, and snippets.

@jsab
Forked from noisesmith/async-test.clj
Last active January 8, 2016 14:21
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 jsab/ff8f4689d48192ab8a6f to your computer and use it in GitHub Desktop.
Save jsab/ff8f4689d48192ab8a6f to your computer and use it in GitHub Desktop.
experiment with closing and putting in core.async
(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