Reworking the taskdetails method

This commit is contained in:
Ryan Ward 2022-02-17 10:00:55 -05:00
parent fc18a303dd
commit 5172dcdf01
3 changed files with 12 additions and 22 deletions

View File

@ -13,6 +13,8 @@ Full Update Showcase
Added:
---
- multi:getThreads()
- Returns a list of all threads on a process
- multi:newProcessor(name,nothread).run()
- new function run to the processor object to

View File

@ -943,6 +943,9 @@ function multi:newProcessor(name,nothread)
c.process.isProcessThread = true
c.process.PID = sandcount
c.OnError = c.process.OnError
function c:getThreads()
return self.threads
end
function c:newThread(name,func,...)
in_proc = c
local t = thread.newThread(c,name,func,...)
@ -1027,6 +1030,10 @@ local resume, status, create, yield, running = coroutine.resume, coroutine.statu
local t_hold, t_sleep, t_holdF, t_skip, t_holdW, t_yield, t_none = 1, 2, 3, 4, 5, 6, 7
function multi:getThreads()
return threads
end
function thread.request(t,cmd,...)
thread.requests[t.thread] = {cmd,{...}}
end

View File

@ -1,27 +1,8 @@
package.path = "./?/init.lua;"..package.path
multi, thread = require("multi"):init()
func = thread:newFunction(function(count)
local a = 0
while true do
a = a + 1
thread.sleep(.1)
thread.pushStatus(a,count)
if a == count then break end
end
return "Done", 1, 2, 3
end)
thread:newThread("test",function()
local ret = func(10)
ret.OnStatus(function(part,whole)
print("Ret1: ",math.ceil((part/whole)*1000)/10 .."%")
end)
print("Status:",thread.hold(ret.OnReturn))
print("Function Done!")
os.exit()
end).OnError(function(...)
print("Error:",...)
end)
function multi:getTaskStats()
local stats = {}
end
multi:mainloop()