V15.2.0 #33
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
25
test.lua
25
test.lua
@ -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()
|
||||
Loading…
x
Reference in New Issue
Block a user