lua-users home
lua-l archive

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


> Not only "not polite".  Between two API calls (i.e. lua_getref(L2, x)
> lua_setglobals(L2)) the other thread may run and you have just put him
> some garbage on the stack...

This is harder still, as I have not started the other process when I call 
lua_getref. Afaiks, you cannot do anything reasonable in another thread's 
stack after it starts running (even with a function like receivevalue), 
unless if you implement some kind of randevous. You are not going to change 
another thread's global table on the fly... In my view, you create the new 
Lua stack, configure it (then you can use lua_getref, lua_setglobals, and 
others without problems), and then you start the new thread. After that, 
all communication must be through "official" channels (critical regions, 
semaphores, etc.). 


> Afaik, locks are reasonable fast as long as there's no contention.

In my Linux, just adding the macros with the locks slowdowns
"typical" Lua programs by a factor of 20% to 40% (depends how much
they call C). And this is only the main thread running, so there is
no contention.

-- Roberto