also a different question: I'm a little bit confused about what coroutine constructs have to be explicitly cancelled to free memory and what will be garbage collected automatically. Stuff like channels and jobs (outside a running coroutine) I assume will just get garbage collected without needing to call
close
or
cancel
on them?
g
gildor
04/17/2018, 2:55 PM
Yes, but only when they finished work, the same as with any other callback
d
Daniel Tam
04/17/2018, 3:22 PM
Yep, by finished work you mean when no coroutine is running it right?
g
gildor
04/17/2018, 3:31 PM
when particular coroutine finished work (code inside coroutine invoked) such coroutine can be garbage collected
It works the same way as any other object GC when nobody keeps reference on it