lua-users home
lua-l archive

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

Michael Gogins wrote:
> My question is this: Are there any plans to implement native threads
> in LuaJIT?

Well, in theory you can do this yourself with the LuaJIT FFI: it
has full access to the thread APIs of the OS. Alas, callbacks are
not implemented right now, which foils this attempt. This will be
fixed eventually.

Once that is done, you can just create a different Lua state from
the FFI and run it in a different thread. I guess one would be
able to get a first cut running in a couple minutes. But there are
many challenges, like passing objects between separate Lua states
and so on. I'm not sure this is something every developer needs to
replicate or should try to get right on his/her own.

So, yes, in the long term I want to provide a convenient API,
which allows you to create new Lua states in different threads and
communicate with them (e.g. a ffi.thread module). But I won't get
around to do this anytime soon with my current workload.