Consider a happy, oblivious producer of values:

(def c (chan 42))

(go (while true (>! c (rand))))

It doesn't know where/now the channel is consumed (which part of the point 
of channels/queues). However, we *do* know that at some point, nobody will 
need the result of our producing, so we should stop our activity.

It seems to me that a natural way to tell the producer to stop is to close 
the channel. However:

* there's nothing like a clojure.core.async/chan-closed? fn, AFAICT
* The >! fn unconditionally returns nil, whether the channel is open or 
not. Only the blocking nature of the call can potentially vary - which is 
not particularly useful for the purpose.

What would be an adequate way to indicate termination? Just telling the 
producer to stop (e.g. (reset! keep-producing false)) would break the 
indirection one gains by using channels.

What if >! returned true/false depending on whether the value was put 
(because the channel was open)?

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to