Skip to content

Instantly share code, notes, and snippets.

@ray1729
Last active Aug 29, 2015
Embed
What would you like to do?
(ns rollup.core
(:require [clojure.core.async :refer [go chan <! put! timeout alt! alts!]]))
(def ch (chan))
(go
(loop [stash []]
(let [[v c] (alts! [ch (timeout 3000)])]
(if (= c ch)
(when v
(when (< (count stash) 5)
(println "A" v))
(recur (conj stash v)))
(do
(when (not-empty stash)
(println "B" stash))
(recur []))))))
(dotimes [n 20] (put! ch n))
(clojure.core.async/close! ch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment