Lua operations, that works in mutitheaded environment

Posted by SBKarr on Stack Overflow See other posts from Stack Overflow or by SBKarr
Published on 2012-10-09T15:09:53Z Indexed on 2012/10/09 15:37 UTC
Read the original article Hit count: 177

Filed under:
|

My application uses Lua in multithreaded environment with global mutex. It implemented like this:

  1. Thread locks mutex,
  2. Call lua_newthread
  3. Perform some initialization on coroutine
  4. Run lua_resume on coroutine
  5. Unlocks mutex

lua_lock/unlock is not implemented, GC is stopped, when lua works with coroutine.

My question is, can I perform steps 2 and 3 without locking, if initialisation process does not requires any global Lua structs? Can i perform all this process without locking at all, if coroutine does not requires globals too?

In what case I generally can use Lua functions without locking?

© Stack Overflow or respective owner

Related posts about multithreading

Related posts about lua