Issue#12 Changed
Modify the newThread method to allow for nameless coroutine based threads
This commit is contained in:
parent
31f1e10cfc
commit
8afef44252
@ -1495,8 +1495,13 @@ end
|
|||||||
multi:setDomainName("Threads")
|
multi:setDomainName("Threads")
|
||||||
multi:setDomainName("Globals")
|
multi:setDomainName("Globals")
|
||||||
local initT = false
|
local initT = false
|
||||||
|
local threadCount = 0
|
||||||
function multi:newThread(name,func)
|
function multi:newThread(name,func)
|
||||||
if not func then return end
|
local func = func
|
||||||
|
if type(name) == "function" then
|
||||||
|
func = name
|
||||||
|
name = "Thread#"..threadCount
|
||||||
|
end
|
||||||
local c={}
|
local c={}
|
||||||
c.ref={}
|
c.ref={}
|
||||||
c.Name=name
|
c.Name=name
|
||||||
|
|||||||
43
test.lua
43
test.lua
@ -1,38 +1,13 @@
|
|||||||
--~ package.path="?/init.lua;?.lua;"..package.path
|
package.path="?/init.lua;?.lua;"..package.path
|
||||||
multi = require("multi")
|
multi = require("multi")
|
||||||
--~ local GLOBAL,THREAD = require("multi.integration.lanesManager").init()
|
local GLOBAL,THREAD = require("multi.integration.lanesManager").init()
|
||||||
--~ nGLOBAL = require("multi.integration.networkManager").init()
|
nGLOBAL = require("multi.integration.networkManager").init()
|
||||||
--~ local a
|
multi:newThread(function()
|
||||||
--~ local clock = os.clock
|
error("Did it work?")
|
||||||
--~ function sleep(n) -- seconds
|
end)
|
||||||
--~ local t0 = clock()
|
multi.OnError(function(...)
|
||||||
--~ while clock() - t0 <= n do end
|
print(...)
|
||||||
--~ 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 = {"localhost",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
|
|
||||||
--~ master:execute("TASK_MAN",connlist[i], multi:getTasksDetails())
|
|
||||||
--~ end
|
|
||||||
--~ end
|
|
||||||
--~ end)
|
|
||||||
--~ master.OnNodeConnected(function(name)
|
|
||||||
--~ print("Connected to the node")
|
|
||||||
--~ table.insert(connlist,name)
|
|
||||||
--~ end)
|
|
||||||
--~ multi.OnError(function(...)
|
|
||||||
--~ print(...)
|
|
||||||
--~ end)
|
|
||||||
print("HI!")
|
|
||||||
multi:mainloop{
|
multi:mainloop{
|
||||||
protect = false,
|
protect = false,
|
||||||
print = true
|
print = true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user