[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: handling asynchronous events in lua
- From: Cosmin Apreutesei <cosmin.apreutesei@...>
- Date: Wed, 5 Aug 2009 18:36:51 +0300
Hi,
I have a library in which I can register asynchronous callbacks.
Problem is, I can't call Lua inside the callback because the state is
not consistent (obviously). Is there any way I can handle the lua
state in consistent steps so I can enter back to lua and call a lua
function? Python has this signal lib[1] that seems to work this way,
executing the callbacks just between "atomic" python instructions.
Sorry if this is old potatoes, I'm reading the list as fast as I can
:)
Another solution would be to keep the callbacks into FIFO list and
have lua pull them from there -- and let the user solve the threading
problem separately, with a threading library or with coroutines,
depending on the design of the app. I was thinking of adding this
functionality to alien as a general solution for async. callbacks. Is
that a generally useful pattern to belong to a binding library or just
my special needs?
[1] http://docs.python.org/library/signal.html