[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Turing-incomplete Lua?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 8 Dec 2004 09:00:09 -0200
> > No, it's not. lua.c calls lua_sethook from a signal handler.
> You could always do that, then, if your threads support signals or something
> similar: have a signal handler call lua_sethook, and then when you want to
> terminate the thread, send the signal to the thread. That way all the
> lua_State manipulation takes place in the same thread.
Yes, but then you need to store the lua_State* somewhere static because signal
handlers do not get this data. Hence the global variable in lua.c :-(
In Posix, you may want to use sigaction, which I think allows userdata to be
set for signal handlers.
On the other hand, I don't know how signals and multiple threads mesh together,
so I'd go for the simpler and more portable solution of setting the hook when
the user presses the "stop" button. You still need to store the lua_State*
somewhere, though, but perhaps it can be obtained from the thread pointer or
something. It all depends on how the application is written.