Jobqueues lvl up
This commit is contained in:
parent
ead2fd6f2c
commit
ebe87ed69a
@ -1,4 +1,4 @@
|
|||||||
# multi Version: 14.0.0 Bug fixes and cool new features added (See changes.md)
|
# multi Version: 14.1.0 System threaded functions (See changes.md)
|
||||||
|
|
||||||
Found an issue? Please [submit it](https://github.com/rayaman/multi/issues) and ill look into it!
|
Found an issue? Please [submit it](https://github.com/rayaman/multi/issues) and ill look into it!
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
MAIN: Love2d support is updated to 11.1
|
|
||||||
|
|
||||||
May be bugs in supporting libraries, but the multitasking library is fully updated.
|
|
||||||
|
|
||||||
The GuiManager may have a bug or 2, but I haven't found any ground breaking bugs that haven't been fixed
|
|
||||||
@ -1742,7 +1742,7 @@ function multi.initThreads(justThreads)
|
|||||||
for i=#threads,1,-1 do
|
for i=#threads,1,-1 do
|
||||||
if not threads[i].__started then
|
if not threads[i].__started then
|
||||||
if coroutine.running() ~= threads[i].thread then
|
if coroutine.running() ~= threads[i].thread then
|
||||||
_,ret,r1,r2,r3,r4,r5,r6=coroutine.resume(threads[i].thread,t0,t1,t2,t3,t4,t5,t6)
|
_,ret,r1,r2,r3,r4,r5,r6=coroutine.resume(threads[i].thread,unpack(threads[i].startArgs))
|
||||||
CheckRets(i)
|
CheckRets(i)
|
||||||
end
|
end
|
||||||
threads[i].__started = true
|
threads[i].__started = true
|
||||||
|
|||||||
@ -80,6 +80,7 @@ function multi:newSystemThreadedJobQueue(n)
|
|||||||
function c:pushJob(name,...)
|
function c:pushJob(name,...)
|
||||||
queueJob:push{name,jid,{...}}
|
queueJob:push{name,jid,{...}}
|
||||||
jid = jid + 1
|
jid = jid + 1
|
||||||
|
return jid-1
|
||||||
end
|
end
|
||||||
multi:newThread("JobQueueManager",function()
|
multi:newThread("JobQueueManager",function()
|
||||||
while true do
|
while true do
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
multi = require("multi")
|
|
||||||
local GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
|
||||||
nGLOBAL = require("multi.integration.networkManager").init()
|
|
||||||
multi:nodeManager(12345) -- Host a node manager on port: 12345
|
|
||||||
print("Node Manager Running...")
|
|
||||||
settings = {
|
|
||||||
priority = 0, -- 1 or 2
|
|
||||||
protect = false,
|
|
||||||
}
|
|
||||||
multi:mainloop(settings)
|
|
||||||
-- Thats all you need to run the node manager, everything else is done automatically
|
|
||||||
63
test.lua
63
test.lua
@ -1,25 +1,44 @@
|
|||||||
package.path="?/init.lua;?.lua;"..package.path
|
package.path="?.lua;?/init.lua;?.lua;"..package.path
|
||||||
multi,thread = require("multi"):init()
|
local multi,thread = require("multi"):init()
|
||||||
--GLOBAL,THREAD = require("multi.integration.lanesManager"):init()
|
GLOBAL,THREAD = require("multi.integration.lanesManager"):init()
|
||||||
-- local co = 0
|
local test = multi:newSystemThreadedJobQueue(4)
|
||||||
-- multi.OnLoad(function()
|
local nFunc = 0
|
||||||
-- print("Code Loaded!")
|
function test:newFunction(name,func,holup) -- This registers with the queue
|
||||||
-- end)
|
if type(name)=="function" then
|
||||||
multi.OnExit(function(n)
|
holup = func
|
||||||
print("Code Exited!")
|
func = name
|
||||||
|
name = "JQFunction_"..nFunc
|
||||||
|
end
|
||||||
|
local ref = self
|
||||||
|
nFunc = nFunc + 1
|
||||||
|
ref:registerFunction(name,func)
|
||||||
|
return thread:newFunction(function(...)
|
||||||
|
local id = ref:pushJob(name,...)
|
||||||
|
local link
|
||||||
|
local rets
|
||||||
|
link = ref.OnJobCompleted(function(jid,...)
|
||||||
|
if id==jid then
|
||||||
|
rets = {...}
|
||||||
|
link:Remove()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
-- multi:newThread(function()
|
return thread.hold(function()
|
||||||
-- t = os.clock()
|
if rets then
|
||||||
-- while true do
|
return unpack(rets)
|
||||||
-- thread.skip()
|
end
|
||||||
-- co = co + 1
|
end)
|
||||||
-- end
|
end,holup)
|
||||||
-- end)
|
end
|
||||||
-- multi:setTimeout(function()
|
func = test:newFunction("test",function(a)
|
||||||
-- os.exit()
|
test2()
|
||||||
-- end,5)
|
return a..a
|
||||||
multi:benchMark(1):OnBench(function(...)
|
end,true)
|
||||||
print(...)
|
func2 = test:newFunction("test2",function(a)
|
||||||
|
print("ooo")
|
||||||
|
end,true)
|
||||||
|
print(func("1"))
|
||||||
|
print(func("Hello"))
|
||||||
|
print(func("sigh"))
|
||||||
|
print(#test.OnJobCompleted.connections)
|
||||||
os.exit()
|
os.exit()
|
||||||
end)
|
|
||||||
multi:mainloop()
|
multi:mainloop()
|
||||||
Loading…
x
Reference in New Issue
Block a user