diff --git a/docs/changes.md b/docs/changes.md index be715a8..afbc542 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -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 diff --git a/integration/sharedExtensions/init.lua b/integration/sharedExtensions/init.lua index 188efcd..209cd36 100644 --- a/integration/sharedExtensions/init.lua +++ b/integration/sharedExtensions/init.lua @@ -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