multi/test.lua
Ryan Ward 8f0f404c36 small changes
Im still have tons of work to do
2019-02-06 00:22:32 -05:00

49 lines
1.4 KiB
Lua

package.path="?/init.lua;?.lua;"..package.path
multi = require("multi")
local GLOBAL,THREAD = require("multi.integration.lanesManager").init()
nGLOBAL = require("multi.integration.networkManager").init()
local a
local clock = os.clock
function sleep(n) -- seconds
local t0 = clock()
while clock() - t0 <= n do end
end
master = multi:newMaster{
name = "Main", -- the name of the master
noBroadCast = true, -- if using the node manager, set this to true to avoid double connections
managerDetails = {"192.168.1.4",12345}, -- the details to connect to the node manager (ip,port)
}
master.OnError(function(name,err)
print(name.." has encountered an error: "..err)
end)
local connlist = {}
multi:newThread("NodeUpdater",function()
while true do
thread.sleep(1)
for i=1,#connlist do
conn = master:execute("TASK_MAN",connlist[i], multi:getTasksDetails())
end
end
end)
master.OnNodeConnected(function(name)
table.insert(connlist,name)
end)
multi.OnError(function(...)
print(...)
end)
multi:newSystemThreadedConsole("console"):init()
jQueue = multi:newSystemThreadedJobQueue("MainJobQueue")
jQueue.OnReady:holdUT()
jQueue:doToAll(function()
console = THREAD.waitFor("console"):init()
end)
jQueue:registerJob("TEST",function(a,b,c)
console:print(a,b,c)
return "This is a test"
end)
jQueue:pushJob("TEST",123,"Hello",false)
--~ multi:benchMark(1,nil,"Bench:")
multi:mainloop{
protect = false
}