diff --git a/README.md b/README.md index ba30e47..8fe99ea 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/commit notes.txt b/commit notes.txt deleted file mode 100644 index 683597f..0000000 --- a/commit notes.txt +++ /dev/null @@ -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 \ No newline at end of file diff --git a/multi/init.lua b/multi/init.lua index caa22e8..40a5d69 100644 --- a/multi/init.lua +++ b/multi/init.lua @@ -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 diff --git a/multi/integration/lanesManager/extensions.lua b/multi/integration/lanesManager/extensions.lua index 7c93108..ac6308b 100644 --- a/multi/integration/lanesManager/extensions.lua +++ b/multi/integration/lanesManager/extensions.lua @@ -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 diff --git a/sample-nodeManager.lua b/sample-nodeManager.lua deleted file mode 100644 index 7d57596..0000000 --- a/sample-nodeManager.lua +++ /dev/null @@ -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 diff --git a/test.lua b/test.lua index 8a321ab..6415cb2 100644 --- a/test.lua +++ b/test.lua @@ -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() \ No newline at end of file