[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Is it possible to run Lua threads in OS threads safely?
- From: "Joseph C. Sible" <josephcsible@...>
- Date: Sat, 13 Jun 2020 14:16:38 -0400
On Sat, Jun 13, 2020 at 2:05 PM James Pascoe <firstname.lastname@example.org> wrote:
> Also, the reference manual states that Lua threads created by lua_newthread() share the same global environment, which (as I understand it) means that they point to the same global environment in the parent lua_State. However, what I am trying to understand is whether it is possible to run individual Lua threads in separate OS threads safely?
No, that's not possible to safely do with stock Lua. Different OS
threads running Lua at the same time can only safely use completely
separate states, not threads that share a global state.
> And also, is it possible for Lua threads running in separate OS threads to communicate?
On their own, separate Lua states can't communicate at all. You'd have
to use some kind of helper to communicate between them, like Lua Lanes
 or luaproc .
Joseph C. Sible