lua-users home
lua-l archive

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

On Jul 13, 2014, at 7:36 PM, Austin Einter <> wrote:

> Hi All
> Suppose I have Lua State L as a global variable in my C program.
> If it is accessed and used by two different threads, is it required for me to protect the Lua State by using a semaphore/mutex.
> OR
> Lua State internally has a semaphore/mutex to protect itself.
> Please let me know.
> Austin

I believe you need to #define the `lua_lock` and `lua_unlock` macros to perform whichever locking mechanism you desire for Lua thread safety, these macros are not defined to do anything by default.

Searching the archives for `lua_lock` brings up a number of previous discussions, some of which are on the use of `lua_lock` and `lua_unlock` in threaded environments.