[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua_lock and lua_unlock usage in LuaThread1.0-work?
- From: Diego Fernandes Nehab <diego@...>
- Date: Thu, 24 Jan 2002 13:11:14 -0200 (BRST)
Hi,
> When should I use lua_lock() and lua_unlock() while I write C
> extention function?
> While I looked over serveral source files, I found some C functions
> use lua_lock()/lua_unlock() pair, but some functions did not use them.
Lua_lock and lua_unlock are internal to the Lua core. The idea is that when
there are multiple threads accessing the same lua_State concurrently, Lua
uses these macros to sinchronize them. Furthermore, they are not
implemented by the Lua team, but supplied by an external library, such as
LuaThreads.
If you are creating an extention library in C, and wory about concurrent
access, you can use your own sinchronization functions (or borrow those
provided by LuaThreads). Since access to the lua_State is already
sinchronized by Lua core (using these macros), you need only worry with
concurrent access to your C structures.
Regards,
Diego.