Ah, I see, I'd missed the
value-passing issue. This obviously requires that the calling coroutine
waits for the called one to yield.|
David Kastrup escribió:
Hugo Etchegoyen <email@example.com> writes:IMHO a non-preemptible thread and a coroutine (at least the kind of coroutines you are talking about, which have a private stack) are the same thing.This would hold at best on single processors: on multiple processors, several threads can run simultaneously unpreempted. However, coroutines, being strictly synchronized, can have something that threads in general don't: they can pass values. Yielding in a Lua thread will both pass and accept a value to and from the controlling Lua thread. This is obviously only possible when the caller is suspended until the called thread yields. Apart from the switching of the stacks, this is completely identical to function calls.
Hugo Eduardo Etchegoyen
Hasar | Grupo