more tweaks
This commit is contained in:
parent
20647f4738
commit
28a4e37c51
@ -329,6 +329,8 @@ function multi.AlignTable(tab)
|
|||||||
end
|
end
|
||||||
return table.concat(str,"\n")
|
return table.concat(str,"\n")
|
||||||
end
|
end
|
||||||
|
local priorityTable = {[0]="Round-Robin",[1]="Just-Right",[2]="Top-heavy",[3]="Timed-Based-Balancer"}
|
||||||
|
local ProcessName = {[true]="SubProcess",[false]="MainProcess"}
|
||||||
function multi:getTasksDetails(t)
|
function multi:getTasksDetails(t)
|
||||||
if t == "string" or not t then
|
if t == "string" or not t then
|
||||||
str = {
|
str = {
|
||||||
@ -352,12 +354,17 @@ function multi:getTasksDetails(t)
|
|||||||
for i=1,#multi.scheduler.Threads do
|
for i=1,#multi.scheduler.Threads do
|
||||||
dat = dat .. "<THREAD: "..multi.scheduler.Threads[i].Name.." | "..os.clock()-multi.scheduler.Threads[i].creationTime..">\n"
|
dat = dat .. "<THREAD: "..multi.scheduler.Threads[i].Name.." | "..os.clock()-multi.scheduler.Threads[i].creationTime..">\n"
|
||||||
end
|
end
|
||||||
return "Load on "..({[true]="SubProcess<"..(self.Name or "Unnamed")..">",[false]="MainProcess"})[self.Type=="process"]..": "..multi.Round(multi:getLoad(),2).."%\nMemory Usage: "..math.ceil(collectgarbage("count")).." KB\nThreads Running: "..#multi.scheduler.Threads.."\n\n"..s.."\n\n"..dat
|
return "Load on "..ProcessName[self.Type=="process"].."<"..(self.Name or "Unnamed")..">"..": "..multi.Round(multi:getLoad(),2).."%\nMemory Usage: "..math.ceil(collectgarbage("count")).." KB\nThreads Running: "..#multi.scheduler.Threads.."\nPriority Scheme: "..priorityTable[multi.defaultSettings.priority or 0].."\n\n"..s.."\n\n"..dat
|
||||||
else
|
else
|
||||||
return "Load on "..({[true]="SubProcess<"..(self.Name or "Unnamed")..">",[false]="MainProcess"})[self.Type=="process"]..": "..multi.Round(multi:getLoad(),2).."%\nMemory Usage: "..math.ceil(collectgarbage("count")).." KB\nThreads Running: 0\n\n"..s
|
return "Load on "..({[true]="SubProcess<"..(self.Name or "Unnamed")..">",[false]="MainProcess"})[self.Type=="process"]..": "..multi.Round(multi:getLoad(),2).."%\nMemory Usage: "..math.ceil(collectgarbage("count")).." KB\nThreads Running: 0\nPriority Scheme: "..priorityTable[multi.defaultSettings.priority or 0].."\n\n"..s
|
||||||
end
|
end
|
||||||
elseif t == "t" or t == "table" then
|
elseif t == "t" or t == "table" then
|
||||||
str = {ThreadCount = #multi.scheduler.Threads,MemoryUsage = math.ceil(collectgarbage("count")).." KB"}
|
str = {
|
||||||
|
ThreadCount = #multi.scheduler.Threads,
|
||||||
|
MemoryUsage = math.ceil(collectgarbage("count")).." KB",
|
||||||
|
PriorityScheme = priorityTable[multi.defaultSettings.priority or 0],
|
||||||
|
SystemLoad = multi.Round(multi:getLoad(),2)
|
||||||
|
}
|
||||||
str.threads = {}
|
str.threads = {}
|
||||||
for i,v in pairs(self.Mainloop) do
|
for i,v in pairs(self.Mainloop) do
|
||||||
str[#str+1]={Type=v.Type,Name=v.Name,Uptime=os.clock()-v.creationTime,Priority=self.PriorityResolve[v.Priority],TID = i}
|
str[#str+1]={Type=v.Type,Name=v.Name,Uptime=os.clock()-v.creationTime,Priority=self.PriorityResolve[v.Priority],TID = i}
|
||||||
@ -868,7 +875,7 @@ function multi:newJob(func,name)
|
|||||||
end
|
end
|
||||||
table.insert(self.Jobs,{c,name})
|
table.insert(self.Jobs,{c,name})
|
||||||
if self.JobRunner==nil then
|
if self.JobRunner==nil then
|
||||||
self.JobRunner=self:newAlarm(self.jobUS)
|
self.JobRunner=self:newAlarm(self.jobUS):setName("multi.jobHandler")
|
||||||
self.JobRunner:OnRing(function(self)
|
self.JobRunner:OnRing(function(self)
|
||||||
if #self.Parent.Jobs>0 then
|
if #self.Parent.Jobs>0 then
|
||||||
if self.Parent.Jobs[1] then
|
if self.Parent.Jobs[1] then
|
||||||
@ -933,6 +940,7 @@ function multi:newEvent(task)
|
|||||||
table.insert(self.func,func)
|
table.insert(self.func,func)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
self:setPriority("core")
|
||||||
self:create(c)
|
self:create(c)
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
@ -1513,7 +1521,7 @@ function multi:newThread(name,func)
|
|||||||
end
|
end
|
||||||
function multi.initThreads()
|
function multi.initThreads()
|
||||||
initT = true
|
initT = true
|
||||||
multi.scheduler=multi:newLoop()
|
multi.scheduler=multi:newLoop():setName("multi.thread")
|
||||||
multi.scheduler.Type="scheduler"
|
multi.scheduler.Type="scheduler"
|
||||||
function multi.scheduler:setStep(n)
|
function multi.scheduler:setStep(n)
|
||||||
self.skip=tonumber(n) or 24
|
self.skip=tonumber(n) or 24
|
||||||
@ -1652,12 +1660,12 @@ function multi:newThreadedProcess(name)
|
|||||||
multi:newAlarm(n):OnRing(function(a)
|
multi:newAlarm(n):OnRing(function(a)
|
||||||
holding = false
|
holding = false
|
||||||
a:Destroy()
|
a:Destroy()
|
||||||
end)
|
end):setName("multi.TPSleep")
|
||||||
elseif type(n)=="function" then
|
elseif type(n)=="function" then
|
||||||
multi:newEvent(n):OnEvent(function(e)
|
multi:newEvent(n):OnEvent(function(e)
|
||||||
holding = false
|
holding = false
|
||||||
e:Destroy()
|
e:Destroy()
|
||||||
end)
|
end):setName("multi.TPHold")
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -1750,12 +1758,12 @@ function multi:newHyperThreadedProcess(name)
|
|||||||
multi:newAlarm(b):OnRing(function(a)
|
multi:newAlarm(b):OnRing(function(a)
|
||||||
holding = false
|
holding = false
|
||||||
a:Destroy()
|
a:Destroy()
|
||||||
end)
|
end):setName("multi.HTPSleep")
|
||||||
elseif type(b)=="function" then
|
elseif type(b)=="function" then
|
||||||
multi:newEvent(b):OnEvent(function(e)
|
multi:newEvent(b):OnEvent(function(e)
|
||||||
holding = false
|
holding = false
|
||||||
e:Destroy()
|
e:Destroy()
|
||||||
end)
|
end):setName("multi.HTPHold")
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
6
test.lua
6
test.lua
@ -3,9 +3,6 @@ multi = require("multi")
|
|||||||
local GLOBAL,THREAD = require("multi.integration.lanesManager").init()
|
local GLOBAL,THREAD = require("multi.integration.lanesManager").init()
|
||||||
nGLOBAL = require("multi.integration.networkManager").init()
|
nGLOBAL = require("multi.integration.networkManager").init()
|
||||||
local a
|
local a
|
||||||
function multi:setName(name)
|
|
||||||
self.Name = name
|
|
||||||
end
|
|
||||||
local clock = os.clock
|
local clock = os.clock
|
||||||
function sleep(n) -- seconds
|
function sleep(n) -- seconds
|
||||||
local t0 = clock()
|
local t0 = clock()
|
||||||
@ -22,7 +19,7 @@ end)
|
|||||||
local connlist = {}
|
local connlist = {}
|
||||||
multi:newThread("NodeUpdater",function()
|
multi:newThread("NodeUpdater",function()
|
||||||
while true do
|
while true do
|
||||||
thread.sleep(.1)
|
thread.sleep(1)
|
||||||
for i=1,#connlist do
|
for i=1,#connlist do
|
||||||
conn = master:execute("TASK_MAN",connlist[i], multi:getTasksDetails())
|
conn = master:execute("TASK_MAN",connlist[i], multi:getTasksDetails())
|
||||||
end
|
end
|
||||||
@ -34,7 +31,6 @@ end)
|
|||||||
multi.OnError(function(...)
|
multi.OnError(function(...)
|
||||||
print(...)
|
print(...)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
multi:mainloop{
|
multi:mainloop{
|
||||||
protect = false
|
protect = false
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user