[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to timeout a running function??
- From: "Leo Razoumov" <slonik.az@...>
- Date: Mon, 30 Oct 2006 08:29:51 -0500
On 10/30/06, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
For Lua functions, you can set a count hook and call error for there.
For C functions, you need a real timer. Even then, you need to be careful
how you interrupt Lua. See how lua.c does it or my lalarm. --lhf
Luiz,
thanks a lot for your reply. lalarm seems to address my problem for C functions.
On the other hand I do not see how setting count hook would help to
time-out a Lua function. According to Lua manual count hook cannot
count time. It counts instructions, lines of code, function
invocations/returns. How would count hook help me if my foo()
functions is blocking inside?
function foo(key)
local res= get_resource() -- can possible block for long time
return res:lookup( key)
end
Can I use lalarm to break out from Lua function? Would setjmp/longjmp
used in alarm handler leave Lua in inconsistent state?
--Leo--