lua-users home
lua-l archive

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


Have you taken a look at Tims "Luvit"? Thats basically a Lua
environment tailored to Asynchronous Callbacks / Events.
https://github.com/luvit/luvit

The idea is anyway execute to end, and then have the event machine
restart in a closure for each event. In Lua, however, execute 'til end
can be made more elegant with coroutines than to its sister project
Node.JS.

On Tue, Mar 27, 2012 at 11:49 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> Hi all,
>
> I've been recently trying to get winapi to do Real Things, and I'm
> hitting those little random crashes which suggest that multithreading
> in Lua is not as simple as I naively thought.
>
> Current design is e.g. to have a thread waiting for i/o, and then
> dispatch the callback when a read() returns, ensuring that only one
> callback can be active at a time using mutexes.  (Ditto for timers and
> so forth).  One obvious problem is that we could be running Lua code
> in the main thread anyway, which suggests that the mutex should only
> unlocked when we are sleeping or otherwise waiting on some event.  But
> the callbacks still happen on _another thread_, so I wonder if this
> isn't the real problem.
>
> Can such a design be made truly solid? I remember reading that Mike
> Pall reckoned that coroutines created from the C side should work
> fine.
>
> (My apologies for the vagueness, but multithreading is not my native language)
>
> steve d.
>