running the debug hook that is used to check for timeouts more often, may help with #78

This commit is contained in:
Florian Nücke 2014-01-10 17:31:10 +01:00
parent 27102a8be1
commit 128b3ae03b

View File

@ -1,3 +1,4 @@
local hookInterval = 100
local deadline = 0 local deadline = 0
local function checkDeadline() local function checkDeadline()
if computer.realTime() > deadline then if computer.realTime() > deadline then
@ -94,7 +95,7 @@ sandbox = {
checkArg(1, co, "thread") checkArg(1, co, "thread")
local args = table.pack(...) local args = table.pack(...)
while true do -- for consecutive sysyields while true do -- for consecutive sysyields
debug.sethook(co, checkDeadline, "", 10000) debug.sethook(co, checkDeadline, "", hookInterval)
local result = table.pack( local result = table.pack(
coroutine.resume(co, table.unpack(args, 1, args.n))) coroutine.resume(co, table.unpack(args, 1, args.n)))
debug.sethook(co) -- avoid gc issues debug.sethook(co) -- avoid gc issues
@ -396,7 +397,7 @@ local function main()
local co, args = bootstrap(), {n=0} local co, args = bootstrap(), {n=0}
while true do while true do
deadline = computer.realTime() + timeout -- timeout global is set by host deadline = computer.realTime() + timeout -- timeout global is set by host
debug.sethook(co, checkDeadline, "", 10000) debug.sethook(co, checkDeadline, "", hookInterval)
local result = table.pack(coroutine.resume(co, table.unpack(args, 1, args.n))) local result = table.pack(coroutine.resume(co, table.unpack(args, 1, args.n)))
if not result[1] then if not result[1] then
error(tostring(result[2]), 0) error(tostring(result[2]), 0)