[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Turing-incomplete Lua?
- From: "Ashwin Hirschi" <deery@...>
- Date: Tue, 07 Dec 2004 19:01:17 +0100
> What is the proper way to terminate a running lua_State from another thread?
In ANSI C, you can do as in lua.c for handling signals: set a hook for
the running state and then raise an error. See laction and lstop in lua.c.
Of course, you don't need to do this only in response to signals being raised.
Thanks. Is it safe to call lua_sethook from another thread?
Why not set the hook before you start the script (from the same thread that the script runs in, I mean)?
All your hook handler then needs to do is check the "interrupted" flag, that you can set from the GUI thread. If the flag is set, you can deal with the interrupt as Luiz explained.
Also, note that if you intend to use the same (active) Lua state from different threads you'll need to take special precautions.
no signature is a signature.