Thanks for the explanation! This is very close to what I want. I see some
confusing behavior though. See below.
On Friday, January 5, 2018 at 2:40:14 PM UTC-5, Brian J. Rubinton wrote:
>
>
> The work-queue channel has a fixed buffer size of 1. A collection (range
> 50) is put on the channel. While consumers can take items off the channel —
> note the individual contents of (range 50) are returned — a producer cannot
> put another value onto the channel until the entire initial collection is
> consumed.
>
I tried your example code works for me, but then I tried using `>!!`
instead of `offer!` and it behaves differently.
user> (def c (chan 1 (mapcat identity)))
=> #'user/c
user> (do
(async/thread (async/>!! c [1 2 3]) (println "put #1"))
(async/thread (async/>!! c [4 5 6]) (println "put #2"))
(async/thread (async/>!! c [7 8 9]) (println "put #3")))
put #1
As expected it prints "put #1" right away, and other threads are blocked.
But...
user> (poll! c)
=> 1
put #2
user> (poll! c)
=> 2
put #3
As soon as your read anything from it, other puts succeed. Shouldn't they
be blocked?
Rob
--
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.