tiny changes

This commit is contained in:
Ryan Ward 2019-07-15 21:04:22 -04:00
parent 7126e28530
commit 3bbd63ba62
4 changed files with 44 additions and 20 deletions

View File

@ -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!

View File

@ -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

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()
@ -169,12 +171,16 @@ function multi.InitSystemThreadErrorHandler()
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

View File

@ -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