lua-users home
lua-l archive

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

On 14.07.2014 9:46, Austin Einter wrote:
2. Do not define lua_lock/lua_unlock, have my own semaphore with count 1, do lock and unlock while accessing lua state.

Why semaphore? It's a job for a critical section / mutex.

Now, my doubt is, when garbage collection happens, it executes in which thread context. Since lua_lock and lua_unlock is not defined, can it cause any issue during garbage collection.

Your thread does some Lua call and only during its execution garbage collection may happen. So, no troubles with that.

Out of two approaches, if I prefer approach 1, will it more slower.

Definitely. Plus, if the threads could operate on the same coroutine, you'll still need to make enclosing calls to lock/unlock.

Best regards,
Sergey Rozhenko