lua-users home
lua-l archive

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



On Mar 31, 2008, at 3:56 AM, Eugen-Andrei Gavriloaie wrote:

To further summarize the problem:


1. Have a c++ working thread that gets it's work chunk from a queue

2. Wrap all the internals in a c++ function callable from Lua

a. enqueue the work chunk

b. yield Lua

c. wait for the results from thread (we will get signaled)

d. resume Lua by invoking lua_resume

3. The writer of the Lua script must not know anything about the internals of the call (we must not force him to make a yield/resume from Lua)


Are you wanting to use multiple OS threads to achieve this? Lua doesn't support multi-threading by default, and enabling it through the lua_lock macros may impact performance considerably.  BUT, there's nothing stopping you having Lua in a single OS thread, spawning multiple OS threads and waiting for them to return.  A good example is http://helper-threads.luaforge.net/