lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Mar 23, 2011 at 9:50 PM, Tang Daogang <daogangtang@gmail.com> wrote:
> Anybody knows the differences between lua coroutine and golang goroutine,
> and further 'channel'?

(note: i hadn't read the code, so i'm just guessing from the docs and
a little observations)

my guess is that a goroutine is initially implemented as a coroutine,
with some clear points of control transfer (at the channel operations
and maybe IO) but with less 'no non-preemptive' guarantees.  That, and
the lack of complex environment structures (the global space seems to
be similar to C globals, not a thick web of mutable objects
references, like Lua's), allows the runtime to 'promote' a goroutine
acting as a coroutine into thread-like behavior.  the exact criteria
used is left implementation-defined.

there are also some notes about the current runtime not being too
smart nor optimal; but with the promise of future uncertainty :-)

-- 
Javier