Working on 16.0.0 #53

Merged
rayaman merged 120 commits from v16.0.0 into master 2024-02-25 00:00:51 -05:00
4 changed files with 27 additions and 33 deletions
Showing only changes of commit 42149ffab2 - Show all commits

View File

@ -204,6 +204,7 @@ Added
Changed
---
- multi.OnObjectCreated is only called when an object is created in a particular process. Proc.OnObjectCreated is needed to detect when an object is created within a process.
- multi.print shows "INFO" before it's message.
- Connections internals changed, not too much changed on the surface.
- newConnection(protect, func, kill)

View File

@ -402,7 +402,7 @@ function multi:newConnection(protect, func, kill)
end
if not(ignoreconn) then
multi:create(c)
self:create(c)
end
return c
@ -638,7 +638,7 @@ function multi:newTimer()
time=os.clock()-time
return self
end
multi:create(c)
self:create(c)
return c
end
@ -662,7 +662,7 @@ function multi:newEvent(task)
c.OnEvent = self:newConnection():fastMode()
self:setPriority("core")
c:setName(c.Type)
multi:create(c)
self:create(c)
return c
end
@ -684,7 +684,7 @@ function multi:newUpdater(skip)
end
c.OnUpdate = self:newConnection():fastMode()
c:setName(c.Type)
multi:create(c)
self:create(c)
return c
end
@ -721,7 +721,7 @@ function multi:newAlarm(set)
return self
end
c:setName(c.Type)
multi:create(c)
self:create(c)
return c
end
@ -744,7 +744,7 @@ function multi:newLoop(func,notime)
c.OnLoop(func)
end
multi:create(c)
self:create(c)
c:setName(c.Type)
return c
end
@ -804,7 +804,7 @@ function multi:newStep(start,reset,count,skip)
return self
end
c:setName(c.Type)
multi:create(c)
self:create(c)
return c
end
@ -840,7 +840,7 @@ function multi:newTLoop(func,set)
c.OnLoop(func)
end
c:setName(c.Type)
multi:create(c)
self:create(c)
return c
end
@ -890,7 +890,7 @@ function multi:newTStep(start,reset,count,set)
return self
end
c:setName(c.Type)
multi:create(c)
self:create(c)
return c
end
@ -979,6 +979,7 @@ function multi:newProcessor(name, nothread)
c.threads = {}
c.startme = {}
c.parent = self
c.OnObjectCreated = multi:newConnection()
local handler = c:createHandler(c)
@ -1449,7 +1450,7 @@ function thread:newThread(name, func, ...)
globalThreads[c] = multi
threadid = threadid + 1
multi:create(c)
self:create(c)
c.creationTime = os.clock()
return c
end
@ -2172,7 +2173,7 @@ function multi:IsAnActor()
return self.Act~=nil
end
function multi:reallocate(o,n)
function multi:reallocate(o, n)
n=n or #o.Mainloop+1
local int=self.Parent
self:Destroy()

View File

@ -27,17 +27,12 @@ local uManagerRefP = multi.uManagerRefP1
-- self:setCurrentProcess() a bit slower than using the local var, but there isn't another option
-- function multi:uManagerRef()
-- if self.Active then
-- self:setCurrentProcess()
-- local Loop=self.Mainloop
-- for _D=#Loop,1,-1 do
-- __CurrentTask = Loop[_D]
-- __CurrentTask:Act()
-- self:setCurrentProcess()
-- end
-- end
-- end
local priorityManager = multi:newProcessor("Priority Manager", true)
local function processHook(obj, proc)
obj.__restoreProc = proc
obj:reallocate(priorityManager)
end
local function init()
local RR, PB, TB = 0, 1, 2
@ -67,7 +62,12 @@ local function init()
end
local function init_chronos()
multi:newThread("Priority Manager", function()
while true do
thread.yield()
priorityManager.run()
end
end)
end
if chronos then

View File

@ -1,13 +1,5 @@
package.path = "../?/init.lua;../?.lua;"..package.path
multi, thread = require("multi"):init{print=true,findopt=true}
require("multi.integration.priorityManager")
local conn1 = multi:newConnection()
local conn2 = function(a,b,c) return a*2, b*2, c*2 end % conn1
conn2(function(a,b,c)
print("Conn2",a,b,c)
end)
conn1(function(a,b,c)
print("Conn1",a,b,c)
end)
conn1:Fire(1,2,3)
conn2:Fire(1,2,3)
multi:mainloop()