Error handling not working if its on the first step
This commit is contained in:
parent
3fbead60d9
commit
cdb4bfda11
@ -1420,27 +1420,21 @@ function multi:attachScheduler()
|
|||||||
}
|
}
|
||||||
setmetatable(switch,{__index=function() return function() end end})
|
setmetatable(switch,{__index=function() return function() end end})
|
||||||
local cmds = {-- ipart: t_hold, t_sleep, t_holdF, t_skip, t_holdW, t_yield, t_none <-- Order
|
local cmds = {-- ipart: t_hold, t_sleep, t_holdF, t_skip, t_holdW, t_yield, t_none <-- Order
|
||||||
-- function(th,arg1,arg2,arg3)
|
|
||||||
-- threads[i].OnDeath:Fire(threads[i],"killed",ret,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16)
|
|
||||||
-- self.setType(threads[i],self.DestroyedObj)
|
|
||||||
-- table.remove(threads,i)
|
|
||||||
-- ret = nil
|
|
||||||
-- end,
|
|
||||||
function(th,arg1,arg2,arg3)
|
function(th,arg1,arg2,arg3)
|
||||||
print("hold",arg1,arg2,arg3)
|
--print("hold",arg1,arg2,arg3)
|
||||||
th.func = arg1
|
th.func = arg1
|
||||||
th.task = t_hold
|
th.task = t_hold
|
||||||
th.interval = arg3 or 0
|
th.interval = arg3 or 0
|
||||||
th.intervalR = clock()
|
th.intervalR = clock()
|
||||||
end,
|
end,
|
||||||
function(th,arg1,arg2,arg3)
|
function(th,arg1,arg2,arg3)
|
||||||
print("sleep",arg1,arg2,arg3)
|
--print("sleep",arg1,arg2,arg3)
|
||||||
th.sec = arg1
|
th.sec = arg1
|
||||||
th.time = clock()
|
th.time = clock()
|
||||||
th.task = t_sleep
|
th.task = t_sleep
|
||||||
end,
|
end,
|
||||||
function(th,arg1,arg2,arg3)
|
function(th,arg1,arg2,arg3)
|
||||||
print("holdf",arg1,arg2,arg3)
|
--print("holdf",arg1,arg2,arg3)
|
||||||
th.sec = arg1
|
th.sec = arg1
|
||||||
th.func = arg2
|
th.func = arg2
|
||||||
th.task = t_holdF
|
th.task = t_holdF
|
||||||
@ -1449,13 +1443,13 @@ function multi:attachScheduler()
|
|||||||
th.intervalR = clock()
|
th.intervalR = clock()
|
||||||
end,
|
end,
|
||||||
function(th,arg1,arg2,arg3)
|
function(th,arg1,arg2,arg3)
|
||||||
print("skip",arg1,arg2,arg3)
|
--print("skip",arg1,arg2,arg3)
|
||||||
th.count = arg1
|
th.count = arg1
|
||||||
th.pos = 0
|
th.pos = 0
|
||||||
th.task = t_skip
|
th.task = t_skip
|
||||||
end,
|
end,
|
||||||
function(th,arg1,arg2,arg3)
|
function(th,arg1,arg2,arg3)
|
||||||
print("holdw",arg1,arg2,arg3)
|
--print("holdw",arg1,arg2,arg3)
|
||||||
th.count = arg1
|
th.count = arg1
|
||||||
th.pos = 0
|
th.pos = 0
|
||||||
th.func = arg2
|
th.func = arg2
|
||||||
@ -1476,13 +1470,23 @@ function multi:attachScheduler()
|
|||||||
["normal"] = function(thd,ref) end, -- Not sure if I will handle this
|
["normal"] = function(thd,ref) end, -- Not sure if I will handle this
|
||||||
["running"] = function(thd,ref) end,
|
["running"] = function(thd,ref) end,
|
||||||
["dead"] = function(thd,ref,task,i)
|
["dead"] = function(thd,ref,task,i)
|
||||||
print("Ended:",ref.Name,_,ret,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16)
|
if _ then
|
||||||
local t = ref.TempRets or {}
|
ref.OnDeath:Fire(ret,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16)
|
||||||
print("ended",t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15],t[16])
|
else
|
||||||
ref.OnDeath:Fire(ref,"ended",t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15],t[16])
|
ref.OnError:Fire(ref,ret,r1)
|
||||||
|
end
|
||||||
|
if i then
|
||||||
table.remove(threads,i)
|
table.remove(threads,i)
|
||||||
|
else
|
||||||
|
for i,v in pairs(threads) do
|
||||||
|
if v.thread==thd then
|
||||||
|
table.remove(threads,i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
_=nil r1=nil r2=nil r3=nil r4=nil r5=nil
|
_=nil r1=nil r2=nil r3=nil r4=nil r5=nil
|
||||||
--self.setType(ref,self.DestroyedObj)
|
self.setType(ref,self.DestroyedObj)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
self.scheduler:OnLoop(function(self)
|
self.scheduler:OnLoop(function(self)
|
||||||
@ -1491,18 +1495,12 @@ function multi:attachScheduler()
|
|||||||
task = ref.task
|
task = ref.task
|
||||||
thd = ref.thread
|
thd = ref.thread
|
||||||
ready = ref.__ready
|
ready = ref.__ready
|
||||||
|
-- First time setup for threads
|
||||||
for start = startme_len,1,-1 do
|
for start = startme_len,1,-1 do
|
||||||
_,ret,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16 = resume(startme[start].thread,unpack(startme[start].startArgs))
|
_,ret,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16 = resume(startme[start].thread,unpack(startme[start].startArgs))
|
||||||
-- An error can happen here
|
co_status[status(startme[startme_len].thread)](startme[startme_len].thread,startme[startme_len],t_none) --cmds[r1](startme[start],r2,r3,r4,r5)
|
||||||
cmds[r1](startme[start],r2,r3,r4,r5)
|
startme[startme_len] = nil
|
||||||
startme_len = startme_len - 1
|
startme_len = startme_len - 1
|
||||||
if not _ then
|
|
||||||
co_status["dead"](startme[start].thread,startme[start],task,i)
|
|
||||||
table.remove(startme,startme_len)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
table.remove(startme,startme_len)
|
|
||||||
end
|
end
|
||||||
co_status[status(thd)](thd,ref,task,i)
|
co_status[status(thd)](thd,ref,task,i)
|
||||||
end
|
end
|
||||||
|
|||||||
23
test4.lua
23
test4.lua
@ -17,17 +17,26 @@ multi:newAlarm(3):OnRing(function()
|
|||||||
end)
|
end)
|
||||||
multi:benchMark(sleep_for,multi.Priority_Core,"Core:"):OnBench(bench)
|
multi:benchMark(sleep_for,multi.Priority_Core,"Core:"):OnBench(bench)
|
||||||
multi:newThread("Thread 1",function()
|
multi:newThread("Thread 1",function()
|
||||||
error("Testing 1")
|
while true do
|
||||||
end)
|
thread.sleep(1)
|
||||||
|
error("hi")
|
||||||
|
print("Test 1")
|
||||||
|
thread.hold(conn)
|
||||||
|
print("Conn sleep test")
|
||||||
|
end
|
||||||
|
end).OnError(print)
|
||||||
|
|
||||||
multi:newThread("Thread 2",function()
|
multi:newThread("Thread 2",function()
|
||||||
thread.sleep(2)
|
print("Thread 2")
|
||||||
error("Testing 2")
|
return "it worked"
|
||||||
end)
|
end):OnDeath(print):OnError(error)
|
||||||
multi:newThread("Thread 3",function()
|
multi:newThread("Thread 3",function()
|
||||||
thread.sleep(1)
|
thread.hold(function()
|
||||||
return "Complete 3"
|
return ready
|
||||||
end)
|
end)
|
||||||
|
print("Function test")
|
||||||
|
return "Yay we did it"
|
||||||
|
end).OnDeath(print)
|
||||||
|
|
||||||
-- multi.OnExit(function()
|
-- multi.OnExit(function()
|
||||||
-- print("Total: ".. a)
|
-- print("Total: ".. a)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user