[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Preemptive User Threads
- From: M Joonas Pihlaja <jpihlaja@...>
- Date: Thu, 26 Mar 2009 01:27:07 +0200 (EET)
Hi,
On Wed, 25 Mar 2009, John Dunn wrote:
> After looking more into my desire for asynchronous network
> communications, it appears as though a better solution might be to
> figure out a way to allow the users to spawn threads and use lua sockets
> directly.
IMHO this path is fraught with dangers. Not only are you bringing all
the normal badness of normal threading into the mix, the fact that all
external C code is run without the Lua VM lock held makes calling out
to external C modules a bit risky. Most haven't been written to be
threadsafe in the context of a threaded Lua VM. Something like Lua
Lanes with its default of shared-nothing is IMHO much safer.
If you nevertheless want to go down the shared global state path I
suggest trying out LuaThread from
http://www.tecgraf.puc-rio.br/~diego/professional/luathread/
I've rolled the latest version of that into a single patch for Lua
5.1.4 available at
http://www.discontinuity.info/~rowan/LuaThread-1.1-for-5.1.4.patch
Cheers,
Joonas