[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Yet another Lua thread question
- From: "D Burgess" <dburgess@...>
- Date: Tue, 23 May 2006 13:53:05 +1000
I am stitching Lua into an existing threaded application and I
was hoping that someone can confirm some things for me.
The app has a fixed threadpool, mutex protection guarantees that
only one of these threads can access the Lua universe (L) at
any one time.
The worker threads may load lua code and this code is
lua_resume()d, so that each OS thread has its own Lua
thread(L1, L2 ...). Again let me state that each of these
threads are mutex protected so that none of these states
are ever accessed by more than one OS thread at a time.
When the pool mutex is released another thread may begin
execution and the current thread immediately requests the
same mutex, i.e. a pool thread may be preempted
There are no lua_yields. The lua_resume is simply used
to maintain separate Lua stacks for each OS thread when
it executes Lua code.
I have read (about 5 times) the blue PIL section at chapter 30
and have checked the Lua source (as far as I understand it)
and I think this is safe. Nor has it crashed on me (yet).
Can someone with great wisdom either confirm this is OK
or alternatively tell me what is wrong with this scheme?
David B