V15.2.0 #33
@ -13,6 +13,8 @@ Full Update Showcase
|
|||||||
|
|
||||||
Added:
|
Added:
|
||||||
---
|
---
|
||||||
|
- multi:getThreads()
|
||||||
|
- Returns a list of all threads on a process
|
||||||
- multi:newProcessor(name,nothread).run()
|
- multi:newProcessor(name,nothread).run()
|
||||||
- new function run to the processor object to
|
- new function run to the processor object to
|
||||||
|
|
||||||
|
|||||||
@ -943,6 +943,9 @@ function multi:newProcessor(name,nothread)
|
|||||||
c.process.isProcessThread = true
|
c.process.isProcessThread = true
|
||||||
c.process.PID = sandcount
|
c.process.PID = sandcount
|
||||||
c.OnError = c.process.OnError
|
c.OnError = c.process.OnError
|
||||||
|
function c:getThreads()
|
||||||
|
return self.threads
|
||||||
|
end
|
||||||
function c:newThread(name,func,...)
|
function c:newThread(name,func,...)
|
||||||
in_proc = c
|
in_proc = c
|
||||||
local t = thread.newThread(c,name,func,...)
|
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
|
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,...)
|
function thread.request(t,cmd,...)
|
||||||
thread.requests[t.thread] = {cmd,{...}}
|
thread.requests[t.thread] = {cmd,{...}}
|
||||||
end
|
end
|
||||||
|
|||||||
23
test.lua
23
test.lua
@ -1,27 +1,8 @@
|
|||||||
package.path = "./?/init.lua;"..package.path
|
package.path = "./?/init.lua;"..package.path
|
||||||
multi, thread = require("multi"):init()
|
multi, thread = require("multi"):init()
|
||||||
|
|
||||||
func = thread:newFunction(function(count)
|
function multi:getTaskStats()
|
||||||
local a = 0
|
local stats = {}
|
||||||
while true do
|
|
||||||
a = a + 1
|
|
||||||
thread.sleep(.1)
|
|
||||||
thread.pushStatus(a,count)
|
|
||||||
if a == count then break end
|
|
||||||
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)
|
|
||||||
|
|
||||||
multi:mainloop()
|
multi:mainloop()
|
||||||
Loading…
x
Reference in New Issue
Block a user