tiny changes
This commit is contained in:
parent
7126e28530
commit
3bbd63ba62
@ -1,13 +1,19 @@
|
||||
#Changes
|
||||
# Changes
|
||||
[TOC]
|
||||
Update 13.1.0 Bug fixes and some new features (Will upgrade version to 14.0.0 if significant changes are made)
|
||||
-------------
|
||||
Added:
|
||||
- Connections:Lock() -- Prevents a connection object form being fired
|
||||
- Connections:Unlock() -- Removes the restriction imposed by conn:Lock()
|
||||
-
|
||||
|
||||
Fixed:
|
||||
- Minor bug with multi:newThread() in how names and functions were managed
|
||||
- Major bug with the system thread handler. Saw healthy threads as dead ones
|
||||
-
|
||||
|
||||
Changed:
|
||||
- getTasksDetails("t"), the table varaiant, formats threads, and system threads in the same way that tasks are formatted
|
||||
-
|
||||
|
||||
Update 13.0.0 Added some documentation, and some new features too check it out!
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
17
test.lua
17
test.lua
@ -15,16 +15,29 @@ function table.print(tbl, indent)
|
||||
end
|
||||
end
|
||||
end
|
||||
multi:newThread(function()
|
||||
print(#multi.SystemThreads)
|
||||
multi:newThread("Detail Updater",function()
|
||||
while true do
|
||||
thread.sleep(1)
|
||||
print(multi:getTasksDetails())
|
||||
print("-----")
|
||||
multi:getTasksDetails("t")
|
||||
table.print(multi:getTasksDetails("t"))
|
||||
io.read()
|
||||
end
|
||||
end)
|
||||
multi.OnSystemThreadDied(function(...)
|
||||
print("why you say dead?",...)
|
||||
end)
|
||||
multi.OnError(function(...)
|
||||
print(...)
|
||||
end)
|
||||
multi:newSystemThread("TestSystem",function()
|
||||
while true do
|
||||
THREAD.sleep(1)
|
||||
print("I'm alive")
|
||||
end
|
||||
end)
|
||||
print(#multi.SystemThreads)
|
||||
multi:mainloop{
|
||||
protect = false,
|
||||
print = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user