lua-users home
lua-l archive

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


2014-08-26 10:15 GMT+01:00 Duncan Cross <duncan.cross@gmail.com>:
> It's because not all threads are coroutines. Every Lua state automatically
> has a "main" thread, and this thread is not a coroutine. It cannot be
> suspended.

Also Lua threads don't necessarily have the "routine" part of
coroutines. coroutine.create takes a function to be run, but from C
you can create a thread and use it without ever calling a function in
it. It's sometimes useful for example to store temporary data when
binding C APIs involving callbacks (you create a clean thread, pass
it's lua_State* as the API void*, have the callback push values, and
xmove them afterwards).