Seems OK. Note that code inside go blocks is transformed into state machine
'object' immediatelly, not waiting for hitting <!, as go is a macro.


On Thu, Jan 30, 2014 at 8:36 PM, t x <txrev...@gmail.com> wrote:

> Following up on this. Is the following correct:
>
> * async/thread creates Java threads -- these _are_ root gc objects
>
> * async/go creates go "blocks", which in reality, is just a state
> machine. go-blocks are NOT root gc objects
>
> * go-blocks do _NOT_ have stackframes -- they're just a simple, flat
> state machine created via inversion of control at <!, >!, and alt!
> locations
>
> * when a go-block blocks, it gets appended to either the put or the
> take queue of the channel it's blocking on
>
> Thus, in the following code:
>
> (let [c (async/chan)
>       d (async/go (<! c))] )
>
> what happens is the following thing:
>
> * we create a channel "c"
> * we create a go-block, who returns to a channel "d"
> * the go block hits (<! c), then gets ioc-ed into a state machine
> * this state machine is put on the "take-list" of "c"
>
> Then, the GC collects "c" and "d" -- and the go-block vanishes, since
> it's just a state machine attached to "c"
>
>
> Can you please tell me if
>
> (1) all above statements are correct or
> (2) correct the wrong ones in place?
>
> Thanks!
>
>
> On Thu, Jan 30, 2014 at 11:06 AM, t x <txrev...@gmail.com> wrote:
> >> The key thing to remember in all questions of core.async GC is that
> there is
> >> no global "blocked gos" queue. Instead, the blocked "gos" are attached
> >> directly to the channel. When the channel is GC'd all attached gos are
> GC'd
> >> as well.
> >
> > This is the source of all my mis-understanding. Thanks for explaining!
> >
> >
> >>
> >> So in this case, it's actually even simpler.....the go never blocks.
> What
> >> this code is doing is creating a channel to return from the go. This
> channel
> >> has a buffer size of 1. It then puts a channel into the channel. The go
> then
> >> exits and is GC'd. Once the return channel is discarded by the caller of
> >> this code, both channels are also GC'd
> >>
> >> Timothy
> >>
> >>
> >> On Thu, Jan 30, 2014 at 11:24 AM, t x <txrev...@gmail.com> wrote:
> >>>
> >>> Hi,
> >>>
> >>>   Consider this block of code:
> >>>
> >>>   (async/go (async/chan))
> >>>
> >>>   This creates a go-thread and a go-chan.
> >>>
> >>>   The go-thread is linked from the list of blocked go-threads.
> >>>
> >>>   The go-chan is linked from the go-thread.
> >>>
> >>>   Thus, did we just create a go-thread and a go-chan which is NOT
> gc-ed at
> >>> all?
> >>>
> >>> Thanks!
> >>>
> >>> --
> >>> 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.
> >>
> >>
> >>
> >>
> >> --
> >> "One of the main causes of the fall of the Roman Empire was that-lacking
> >> zero-they had no way to indicate successful termination of their C
> >> programs."
> >> (Robert Firth)
> >>
> >> --
> >> 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.
>
> --
> 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.
>

-- 
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