I've just discovered go's way of dealing with concurrency. I find it neat,
but also confusing... A mix between threads and greenlets. So I'm trying to
understand how this is working under the hood.
When I'm retrieving something from a channel (<- c) inside a goroutine,
what I understand is that I'm implicitly yielding to the go scheduler, thus
allowing other goroutines (within the same thread) to run. But I don't know
how my goroutine knows when the "c" channel is ready yet.
Does the go scheduler have an "IO task" that it runs after each goroutine
yields, and has a mapping of goroutines and the channels, sockets...
they're waiting for ?
Does the scheduler work some like this ?
1) scheduler picks a goroutine G1 from goroutines stack and run it. G1
yields back to the scheduler and waits for channel c
2) scheduler maps G1 to channel c in a "waiting for IO" map.
2) pick goroutine G2 and run it. G2 yields back to scheduler
3) scheduler checks if any IO is ready. Yes, c is ready.
4) scheduler wakes up G1 to continue.
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
For more options, visit https://groups.google.com/d/optout.