lua-users home
lua-l archive

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



Lanes offers a multithreading framework for Lua.

http://luaforge.net/frs/?group_id=265


Fabien kirjoitti 10.10.2008 kello 14:55:

== Preemptive Multitasking ==  [...]
To prevent reimplementation of the wheel, has anybody written a module to make this programming model accessable from within Lua? Sort of "loadandrunstring_async"?

I stitched together rings (for multiple states) and pluto (for data serialization) some time ago. Rings is not intended for preemptive multitasking, but you can probably adapt to luathreads or something else with few adaptations:

http://lua-users.org/lists/lua-l/2007-12/msg00440.html

wouldn't it be possible to emulate forking on the Lua level by preemptive multitasking as described above? What would be needed is cloning of a lua_State, so that both the original and the new thread would have different but semantically equivalent states. Is there prior art on this idea?

Yes, Mike Pall proposed some time ago a patch that lets serialize a Lua thread. Together with coroutines, it gives you full continuations, which among others allow to emulate process forking. You can also take the idea and use Pluto for serialization, thus getting a fine-grained control of what's shared or not between forked "processes".

-- Fabien.