Fixed issue with double thread activations (Looking for another solution)
This commit is contained in:
parent
a7a902acd6
commit
6ed5555706
32
init.lua
32
init.lua
@ -976,10 +976,10 @@ end
|
|||||||
|
|
||||||
local sandcount = 1
|
local sandcount = 1
|
||||||
|
|
||||||
function multi:newProcessor(name,nothread)
|
function multi:newProcessor(name, nothread)
|
||||||
local c = {}
|
local c = {}
|
||||||
setmetatable(c,{__index = multi})
|
setmetatable(c,{__index = multi})
|
||||||
local name = name or "Processor_"..sandcount
|
local name = name or "Processor_" .. sandcount
|
||||||
sandcount = sandcount + 1
|
sandcount = sandcount + 1
|
||||||
c.Mainloop = {}
|
c.Mainloop = {}
|
||||||
c.Type = "process"
|
c.Type = "process"
|
||||||
@ -989,12 +989,12 @@ function multi:newProcessor(name,nothread)
|
|||||||
c.startme = {}
|
c.startme = {}
|
||||||
c.parent = self
|
c.parent = self
|
||||||
|
|
||||||
local handler = c:createHandler(c.threads,c.startme)
|
local handler = c:createHandler(c.threads, c.startme)
|
||||||
|
|
||||||
if not nothread then -- Don't create a loop if we are triggering this manually
|
if not nothread then -- Don't create a loop if we are triggering this manually
|
||||||
c.process = self:newLoop(function()
|
c.process = self:newLoop(function()
|
||||||
if Active then
|
if Active then
|
||||||
c:uManager()
|
c:uManager(true)
|
||||||
handler()
|
handler()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@ -1005,8 +1005,8 @@ function multi:newProcessor(name,nothread)
|
|||||||
else
|
else
|
||||||
c.OnError = multi:newConnection()
|
c.OnError = multi:newConnection()
|
||||||
end
|
end
|
||||||
|
|
||||||
c.OnError(multi.print)
|
c.OnError(multi.print)
|
||||||
|
|
||||||
|
|
||||||
function c:getThreads()
|
function c:getThreads()
|
||||||
return c.threads
|
return c.threads
|
||||||
@ -1027,15 +1027,15 @@ function multi:newProcessor(name,nothread)
|
|||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
function c:newFunction(func,holdme)
|
function c:newFunction(func, holdme)
|
||||||
return thread:newFunctionBase(function(...)
|
return thread:newFunctionBase(function(...)
|
||||||
return c:newThread("TempThread",func,...)
|
return c:newThread("TempThread",func,...)
|
||||||
end,holdme)()
|
end, holdme)()
|
||||||
end
|
end
|
||||||
|
|
||||||
function c.run()
|
function c.run()
|
||||||
if not Active then return end
|
if not Active then return end
|
||||||
c:uManager()
|
c:uManager(true)
|
||||||
handler()
|
handler()
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
@ -1274,7 +1274,7 @@ end
|
|||||||
|
|
||||||
local handler
|
local handler
|
||||||
|
|
||||||
function thread:newFunctionBase(generator,holdme)
|
function thread:newFunctionBase(generator, holdme)
|
||||||
return function()
|
return function()
|
||||||
local tfunc = {}
|
local tfunc = {}
|
||||||
tfunc.Active = true
|
tfunc.Active = true
|
||||||
@ -1351,7 +1351,7 @@ function thread:newFunctionBase(generator,holdme)
|
|||||||
t.statusconnector = temp.OnStatus
|
t.statusconnector = temp.OnStatus
|
||||||
return temp
|
return temp
|
||||||
end
|
end
|
||||||
setmetatable(tfunc,tfunc)
|
setmetatable(tfunc, tfunc)
|
||||||
return tfunc
|
return tfunc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1863,17 +1863,17 @@ function multi.init(settings, realsettings)
|
|||||||
return _G["$multi"].multi,_G["$multi"].thread
|
return _G["$multi"].multi,_G["$multi"].thread
|
||||||
end
|
end
|
||||||
|
|
||||||
function multi:uManager()
|
function multi:uManager(proc)
|
||||||
if self.Active then
|
if self.Active then
|
||||||
__CurrentProcess = self
|
__CurrentProcess = self
|
||||||
multi.OnPreLoad:Fire()
|
multi.OnPreLoad:Fire()
|
||||||
self.uManager=self.uManagerRef
|
self.uManager=self.uManagerRef
|
||||||
multi.OnLoad:Fire()
|
multi.OnLoad:Fire()
|
||||||
handler()
|
if not proc then handler() end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function multi:uManagerRefP1()
|
function multi:uManagerRefP1(proc)
|
||||||
if self.Active then
|
if self.Active then
|
||||||
__CurrentProcess = self
|
__CurrentProcess = self
|
||||||
local Loop=self.Mainloop
|
local Loop=self.Mainloop
|
||||||
@ -1886,11 +1886,11 @@ function multi:uManagerRefP1()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
handler()
|
if not proc then handler() end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function multi:uManagerRef()
|
function multi:uManagerRef(proc)
|
||||||
if self.Active then
|
if self.Active then
|
||||||
__CurrentProcess = self
|
__CurrentProcess = self
|
||||||
local Loop=self.Mainloop
|
local Loop=self.Mainloop
|
||||||
@ -1899,7 +1899,7 @@ function multi:uManagerRef()
|
|||||||
__CurrentTask:Act()
|
__CurrentTask:Act()
|
||||||
__CurrentProcess = self
|
__CurrentProcess = self
|
||||||
end
|
end
|
||||||
handler()
|
if not proc then handler() end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -55,10 +55,10 @@ local count = 1
|
|||||||
local started = false
|
local started = false
|
||||||
local livingThreads = {}
|
local livingThreads = {}
|
||||||
|
|
||||||
function THREAD:newFunction(func,holdme)
|
function THREAD:newFunction(func, holdme)
|
||||||
return thread:newFunctionBase(function(...)
|
return thread:newFunctionBase(function(...)
|
||||||
return multi:newSystemThread("TempSystemThread",func,...)
|
return multi:newSystemThread("TempSystemThread",func,...)
|
||||||
end,holdme)()
|
end, holdme)()
|
||||||
end
|
end
|
||||||
|
|
||||||
function multi:newSystemThread(name, func, ...)
|
function multi:newSystemThread(name, func, ...)
|
||||||
|
|||||||
@ -72,7 +72,7 @@ function multi:newSystemThread(name,func,...)
|
|||||||
return c.name
|
return c.name
|
||||||
end
|
end
|
||||||
thread:newThread(function()
|
thread:newThread(function()
|
||||||
if name:find("TempSystemThread") then
|
if name == "TempSystemThread" then
|
||||||
local status_channel = love.thread.getChannel("__"..c.ID.."__MULTI__STATUS_CHANNEL__")
|
local status_channel = love.thread.getChannel("__"..c.ID.."__MULTI__STATUS_CHANNEL__")
|
||||||
thread.hold(function()
|
thread.hold(function()
|
||||||
-- While the thread is running we might as well do something in the loop
|
-- While the thread is running we might as well do something in the loop
|
||||||
@ -101,10 +101,10 @@ function multi:newSystemThread(name,func,...)
|
|||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
|
|
||||||
function THREAD:newFunction(func)
|
function THREAD:newFunction(func, holdme)
|
||||||
return thread:newFunctionBase(function(...)
|
return thread:newFunctionBase(function(...)
|
||||||
return multi:newSystemThread("TempSystemThread"..THREAD_ID,func,...)
|
return multi:newSystemThread("TempSystemThread", func, ...)
|
||||||
end)()
|
end, holdme)()
|
||||||
end
|
end
|
||||||
|
|
||||||
THREAD.newSystemThread = multi.newSystemThread
|
THREAD.newSystemThread = multi.newSystemThread
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user