This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-30
Channels
- # aleph (1)
- # beginners (126)
- # cider (2)
- # clara (38)
- # cljsrn (2)
- # clojars (2)
- # clojure (49)
- # clojure-dev (31)
- # clojure-dusseldorf (1)
- # clojure-finland (1)
- # clojure-france (6)
- # clojure-italy (13)
- # clojure-nl (12)
- # clojure-russia (9)
- # clojure-sg (1)
- # clojure-spec (33)
- # clojure-uk (83)
- # clojurescript (206)
- # community-development (3)
- # core-async (40)
- # cursive (4)
- # datomic (7)
- # duct (21)
- # emacs (9)
- # fulcro (36)
- # funcool (2)
- # graphql (12)
- # instaparse (4)
- # jobs (4)
- # lumo (24)
- # mount (1)
- # nyc (4)
- # off-topic (29)
- # onyx (1)
- # pedestal (2)
- # random (4)
- # re-frame (60)
- # reagent (136)
- # remote-jobs (1)
- # schema (1)
- # shadow-cljs (20)
- # spacemacs (6)
- # specter (14)
- # tools-deps (2)
the one patch I managed to get in took something like 7 months, and I have a patch that hasn't seen any movement in over year, and I have some new patches that I just started the clock on
FWIW I have no idea whether what I’m doing is a decent approach, but Alex and I got into a twitter conversation about it here: https://twitter.com/clarkkampfe/status/995068142194962432
I’m planning to do a pass on async this summer
When depends on priority of other things but I have a bunch of stuff bookmarked
I’ve been on a consulting project for the last few months so I only have a few hrs a week right now but I’m expecting that to open up soon
Hey. I'm doing something like
(let [chan (async/chan 100 xform)]
(async/go-loop []
(let [msg (async/<! chan)]
(my-foo msg)
(recur))
(future (loop [pooling 0]
(Thread/sleep 1000)
;; in the real world, it's a HTTP Request
;; that returns a "coll-of" msg
(doseq [msg (range 10)]
(async/>!! chan [pooling msg]))
(recur (inc pooling)))))
In this cenario, my-foo
will be called in parallel? Can I control how many parallel my-foo
will run? Or it will be handled smartly as in golang
?If my-foo is only in one go block it will have a maximum of 1 call running. You can start go blocks in a loop, or use something designed for parallel processing like pipeline, pipeline-async or pipeline-blocking
Also, I understand this is a minimal example, but in real code you want to nil check your chan operation result and not call your function or recur if it's nil
(that is, bail if msg is nil)
I'm not doing that at (let [ch (timeout 5000)])
?
timeout returns channels that close after the given number of milliseconds, and it may return the same channel more than once (the channels are shared)
I pulled this example from David Nolen, just retooling it a bit for node: http://swannodette.github.io/2013/07/12/communicating-sequential-processes
you replaced a real channel (chan)
with (timeout)
which doesn't do what you think it does
hmm... help me out here
I thought timeout
returned a chan
it does return a channel, but that channel is only there to signal you when the given number of milliseconds has elapsed
ah, ok, that wasn't clear in the docs http://clojure.github.io/core.async/#clojure.core.async/timeout
so, I should (let [ch (chan (timeout 500))]...
?
ok, i'm sorry if this is obvious. I'm new 😇
Let me get back to it then...
@loganpowell can you elaborate a bit on what you’re trying to achieve?
I think it's based on one of dnolen's demos, just showing what core.async does