This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-22
Channels
- # beginners (240)
- # boot (23)
- # bristol-clojurians (3)
- # cider (101)
- # cljs-dev (52)
- # cljsrn (17)
- # clojure (212)
- # clojure-dusseldorf (2)
- # clojure-greece (2)
- # clojure-italy (9)
- # clojure-russia (1)
- # clojure-spec (91)
- # clojure-uk (33)
- # clojurescript (164)
- # community-development (23)
- # core-async (24)
- # core-logic (9)
- # cursive (18)
- # datavis (1)
- # datomic (119)
- # emacs (13)
- # events (1)
- # figwheel (2)
- # fulcro (86)
- # graphql (1)
- # immutant (5)
- # jobs-discuss (6)
- # leiningen (19)
- # lumo (46)
- # nyc (7)
- # off-topic (23)
- # parinfer (15)
- # pedestal (3)
- # planck (32)
- # re-frame (48)
- # reagent (75)
- # ring-swagger (13)
- # rum (32)
- # shadow-cljs (402)
- # spacemacs (5)
- # specter (3)
- # tools-deps (11)
- # unrepl (20)
- # vim (135)
- # yada (3)
Does anyone have any favorite core.async helper libs? E.g., full.async?
if I have a simple go block like this: (go (while true (receive/receiver (<! receive-chan))))
does the thread pool operate in such a way that the function receive/receiver
could simultaneously run on different threads with different items taken from receive-chan
? Or, does this block create a single process or thread that will handle all items?
the go block effectively becomes a series of one shot callbacks demarcated by parking channel operations (<!, >!, alt!)
so you have a single logical thread of control (each callback is called once and only one running at a time), but each callback may run on a different thread when it runs
so you can think of that code as something like ((fn f [] (when true (on/next-message receive-chan (fn [msg] (receive/receiver msg) (f))))))
@hiredman ah ok. i'm watching my cores on my laptop as that go block runs, and surprised to see all 8 of them light up from a single simple go block... that must be the multiple threads from the pool in action? It made me worry that there is a possibility that an item could be processed sooner than its previous item on the same channel was processed if they were simultaneous, but sounds like that is impossible in this case.
if the go block was inside the main, re-running main would just be the same as a top-level go block, wouldn't it?
and I guess a scoped go block would stick around even after its surrounding scope goes away?
because go blocks turn in to call backs on channels, their lifetime is tied to the lifetime of the channels
so, i restarted the repl entirely. the code was only evaluated once. all 8 cores still light up from that go block. interesting. now stuff is streaming very quickly from a socket and dumping onto the socket, so perhaps the pool is getting quite a workout. though it would seem to me that a single physical thread to process the channel would seem more efficient than switching between threads, but perhaps not