38 lines
1.3 KiB
Lua
38 lines
1.3 KiB
Lua
package.path="?/init.lua;?.lua;"..package.path
|
|
local GLOBAL,lthread=require("multi.intergration.lanesManager").init()
|
|
require("multi.alarm")
|
|
require("multi.threading")
|
|
for i,v in pairs(lanes.ABOUT) do print(i,v) end
|
|
multi:newAlarm(2):OnRing(function(self)
|
|
GLOBAL["NumOfCores"]=lthread.getCores()
|
|
end)
|
|
multi:newAlarm(7):OnRing(function(self)
|
|
GLOBAL["AnotherTest"]=true
|
|
end)
|
|
multi:newAlarm(13):OnRing(function(self)
|
|
GLOBAL["FinalTest"]=true
|
|
end)
|
|
multi:newSystemThread("test",function() -- spawns a thread in another lua process
|
|
require("multi.all") -- now you can do all of your coding with the multi library! You could even spawn more threads from here with the intergration. You would need to require the interaction again though
|
|
print("Waiting for variable: NumOfCores")
|
|
print("Got it: ",lthread.waitFor("NumOfCores"))
|
|
lthread.hold(function()
|
|
return GLOBAL["AnotherTest"] -- note this would hold the entire lthread. Spawn a coroutine thread using multi:newThread() or multi:newThreaded...
|
|
end)
|
|
print("Holding works!")
|
|
multi:newThread("tests",function()
|
|
thread.hold(function()
|
|
return GLOBAL["FinalTest"] -- note this will hold the entire lthread. As seen with the TLoop constantly going!
|
|
end)
|
|
print("Final test works!")
|
|
os.exit()
|
|
end)
|
|
local a=0
|
|
multi:newTLoop(function()
|
|
a=a+1
|
|
print(a)
|
|
end,.5)
|
|
multi:mainloop()
|
|
end)
|
|
multi:mainloop()
|