Finished getLoad(type)

This commit is contained in:
Ryan Ward 2023-05-29 01:29:12 -04:00
parent 3effcb7384
commit 03ecb47f6f
2 changed files with 5 additions and 10 deletions

View File

@ -74,6 +74,7 @@ Allows the user to have multi auto set priorities (Requires chronos). Also adds
Added
---
- STP:getLoad(type) -- returns a table where the index is the threadID and the value is the number of objects[type] running on that thread. `type`: "threads" for coroutines running or nil for all other objects running.
- multi:newTargetedFunction(ID, proc, name, func, holup) -- This is used internally to handle thread.hold(proxy.conn)
- proxy.getThreadID() -- Returns the threadID of the thread that the proxy is running in
- proxy:getUniqueName() -- Gets the special name that identifies the object on the thread the proxy refers to

View File

@ -374,7 +374,7 @@ function multi:newSystemThreadedProcessor(cores)
end
-- Special functions
c.getLeastLoaded = thread:newFunction(function(self, tp)
c.getLoad = thread:newFunction(function(self, tp)
local loads = {}
local func
@ -390,7 +390,7 @@ function multi:newSystemThreadedProcessor(cores)
conn = c.jobqueue.OnJobCompleted(function(id, data)
if id == jid then
table.insert(loads, {v, data})
loads[v] = data
multi:newAlarm(1):OnRing(function(alarm)
c.jobqueue.OnJobCompleted:Unconnect(conn)
alarm:Destroy()
@ -400,14 +400,8 @@ function multi:newSystemThreadedProcessor(cores)
end
thread.hold(function() return #loads == c.cores end)
if tp then
multi.print("Threads\n-------")
else
multi.print("Tasks\n-----")
end
for i,v in pairs(loads) do
print(v[1], v[2])
end
return loads
end)
return c