Jobqueues lvl up

This commit is contained in:
Ryan Ward 2020-02-14 15:38:00 -05:00
parent ead2fd6f2c
commit ebe87ed69a
6 changed files with 46 additions and 43 deletions

View File

@ -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!

View File

@ -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

View File

@ -1742,7 +1742,7 @@ function multi.initThreads(justThreads)
for i=#threads,1,-1 do
if not threads[i].__started 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)
end
threads[i].__started = true

View File

@ -80,6 +80,7 @@ function multi:newSystemThreadedJobQueue(n)
function c:pushJob(name,...)
queueJob:push{name,jid,{...}}
jid = jid + 1
return jid-1
end
multi:newThread("JobQueueManager",function()
while true do

View File

@ -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

View File

@ -1,25 +1,44 @@
package.path="?/init.lua;?.lua;"..package.path
multi,thread = require("multi"):init()
--GLOBAL,THREAD = require("multi.integration.lanesManager"):init()
-- local co = 0
-- multi.OnLoad(function()
-- print("Code Loaded!")
-- end)
multi.OnExit(function(n)
print("Code Exited!")
end)
-- multi:newThread(function()
-- t = os.clock()
-- while true do
-- thread.skip()
-- co = co + 1
-- end
-- end)
-- multi:setTimeout(function()
-- os.exit()
-- end,5)
multi:benchMark(1):OnBench(function(...)
print(...)
os.exit()
end)
package.path="?.lua;?/init.lua;?.lua;"..package.path
local multi,thread = require("multi"):init()
GLOBAL,THREAD = require("multi.integration.lanesManager"):init()
local test = multi:newSystemThreadedJobQueue(4)
local nFunc = 0
function test:newFunction(name,func,holup) -- This registers with the queue
if type(name)=="function" then
holup = func
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)
return thread.hold(function()
if rets then
return unpack(rets)
end
end)
end,holup)
end
func = test:newFunction("test",function(a)
test2()
return a..a
end,true)
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()
multi:mainloop()