V15.3.0 #46

Merged
rayaman merged 85 commits from v15.3.0 into network_parallelism_test_branch 2022-06-11 23:41:07 -04:00
3 changed files with 84 additions and 7 deletions
Showing only changes of commit d98f353936 - Show all commits

View File

@ -13,6 +13,11 @@ Full Update Showcase
Added: Added:
--- ---
- multi:lManager() the uManager() to mainloop() equivalent to lightloop()
- A lightweight version of uManager() Priorities are not supported!
- multi:newProcessor(name,nothread).run()
- new function run to the processor object to
- multi:newTLoop() member functions - multi:newTLoop() member functions
- `TLoop:Set(set)` - Sets the time to wait for the TLoop - `TLoop:Set(set)` - Sets the time to wait for the TLoop
@ -26,6 +31,8 @@ Added:
Changed: Changed:
--- ---
- `multi:newProcessor(name,nothread)` The new argument allows you to tell the system you won't be using the Start() and Stop() functions, rather you will handle the process yourself. Using the proc.run() function. This function needs to be called to pump the events.
- Processors now also use lManager instead of uManager.
- `multi.hold(n,opt)` now supports an option table like thread.hold does. - `multi.hold(n,opt)` now supports an option table like thread.hold does.
- Connection Objects now pass on the parent object if created on a multiobj. This was to allow chaining to work properly with the new update - Connection Objects now pass on the parent object if created on a multiobj. This was to allow chaining to work properly with the new update

View File

@ -912,7 +912,7 @@ function multi.getCurrentTask()
end end
local sandcount = 1 local sandcount = 1
function multi:newProcessor(name) function multi:newProcessor(name,nothread)
local c = {} local c = {}
setmetatable(c,{__index = self}) setmetatable(c,{__index = self})
local multi,thread = require("multi"):init() -- We need to capture the t in thread local multi,thread = require("multi"):init() -- We need to capture the t in thread
@ -920,12 +920,12 @@ function multi:newProcessor(name)
sandcount = sandcount + 1 sandcount = sandcount + 1
c.Mainloop = {} c.Mainloop = {}
c.Type = "process" c.Type = "process"
c.Active = false c.Active = false or nothread
c.Name = name or "" c.Name = name or ""
c.process = self:newThread(c.Name,function() c.process = self:newThread(c.Name,function()
while true do while true do
thread.hold(function() thread.hold(function()
return c.Active return c.Active and not(nothread)
end) end)
__CurrentProcess = c __CurrentProcess = c
c:uManager() c:uManager()
@ -935,6 +935,11 @@ function multi:newProcessor(name)
c.process.isProcessThread = true c.process.isProcessThread = true
c.process.PID = sandcount c.process.PID = sandcount
c.OnError = c.process.OnError c.OnError = c.process.OnError
function c.run()
__CurrentProcess = c
c:uManager()
__CurrentProcess = self
end
function c.Start() function c.Start()
c.Active = true c.Active = true
return self return self
@ -1632,6 +1637,7 @@ function multi:lightloop(settings)
local Loop=self.Mainloop local Loop=self.Mainloop
local ctask local ctask
while true do while true do
__CurrentProcess = self
for _D=#Loop,1,-1 do for _D=#Loop,1,-1 do
__CurrentTask = Loop[_D] __CurrentTask = Loop[_D]
ctask = __CurrentTask ctask = __CurrentTask
@ -1899,8 +1905,55 @@ function multi:uManager(settings)
end end
multi.OnLoad:Fire() multi.OnLoad:Fire()
self.uManager=self.uManagerRef self.uManager=self.uManagerRef
self.lManager=self.lManagerRef
end end
function multi:uManagerRef(settings) function multi:lManager(settings)
__CurrentProcess = self
multi.OnPreLoad:Fire()
multi.defaultSettings = settings or multi.defaultSettings
self.t,self.tt = clock(),0
if settings then
priority = settings.priority
if settings.auto_priority then
priority = -1
end
if settings.preLoop then
settings.preLoop(self)
end
if settings.stopOnError then
stopOnError = settings.stopOnError
end
multi.defaultSettings.p_i = self.Priority_Idle
if settings.auto_stretch then
multi.defaultSettings.p_i = settings.auto_stretch*self.Priority_Idle
end
multi.defaultSettings.delay = settings.auto_delay or 3
multi.defaultSettings.auto_lowerbound = settings.auto_lowerbound or self.Priority_Idle
protect = settings.protect
end
multi.OnLoad:Fire()
self.uManager=self.uManagerRef
self.lManager=self.lManagerRef
end
function multi:lManagerRef()
if self.Active then
local Loop=self.Mainloop
local ctask
while true do
__CurrentProcess = self
for _D=#Loop,1,-1 do
__CurrentTask = Loop[_D]
ctask = __CurrentTask
if ctask.Active then
if not protect then
ctask:Act()
end
end
end
end
end
end
function multi:uManagerRef()
if self.Active then if self.Active then
local Loop=self.Mainloop local Loop=self.Mainloop
local PS=self local PS=self

View File

@ -22,8 +22,25 @@ local multi,thread = require("multi"):init()
-- print("Function Done",handler.getReturns()) -- print("Function Done",handler.getReturns())
-- print("Function Done",handler2.getReturns()) -- print("Function Done",handler2.getReturns())
-- end) -- end)
multi:benchMark(1):OnBench(function(sec,steps)
-- multi:benchMark(1):OnBench(function(sec,steps)
-- print("Steps:",steps)
-- os.exit()
-- end)
local test = multi:newProcessor("test",true)
test:benchMark(1):OnBench(function(sec,steps)
print("Steps:",steps) print("Steps:",steps)
os.exit() --os.exit()
end) end)
multi:mainloop() test:newThread(function()
while true do
thread.sleep(1)
print("hi")
end
end)
test:lightloop()
-- multi:lightloop()