This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-03-29
Channels
- # announcements (9)
- # aws (1)
- # beginners (133)
- # boot (2)
- # calva (94)
- # cider (48)
- # cljdoc (7)
- # cljsrn (22)
- # clojure (128)
- # clojure-europe (22)
- # clojure-finland (7)
- # clojure-greece (6)
- # clojure-losangeles (3)
- # clojure-nl (81)
- # clojure-spec (30)
- # clojure-uk (60)
- # clojure-ukraine (1)
- # clojurescript (45)
- # core-async (26)
- # cursive (18)
- # datomic (12)
- # defnpodcast (1)
- # duct (4)
- # editors (4)
- # emacs (6)
- # fulcro (37)
- # graphql (4)
- # jobs (2)
- # jobs-rus (1)
- # juxt (7)
- # kaocha (2)
- # leiningen (1)
- # nrepl (22)
- # off-topic (2)
- # re-frame (16)
- # reagent (8)
- # reitit (22)
- # ring-swagger (5)
- # shadow-cljs (81)
- # tools-deps (4)
The main difference between Golang and Clojures Core-Async is that in Golang you do not have to care about "Blocking"?
or would that be sorted using the async/thread-macro? i am trying to find some good reading material on this topic
Yes, golang has a scheduler that detects blocking sys calls and spins up a new physical thread: https://github.com/ardanlabs/gotraining/tree/master/topics/go/concurrency/goroutines
core.async doesn't have a scheduler so having blocking IO is a bad idea, you risk dead locking core.async's threadpool
@U0CME35FV thanks for the gotraining link, it has some specifics for coroutine and channel designs and also other generic software design ideas, liked it 👍
I really liked it as well, thank you @U0CME35FV! 🙂
so, I have this really common problem in core.async and have yet to figure out what the "correct" answer is
so, I have a channel that contains a list of values, and I perform an async call on each of those values, and the async call returns a channel. Now I have a channel that has a list of channels
continue, but my guess is you need to switch a map somewhere for pipeline or pipeline async
ideally, ultimately, I want a channel where each value is the result of the get call
hmm.. so
(pipeline-blocking 8 output-chan (map (partial map fetch) input-chan)
is my situation.oh, so that cat is going to emit values one at a time? that wouldn't say, wait for all the fetches to produce a value?
if thats the case I guess I could just
(pipeline-blocking 8 output-chan cat (onto-chan [(chan) (chan) (chan)])
right?
(pipeline-blocking 8 output-chan cat
(to-chan [(go 1) (go (<! (timeout 1000)) 2) (go (<! (timeout 4000)) 3)]))
so in this case, would output-chan require 0 seconds or 4 seconds to emit its first value?well, having no "correct" way of doing things, here's what I have been doing.
(defn chain! [in!]
(let [out! (a/chan)]
(a/go-loop
[next! (a/<! in!)]
(if next!
(do
(<! (go (loop [subval (a/<! next!)]
(when subval (a/>! out! subval)
(recur (a/<! next!))))))
(recur (a/<! in!)))
(a/close! out!)))
out!))