lua-users home
lua-l archive

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


On 13.06.20 20:16, Joseph C. Sible wrote:
> On Sat, Jun 13, 2020 at 2:05 PM James Pascoe <james@james-pascoe.com> wrote:
>> 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
>> 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
> [1] or luaproc [2].

you also might be interested to have a look at

- lua-llthreads2 [1] - Low-Level threads for Lua
- mtmsg [2] - Low-level message buffers for inter-thread communication
- mtstates [3] - Pass Lua states to other threads
- mtint [4] - Make threads and coroutines interruptible

These are orthogonal and low level cross platform packages that can be combined
and play well together. IMHO they build a simple and minimal base for building
higher level multi threading constructs in pure Lua.

Best regards,
Oliver

[1]: https://luarocks.org/modules/moteus/lua-llthreads2
[2]: https://luarocks.org/modules/osch/mtmsg
[3]: https://luarocks.org/modules/osch/mtstates
[4]: https://luarocks.org/modules/osch/mtint