Re: Re-evaluating recuring go blocks

2014-05-19 Thread Dylan Butman
Yea that's very helpful. When you say "the channel can never give them a value," is that because the channel is no longer in scope? So (def c (chan)) (dotimes [x 10] (go ( Channels are not tied to anything, so once your code stops referencing them, > they are garbage collected. > > Go bloc

Re: Re-evaluating recuring go blocks

2014-05-19 Thread Timothy Baldridge
Channels are not tied to anything, so once your code stops referencing them, they are garbage collected. Go blocks are actually nothing more than pretty callbacks that are attached to channels. So if a go is waiting for a put or a take from a channel, it will be GC'd with the channel. I could go i

Re: Re-evaluating recuring go blocks

2014-05-19 Thread Dylan Butman
Great! I've used alts! before with control channels which is definitely useful as well. Timothy, can you elaborate a little? I'm still a little unclear when channels are garbage collected. It it an issue to leave channels open after you've stopped using them? I always feel a little strange co

Re: Re-evaluating recuring go blocks

2014-05-18 Thread Timothy Baldridge
Also, go blocks that are waiting on channels that are garbage collected will be garbage collected themselves. This means I often just re-compile an entire namespace, this redefines the channel, re-binds the def the channel is attached to, and recreates all gos. The channel is now free go be GC'd al

Re: Re-evaluating recuring go blocks

2014-05-18 Thread Herwig Hochleitner
I always pass a control-channel into go loops, by which I can close it: (defn looper [event-ch ctl-ch] (go-loop [] (alt! event-ch ([event _] (handle-event event) (recur)) ctl-ch ([msg _] (assert (nil? msg)) This also makes it easy to funnel more control events then just end-

Re-evaluating recuring go blocks

2014-05-18 Thread Dylan Butman
When working with channels and go blocks with nRepl, I often want to do something like this. (def events (event-generator)) (go-loop [] (when-let [event (http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure"