tiny changes

This commit is contained in:
2019-07-15 21:04:22 -04:00
parent 7126e28530
commit 3bbd63ba62
4 changed files with 44 additions and 20 deletions
+14 -15
View File
@@ -158,7 +158,7 @@ function multi:getLoad()
bench = steps
bb = steps
end)
while not bench do
while not bench do
multi:uManager()
end
bench = bench^1.5
@@ -355,7 +355,7 @@ function multi:getTasksDetails(t)
dat2 = dat2.."<SystemThread: "..multi.SystemThreads[i].Name.." | "..os.clock()-multi.SystemThreads[i].creationTime..">\n"
end
end
local load,steps = multi:getLoad()
local load, steps = multi:getLoad()
if multi.scheduler then
for i=1,#multi.scheduler.Threads do
dat = dat .. "<THREAD: "..multi.scheduler.Threads[i].Name.." | "..os.clock()-multi.scheduler.Threads[i].creationTime..">\n"
@@ -373,19 +373,18 @@ function multi:getTasksDetails(t)
PriorityScheme = priorityTable[multi.defaultSettings.priority or 0],
SystemLoad = multi.Round(load,2),
CyclesPerSecondPerTask = steps,
SystemThreadCount = #multi.SystemThreads
}
str.threads = {}
str.systemthreads = {}
str.Threads = {}
str.Systemthreads = {}
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}
end
for i=1,#multi.scheduler.Threads do
str.threads[multi.scheduler.Threads[i].Name]={Uptime = os.clock()-multi.scheduler.Threads[i].creationTime}
table.insert(str.Threads,{Uptime = os.clock()-multi.scheduler.Threads[i].creationTime,Name = multi.scheduler.Threads[i].Name})
end
if multi.canSystemThread then
for i=1,#multi.SystemThreads do
str.systemthreads[multi.SystemThreads[i].Name]={Uptime = os.clock()-multi.SystemThreads[i].creationTime}
end
for i=1,#multi.SystemThreads do
table.insert(str.Systemthreads,{Uptime = os.clock()-multi.SystemThreads[i].creationTime,Name = multi.SystemThreads[i].Name})
end
return str
end
@@ -635,7 +634,7 @@ function multi:newProcessor(file)
c.Jobs={}
c.queue={}
c.jobUS=2
c.l=self:newLoop(function(self,dt)
c.l=self:newLoop(function(self,dt)
if self.link.Active then
c:uManager()
end
@@ -1055,9 +1054,9 @@ function multi:newFunction(func)
c.func=func
mt={
__index=multi,
__call=function(self,...)
if self.Active then
return self:func(...)
__call=function(self,...)
if self.Active then
return self:func(...)
end
return nil,true
end
@@ -1478,8 +1477,8 @@ function thread.waitFor(name)
return thread.get(name)
end
function thread.testFor(name,_val,sym)
thread.hold(function()
local val = thread.get(name)~=nil
thread.hold(function()
local val = thread.get(name)~=nil
if val then
if sym == "==" or sym == "=" then
return _val==val
+8 -2
View File
@@ -135,6 +135,7 @@ function multi:newSystemThread(name,func,...)
count = count + 1
c.Type="sthread"
c.creationTime = os.clock()
c.alive = true
local THREAD_NAME=name
local function func2(...)
local multi = require("multi")
@@ -151,6 +152,7 @@ function multi:newSystemThread(name,func,...)
function c:kill()
self.thread:cancel()
multi.print("Thread: '"..self.name.."' has been stopped!")
self.alive = false
end
table.insert(multi.SystemThreads,c)
c.OnError = multi:newConnection()
@@ -164,17 +166,21 @@ function multi.InitSystemThreadErrorHandler()
multi:newThread("ThreadErrorHandler",function()
local threads = multi.SystemThreads
while true do
thread.sleep(.5) -- switching states often takes a huge hit on performance. half a second to tell me there is an error is good enough.
thread.sleep(.5) -- switching states often takes a huge hit on performance. half a second to tell me there is an error is good enough.
for i=#threads,1,-1 do
local v,err,t=threads[i].thread:join(.001)
if err then
if err:find("Thread was killed!") then
print(err)
livingThreads[threads[i].Id] = {false,threads[i].Name}
threads[i].alive = false
multi.OnSystemThreadDied:Fire(threads[i].Id)
GLOBAL["__THREADS__"]=livingThreads
table.remove(threads,i)
else
elseif err:find("stack traceback") then
print(err)
threads[i].OnError:Fire(threads[i],err,"Error in systemThread: '"..threads[i].name.."' <"..err..">")
threads[i].alive = false
livingThreads[threads[i].Id] = {false,threads[i].Name}
multi.OnSystemThreadDied:Fire(threads[i].Id)
GLOBAL["__THREADS__"]=livingThreads