lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



> local checker = function()
>  checkcount = checkcount+1
>  -- will kill the coro after 1 second
>  if t+1<socket.gettime() then
>    print("timeout")
>    error("timeout")
>  end
> end
>

Couldn't this be: 

local checker = function()
  checkcount = checkcount+1
  -- will kill the coro after 1 second
  if t+1<socket.gettime() then
    print("timeout")
    coroutine.yield("timeout")
  end
end

And then the scheduler decides what to do with a coroutine yielding "timeout". This would only work if "pcall" was changed into a coroutine like this:

https://github.com/lubyk/lubyk/blob/master/modules/lk/lib/lk/Scheduler.lua#L284

Gaspard