This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-18
Channels
- # announcements (43)
- # aws (28)
- # babashka (32)
- # beginners (80)
- # calva (13)
- # chlorine-clover (2)
- # cider (11)
- # clj-kondo (15)
- # cljs-dev (1)
- # clojure (151)
- # clojure-dev (11)
- # clojure-europe (11)
- # clojure-italy (3)
- # clojure-losangeles (3)
- # clojure-nl (4)
- # clojure-spec (20)
- # clojure-uk (58)
- # clojured (3)
- # clojuredesign-podcast (2)
- # clojurescript (37)
- # core-async (4)
- # core-typed (1)
- # cursive (53)
- # datascript (5)
- # datomic (26)
- # duct (23)
- # emacs (3)
- # fulcro (22)
- # graalvm (1)
- # jobs (2)
- # joker (11)
- # juxt (24)
- # lumo (1)
- # mid-cities-meetup (2)
- # nyc (1)
- # off-topic (54)
- # parinfer (1)
- # reagent (13)
- # shadow-cljs (16)
- # sql (9)
- # tree-sitter (9)
- # vim (9)
Check out https://clojurians.slack.com/archives/C05423W6H/p1580931637362700?thread_ts=1580931637.362700&cid=C05423W6H but watchout for the mentioned bugs
I was going to say that you could just do away with the timeout channels and just use a DelayQueue directly like the timeouts do
as long as you're targeting the JVM
I was thinking of trying a dynamic version of merge, This is the merge source
(defn merge
"Takes a collection of source channels and returns a channel which
contains all values taken from them. The returned channel will be
unbuffered by default, or a buf-or-n can be supplied. The channel
will close after all the source channels have closed."
([chs] (merge chs nil))
([chs buf-or-n]
(let [out (chan buf-or-n)]
(go-loop [cs (vec chs)]
(if (pos? (count cs))
(let [[v c] (alts! cs)]
(if (nil? v)
(recur (filterv #(not= c %) cs))
(do (>! out v)
(recur cs))))
(close! out)))
out)))
I can create a channel for each incoming element, deliver it to that channel after timeout, and always prune the closed channels as merge does. I worry that the performance of alts
will be degrade for a large number of elements.