Some bug fixes
This commit is contained in:
parent
ef151893ab
commit
aff459ef68
@ -1071,7 +1071,7 @@ end
|
|||||||
function multi:newLoop(func)
|
function multi:newLoop(func)
|
||||||
local c=self:newBase()
|
local c=self:newBase()
|
||||||
c.Type='loop'
|
c.Type='loop'
|
||||||
local start=self.clock()
|
local start=clock()
|
||||||
local funcs = {}
|
local funcs = {}
|
||||||
if func then
|
if func then
|
||||||
funcs={func}
|
funcs={func}
|
||||||
@ -1246,7 +1246,7 @@ function multi:newTStep(start,reset,count,set)
|
|||||||
c.skip=skip or 0
|
c.skip=skip or 0
|
||||||
c.count=count or 1*think
|
c.count=count or 1*think
|
||||||
c.funcE={}
|
c.funcE={}
|
||||||
c.timer=self.clock()
|
c.timer=clock()
|
||||||
c.set=set or 1
|
c.set=set or 1
|
||||||
c.funcS={}
|
c.funcS={}
|
||||||
function c:Update(start,reset,count,set)
|
function c:Update(start,reset,count,set)
|
||||||
@ -1255,12 +1255,12 @@ function multi:newTStep(start,reset,count,set)
|
|||||||
self.endAt=reset or self.endAt
|
self.endAt=reset or self.endAt
|
||||||
self.set=set or self.set
|
self.set=set or self.set
|
||||||
self.count=count or self.count or 1
|
self.count=count or self.count or 1
|
||||||
self.timer=self.clock()
|
self.timer=clock()
|
||||||
self:Resume()
|
self:Resume()
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
function c:Act()
|
function c:Act()
|
||||||
if self.clock()-self.timer>=self.set then
|
if clock()-self.timer>=self.set then
|
||||||
self:Reset()
|
self:Reset()
|
||||||
if self.pos==self.start then
|
if self.pos==self.start then
|
||||||
for fe=1,#self.funcS do
|
for fe=1,#self.funcS do
|
||||||
@ -1298,7 +1298,7 @@ function multi:newTStep(start,reset,count,set)
|
|||||||
end
|
end
|
||||||
function c:Reset(n)
|
function c:Reset(n)
|
||||||
if n then self.set=n end
|
if n then self.set=n end
|
||||||
self.timer=self.clock()
|
self.timer=clock()
|
||||||
self:Resume()
|
self:Resume()
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -1475,6 +1475,7 @@ function multi.holdFor(n,func)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
function thread:newFunction(func,holdme)
|
function thread:newFunction(func,holdme)
|
||||||
|
local done = false
|
||||||
return function(...)
|
return function(...)
|
||||||
local rets, err
|
local rets, err
|
||||||
local function wait(no)
|
local function wait(no)
|
||||||
@ -1502,9 +1503,9 @@ function thread:newFunction(func,holdme)
|
|||||||
local temp = {
|
local temp = {
|
||||||
isTFunc = true,
|
isTFunc = true,
|
||||||
wait = wait,
|
wait = wait,
|
||||||
connect = function(f)
|
connect = function(f)
|
||||||
t.OnDeath(function(self,status,...) f(...) end)
|
t.OnDeath(function(self,status,...) if done == false then f(...) done = true end end)
|
||||||
t.OnError(function(self,err) f(self, err) end)
|
t.OnError(function(self,err) if done == false then f(self,err) done = true end end)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
return temp,temp,temp,temp,temp,temp,temp
|
return temp,temp,temp,temp,temp,temp,temp
|
||||||
@ -1604,8 +1605,8 @@ function multi:newThread(name,func,...)
|
|||||||
c.timer=multi:newTimer()
|
c.timer=multi:newTimer()
|
||||||
c._isPaused = false
|
c._isPaused = false
|
||||||
c.returns = {}
|
c.returns = {}
|
||||||
c.OnError = multi:newConnection()
|
c.OnError = multi:newConnection(true,nil,true)
|
||||||
c.OnDeath = multi:newConnection()
|
c.OnDeath = multi:newConnection(true,nil,true)
|
||||||
function c:isPaused()
|
function c:isPaused()
|
||||||
return self._isPaused
|
return self._isPaused
|
||||||
end
|
end
|
||||||
@ -1676,6 +1677,7 @@ function multi.initThreads(justThreads)
|
|||||||
local ret,_
|
local ret,_
|
||||||
local function CheckRets(i)
|
local function CheckRets(i)
|
||||||
if ret~=nil then
|
if ret~=nil then
|
||||||
|
if not threads[i] then return end
|
||||||
threads[i].TempRets[1] = ret
|
threads[i].TempRets[1] = ret
|
||||||
threads[i].TempRets[2] = r1
|
threads[i].TempRets[2] = r1
|
||||||
threads[i].TempRets[3] = r2
|
threads[i].TempRets[3] = r2
|
||||||
@ -1740,7 +1742,7 @@ function multi.initThreads(justThreads)
|
|||||||
for i=#threads,1,-1 do
|
for i=#threads,1,-1 do
|
||||||
if not threads[i].__started then
|
if not threads[i].__started then
|
||||||
if coroutine.running() ~= threads[i].thread then
|
if coroutine.running() ~= threads[i].thread then
|
||||||
_,ret,r1,r2,r3,r4,r5,r6=coroutine.resume(threads[i].thread,unpack(threads[i].startArgs))
|
_,ret,r1,r2,r3,r4,r5,r6=coroutine.resume(threads[i].thread,t0,t1,t2,t3,t4,t5,t6)
|
||||||
CheckRets(i)
|
CheckRets(i)
|
||||||
end
|
end
|
||||||
threads[i].__started = true
|
threads[i].__started = true
|
||||||
|
|||||||
@ -68,7 +68,7 @@ function multi:newSystemThread(name, func, ...)
|
|||||||
c.name = name
|
c.name = name
|
||||||
c.Name = name
|
c.Name = name
|
||||||
c.Id = count
|
c.Id = count
|
||||||
c.loadString = {"base","package","os,math","table","string","coroutine"}
|
c.loadString = {"base","package","os","io","math","table","string","coroutine"}
|
||||||
livingThreads[count] = {true, name}
|
livingThreads[count] = {true, name}
|
||||||
c.Type = "sthread"
|
c.Type = "sthread"
|
||||||
c.creationTime = os.clock()
|
c.creationTime = os.clock()
|
||||||
|
|||||||
@ -105,7 +105,6 @@ function multi:newSystemThreadedJobQueue(n)
|
|||||||
thread.yield()
|
thread.yield()
|
||||||
local dat = c.queueReturn:pop()
|
local dat = c.queueReturn:pop()
|
||||||
if dat then
|
if dat then
|
||||||
print(dat)
|
|
||||||
c.OnJobCompleted:Fire(unpack(dat))
|
c.OnJobCompleted:Fire(unpack(dat))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -47,13 +47,17 @@ local THREAD = require("multi.integration.loveManager.threads")
|
|||||||
local GLOBAL = THREAD.getGlobal()
|
local GLOBAL = THREAD.getGlobal()
|
||||||
local THREAD_ID = 1
|
local THREAD_ID = 1
|
||||||
local OBJECT_ID = 0
|
local OBJECT_ID = 0
|
||||||
|
local stf = 0
|
||||||
function THREAD:newFunction(func,holup)
|
function THREAD:newFunction(func,holup)
|
||||||
|
stf = stf + 1
|
||||||
return function(...)
|
return function(...)
|
||||||
local t = multi:newSystemThread("SystemThreadedFunction",func,...)
|
local t = multi:newSystemThread("STF"..stf,func,...)
|
||||||
return thread:newFunction(function()
|
return thread:newFunction(function()
|
||||||
return thread.hold(function()
|
return thread.hold(function()
|
||||||
if t.stab["returns"] then
|
if t.stab["returns"] then
|
||||||
return unpack(t.stab.returns)
|
local dat = t.stab.returns
|
||||||
|
t.stab.returns = nil
|
||||||
|
return unpack(dat)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end,holup)()
|
end,holup)()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user