Fixing issues with priority
This commit is contained in:
parent
6c1e9f26f0
commit
8580d92c9c
@ -75,7 +75,7 @@ multi.PriorityResolve = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
multi.PStep = 1
|
multi.PStep = 1
|
||||||
multi.PList = {multi.Priority_Core,multi.Priority_Very_High,multi.Priority_High,multi.Priority_Above_Normal,multi.Priority_Normal,multi.Priority_Below_Normal,multi.Priority_Low,multi.Priority_Very_Low,multi.Priority_Idle}
|
local PList = {multi.Priority_Core,multi.Priority_Very_High,multi.Priority_High,multi.Priority_Above_Normal,multi.Priority_Normal,multi.Priority_Below_Normal,multi.Priority_Low,multi.Priority_Very_Low,multi.Priority_Idle}
|
||||||
multi.PriorityTick=1
|
multi.PriorityTick=1
|
||||||
multi.Priority=multi.Priority_High
|
multi.Priority=multi.Priority_High
|
||||||
multi.threshold=256
|
multi.threshold=256
|
||||||
@ -1630,8 +1630,10 @@ end
|
|||||||
function multi:threadloop()
|
function multi:threadloop()
|
||||||
multi.initThreads(true)
|
multi.initThreads(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function multi:lightloop(settings)
|
function multi:lightloop(settings)
|
||||||
multi.defaultSettings = settings or multi.defaultSettings
|
multi.defaultSettings = settings or multi.defaultSettings
|
||||||
|
self.uManager=self.lManager
|
||||||
multi.OnPreLoad:Fire()
|
multi.OnPreLoad:Fire()
|
||||||
if not isRunning then
|
if not isRunning then
|
||||||
local Loop=self.Mainloop
|
local Loop=self.Mainloop
|
||||||
@ -1650,12 +1652,13 @@ function multi:lightloop(settings)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function multi:mainloop(settings)
|
function multi:mainloop(settings)
|
||||||
__CurrentProcess = self
|
__CurrentProcess = self
|
||||||
multi.OnPreLoad:Fire()
|
multi.OnPreLoad:Fire()
|
||||||
multi.defaultSettings = settings or multi.defaultSettings
|
multi.defaultSettings = settings or multi.defaultSettings
|
||||||
self.uManager=self.uManagerRef
|
self.uManager=self.uManagerRef
|
||||||
local p_c,p_h,p_an,p_n,p_bn,p_l,p_i = self.Priority_Core,self.Priority_High,self.Priority_Above_Normal,self.Priority_Normal,self.Priority_Below_Normal,self.Priority_Low,self.Priority_Idle
|
local p_c,p_vh,p_h,p_an,p_n,p_bn,p_l,p_vl,p_i = self.Priority_Core,self.Priority_Very_High,self.Priority_High,self.Priority_Above_Normal,self.Priority_Normal,self.Priority_Below_Normal,self.Priority_Low,self.Priority_Very_Low,self.Priority_Idle
|
||||||
local P_LB = p_i
|
local P_LB = p_i
|
||||||
if not isRunning then
|
if not isRunning then
|
||||||
local protect = false
|
local protect = false
|
||||||
@ -1708,9 +1711,9 @@ function multi:mainloop(settings)
|
|||||||
for _D=#Loop,1,-1 do
|
for _D=#Loop,1,-1 do
|
||||||
__CurrentTask = Loop[_D]
|
__CurrentTask = Loop[_D]
|
||||||
ctask = __CurrentTask
|
ctask = __CurrentTask
|
||||||
for P=1,7 do
|
for P=1,9 do
|
||||||
if ctask then
|
if ctask then
|
||||||
if (PS.PList[P])%ctask.Priority == 0 then
|
if (PList[P])%ctask.Priority == 0 then
|
||||||
if ctask.Active then
|
if ctask.Active then
|
||||||
self.CID = _D
|
self.CID = _D
|
||||||
if not protect then
|
if not protect then
|
||||||
@ -1772,7 +1775,7 @@ function multi:mainloop(settings)
|
|||||||
__CurrentTask = Loop[_D]
|
__CurrentTask = Loop[_D]
|
||||||
ctask = __CurrentTask
|
ctask = __CurrentTask
|
||||||
if ctask then
|
if ctask then
|
||||||
if ctask.Priority == p_c or (ctask.Priority == p_h and tt<.5) or (ctask.Priority == p_an and tt<.125) or (ctask.Priority == p_n and tt<.063) or (ctask.Priority == p_bn and tt<.016) or (ctask.Priority == p_l and tt<.003) or (ctask.Priority == p_i and tt<.001) then
|
if ctask.Priority == p_c or (ctask.Priority == p_vh and tt<.55) or (ctask.Priority == p_h and tt<.5) or (ctask.Priority == p_an and tt<.125) or (ctask.Priority == p_n and tt<.063) or (ctask.Priority == p_bn and tt<.016) or (ctask.Priority == p_l and tt<.003) or (ctask.Priority == p_vl and tt<.001) or (ctask.Priority == p_i and tt<.001) then
|
||||||
if ctask.Active then
|
if ctask.Active then
|
||||||
if not protect then
|
if not protect then
|
||||||
ctask:Act()
|
ctask:Act()
|
||||||
@ -1978,9 +1981,9 @@ function multi:uManagerRefP1()
|
|||||||
for _D=#Loop,1,-1 do
|
for _D=#Loop,1,-1 do
|
||||||
__CurrentTask = Loop[_D]
|
__CurrentTask = Loop[_D]
|
||||||
ctask = __CurrentTask
|
ctask = __CurrentTask
|
||||||
for P=1,7 do
|
for P=1,9 do
|
||||||
if ctask then
|
if ctask then
|
||||||
if (PS.PList[P])%ctask.Priority==0 then
|
if (PList[P])%ctask.Priority==0 then
|
||||||
if ctask.Active then
|
if ctask.Active then
|
||||||
if not multi.defaultSettings.protect then
|
if not multi.defaultSettings.protect then
|
||||||
ctask:Act()
|
ctask:Act()
|
||||||
@ -2285,7 +2288,7 @@ function multi:getLoad()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function multi:setPriority(s)
|
function multi:setPriority(s)
|
||||||
if type(s)==number then
|
if type(s)=="number" then
|
||||||
self.Priority=s
|
self.Priority=s
|
||||||
elseif type(s)=='string' then
|
elseif type(s)=='string' then
|
||||||
if s:lower()=='core' or s:lower()=='c' then
|
if s:lower()=='core' or s:lower()=='c' then
|
||||||
@ -2516,7 +2519,7 @@ multi.OnError=multi:newConnection()
|
|||||||
multi.OnPreLoad = multi:newConnection()
|
multi.OnPreLoad = multi:newConnection()
|
||||||
multi.OnExit = multi:newConnection(nil,nil,true)
|
multi.OnExit = multi:newConnection(nil,nil,true)
|
||||||
multi.m = {onexit = function() multi.OnExit:Fire() end}
|
multi.m = {onexit = function() multi.OnExit:Fire() end}
|
||||||
if _VERSION >= "Lua 5.2" then
|
if _VERSION >= "Lua 5.2" or jit then
|
||||||
setmetatable(multi.m, {__gc = multi.m.onexit})
|
setmetatable(multi.m, {__gc = multi.m.onexit})
|
||||||
else
|
else
|
||||||
multi.m.sentinel = newproxy(true)
|
multi.m.sentinel = newproxy(true)
|
||||||
|
|||||||
32
test3.lua
32
test3.lua
@ -28,11 +28,29 @@ local multi,thread = require("multi"):init()
|
|||||||
-- print("Steps:",steps)
|
-- print("Steps:",steps)
|
||||||
-- os.exit()
|
-- os.exit()
|
||||||
-- end)
|
-- end)
|
||||||
|
print("Running benchmarks! ",_VERSION)
|
||||||
multi:benchMark(1):OnBench(function(sec,steps)
|
local sleep_for = 1
|
||||||
print("Steps:",steps)
|
local a = 0
|
||||||
--os.exit()
|
local c = 1
|
||||||
|
local function bench(t,step)
|
||||||
|
a = a + step
|
||||||
|
c = c + 1
|
||||||
|
if c == 9 then
|
||||||
|
print("Total: "..a)
|
||||||
|
os.exit()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
multi:benchMark(sleep_for,multi.Priority_Idle,"Idle:"):OnBench(bench)
|
||||||
|
multi:benchMark(sleep_for,multi.Priority_Very_Low,"Very Low:"):OnBench(bench)
|
||||||
|
multi:benchMark(sleep_for,multi.Priority_Low,"Low:"):OnBench()
|
||||||
|
multi:benchMark(sleep_for,multi.Priority_Below_Normal,"Below Normal:"):OnBench(bench)
|
||||||
|
multi:benchMark(sleep_for,multi.Priority_Normal,"Normal:"):OnBench(bench)
|
||||||
|
multi:benchMark(sleep_for,multi.Priority_Above_Normal,"Above Normal:"):OnBench(bench)
|
||||||
|
multi:benchMark(sleep_for,multi.Priority_High,"High:"):OnBench(bench)
|
||||||
|
multi:benchMark(sleep_for,multi.Priority_Very_High,"Very High:"):OnBench(bench)
|
||||||
|
multi:benchMark(sleep_for,multi.Priority_Core,"Core:"):OnBench(bench)
|
||||||
|
multi.OnExit(function()
|
||||||
|
print("Total: ".. a)
|
||||||
end)
|
end)
|
||||||
--multi:mainloop()
|
multi:mainloop{print=true,priority=3}
|
||||||
|
--multi:lightloop()
|
||||||
multi:lightloop()
|
|
||||||
Loading…
x
Reference in New Issue
Block a user