lua-users home
lua-l archive

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


On Fri, Apr 22, 2016 at 12:31 PM, Laurent FAILLIE <l_faillie@yahoo.com> wrote:

I read this page but unfortunately, it only explains how to lock and mutex b/w thread, not how to share a function reference w/o locking.

The page explains how you could use one Lua environment from multiple threads. It does need a mutex to protect its internal structures, but that does not make you "rely on main thread activities". With this approach, both of your threads can call lua_pcall with the same Lua environment concurrently, meaning that callbacks can run concurrently with the main thread.

Cheers,
V.