Hi all!
I’m working with core.async pub/sub and ran into an issue which I don’t
quite understand. According to the clojure.core.async/sub docstring:
> By default the channel will be closed when the source closes
This is not the behaviour I’m seeing when I call
clojure.core.async/unsub-all immediately after I close the source channel.
Example:
(def source (async/chan))
(def sub-chan (async/chan))
(def pub (async/pub source (constantly "foo")))
;; by default sub-chan should close when source closes
(async/sub pub "foo" sub-chan)
;; This will not close sub-chan
(async/thread
(async/close! source)
(async/unsub-all pub))
;; This will close sub-chan
(async/thread
(async/close! source))
What is the reason for this behaviour? Is it unnecessary to call unsub-all
if I close the publications source channel?
Thanks,
Jonas
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.