[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [PATCH] lua_forcereturn()
- From: "Alexander Gladysh" <agladysh@...>
- Date: Sat, 19 Jul 2008 13:08:15 +0400
On Sat, Jul 19, 2008 at 6:52 AM, Luiz Henrique de Figueiredo
>> Alexander Gladysh wrote:
>> I apologise for being not quite in context, so my question may be a
>> silly one. I see the expected use case of this feature roughly as
>> follows (pseudocode):
>> 1. [worker thread] spawn_watchdog_thread(L); lua_pcall(L, <stuff>);
>> 2. [watchdog thread] if (spent_too_much_time()) lua_forcereturn(L, 1);
>> If forcereturn is triggered, lua_pcall() returns (prematurely) in
>> worker thread, and worker thread execution continues as usual.
> I fail to see the need for lua_forcereturn: you can just use lua_error.
> Remember the Lua can raise errors on any Lua value, not just strings.
> A suitable error value can be used to transmit any info on the cause
> of error.
Is it good to call lua_error() from another (watchdog) thread? I've
got an impression that this would not work as intended.