mirror of
https://github.com/rayaman/multi.git
synced 2026-09-05 07:27:35 -04:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72733394ac | ||
|
|
dc9cee5a3e | ||
|
|
71ab702a75 | ||
|
|
1bb7410210 | ||
|
|
ec5bf74009 | ||
|
|
7ea6873c1f |
@@ -10,7 +10,7 @@ My multitasking library for lua. It is a pure lua binding, with exceptions of th
|
||||
|
||||
</br>
|
||||
|
||||
Progress is being made in [v15.4.0](https://github.com/rayaman/multi/tree/v15.4.0)
|
||||
Progress is being made in [v16.0.0](https://github.com/rayaman/multi/tree/v16.0.0)
|
||||
---
|
||||
|
||||
</br>
|
||||
|
||||
@@ -1,10 +1,34 @@
|
||||
# Changelog
|
||||
Table of contents
|
||||
---
|
||||
[Update 15.3.1 - Bug fix](#update-1531---bug-fix)</br>
|
||||
[Update 15.3.0 - A world of connections](#update-1530---a-world-of-connections)</br>
|
||||
[Update 15.2.1 - Bug fix](#update-1521---bug-fix)</br>
|
||||
[Update 15.2.0 - Upgrade Complete](#update-1520---upgrade-complete)</br>[Update 15.1.0 - Hold the thread!](#update-1510---hold-the-thread)</br>[Update 15.0.0 - The art of faking it](#update-1500---the-art-of-faking-it)</br>[Update 14.2.0 - Bloatware Removed](#update-1420---bloatware-removed)</br>[Update 14.1.0 - A whole new world of possibilities](#update-1410---a-whole-new-world-of-possibilities)</br>[Update 14.0.0 - Consistency, Additions and Stability](#update-1400---consistency-additions-and-stability)</br>[Update 13.1.0 - Bug fixes and features added](#update-1310---bug-fixes-and-features-added)</br>[Update 13.0.0 - Added some documentation, and some new features too check it out!](#update-1300---added-some-documentation-and-some-new-features-too-check-it-out)</br>[Update 12.2.2 - Time for some more bug fixes!](#update-1222---time-for-some-more-bug-fixes)</br>[Update 12.2.1 - Time for some bug fixes!](#update-1221---time-for-some-bug-fixes)</br>[Update 12.2.0 - The chains of binding](#update-1220---the-chains-of-binding)</br>[Update 12.1.0 - Threads just can't hold on anymore](#update-1210---threads-just-cant-hold-on-anymore)</br>[Update: 12.0.0 - Big update (Lots of additions some changes)](#update-1200---big-update-lots-of-additions-some-changes)</br>[Update: 1.11.1 - Small Clarification on Love](#update-1111---small-clarification-on-love)</br>[Update: 1.11.0](#update-1110)</br>[Update: 1.10.0](#update-1100)</br>[Update: 1.9.2](#update-192)</br>[Update: 1.9.1 - Threads can now argue](#update-191---threads-can-now-argue)</br>[Update: 1.9.0](#update-190)</br>[Update: 1.8.7](#update-187)</br>[Update: 1.8.6](#update-186)</br>[Update: 1.8.5](#update-185)</br>[Update: 1.8.4](#update-184)</br>[Update: 1.8.3 - Mainloop recieves some needed overhauling](#update-183---mainloop-recieves-some-needed-overhauling)</br>[Update: 1.8.2](#update-182)</br>[Update: 1.8.1](#update-181)</br>[Update: 1.7.6](#update-176)</br>[Update: 1.7.5](#update-175)</br>[Update: 1.7.4](#update-174)</br>[Update: 1.7.3](#update-173)</br>[Update: 1.7.2](#update-172)</br>[Update: 1.7.1 - Bug Fixes Only](#update-171---bug-fixes-only)</br>[Update: 1.7.0 - Threading the systems](#update-170---threading-the-systems)</br>[Update: 1.6.0](#update-160)</br>[Update: 1.5.0](#update-150)</br>[Update: 1.4.1 (4/10/2017) - First Public release of the library](#update-141-4102017---first-public-release-of-the-library)</br>[Update: 1.4.0 (3/20/2017)](#update-140-3202017)</br>[Update: 1.3.0 (1/29/2017)](#update-130-1292017)</br>[Update: 1.2.0 (12.31.2016)](#update-120-12312016)</br>[Update: 1.1.0](#update-110)</br>[Update: 1.0.0](#update-100)</br>[Update: 0.6.3](#update-063)</br>[Update: 0.6.2](#update-062)</br>[Update: 0.6.1-6](#update-061-6)</br>[Update: 0.5.1-6](#update-051-6)</br>[Update: 0.4.1](#update-041)</br>[Update: 0.3.0 - The update that started it all](#update-030---the-update-that-started-it-all)</br>[Update: EventManager 2.0.0](#update-eventmanager-200)</br>[Update: EventManager 1.2.0](#update-eventmanager-120)</br>[Update: EventManager 1.1.0](#update-eventmanager-110)</br>[Update: EventManager 1.0.0 - Error checking](#update-eventmanager-100---error-checking)</br>[Version: EventManager 0.0.1 - In The Beginning things were very different](#version-eventmanager-001---in-the-beginning-things-were-very-different)
|
||||
|
||||
# Update 15.3.1 - Bug fix
|
||||
Fixed
|
||||
---
|
||||
- Issue where multiplying connections triggered events improperly
|
||||
```lua
|
||||
local multi, thread = require("multi"):init()
|
||||
conn1 = multi:newConnection()
|
||||
conn2 = multi:newConnection(); -- To remove function ambiguity
|
||||
|
||||
(conn1 * conn2)(function() print("Triggered!") end)
|
||||
|
||||
conn1:Fire()
|
||||
conn2:Fire()
|
||||
|
||||
-- Looks like this is triggering a response. It shouldn't. We need to account for this
|
||||
conn1:Fire()
|
||||
conn1:Fire()
|
||||
-- Triggering conn1 twice counted as a valid way to trigger the phantom connection (conn1 * conn2)
|
||||
|
||||
-- Now in 15.3.1, this works properly and the above doesn't do anything. Internally connections are locked until the conditions are met.
|
||||
conn2:Fire()
|
||||
```
|
||||
|
||||
# Update 15.3.0 - A world of Connections
|
||||
|
||||
Full Update Showcase
|
||||
|
||||
@@ -35,7 +35,7 @@ if not _G["$multi"] then
|
||||
_G["$multi"] = {multi=multi,thread=thread}
|
||||
end
|
||||
|
||||
multi.Version = "15.3.0"
|
||||
multi.Version = "15.3.1"
|
||||
multi.Name = "root"
|
||||
multi.NIL = {Type="NIL"}
|
||||
local NIL = multi.NIL
|
||||
@@ -168,17 +168,23 @@ function multi:newConnection(protect,func,kill)
|
||||
|
||||
c1(function(...)
|
||||
cn.__count[1] = cn.__count[1] + 1
|
||||
c1:Lock()
|
||||
if cn.__count[1] == cn.__hasInstances[1] then
|
||||
cn:Fire(...)
|
||||
cn.__count[1] = 0
|
||||
c1:Unlock()
|
||||
c2:Unlock()
|
||||
end
|
||||
end)
|
||||
|
||||
c2(function(...)
|
||||
cn.__count[1] = cn.__count[1] + 1
|
||||
c2:Lock()
|
||||
if cn.__count[1] == cn.__hasInstances[1] then
|
||||
cn:Fire(...)
|
||||
cn.__count[1] = 0
|
||||
c1:Unlock()
|
||||
c2:Unlock()
|
||||
end
|
||||
end)
|
||||
return cn
|
||||
@@ -246,7 +252,11 @@ function multi:newConnection(protect,func,kill)
|
||||
|
||||
function c:Unconnect(conn)
|
||||
if conn.fast then
|
||||
table.remove(fast,conn.ind)
|
||||
for i = 1, #fast do
|
||||
if conn.ref == fast[i] then
|
||||
table.remove(fast, i)
|
||||
end
|
||||
end
|
||||
elseif conn.Destroy then
|
||||
conn:Destroy()
|
||||
end
|
||||
@@ -255,13 +265,14 @@ function multi:newConnection(protect,func,kill)
|
||||
function c:fastMode()
|
||||
if find_optimization then return self end
|
||||
function self:Fire(...)
|
||||
if lock then return end
|
||||
for i=1,#fast do
|
||||
fast[i](...)
|
||||
end
|
||||
end
|
||||
function self:Connect(func)
|
||||
table.insert(fast, func)
|
||||
local temp = {fast = true, ind = #fast}
|
||||
local temp = {fast = true}
|
||||
setmetatable(temp,{
|
||||
__call=function(s,...)
|
||||
return self:Connect(...)
|
||||
@@ -279,6 +290,7 @@ function multi:newConnection(protect,func,kill)
|
||||
rawset(t,k,v)
|
||||
end,
|
||||
})
|
||||
temp.ref = func
|
||||
return temp
|
||||
end
|
||||
return self
|
||||
@@ -337,6 +349,7 @@ function multi:newConnection(protect,func,kill)
|
||||
end
|
||||
|
||||
function temp:Destroy()
|
||||
multi.print("Calling Destroy on a connection link is deprecated and will be removed in v16.0.0")
|
||||
for i=#call_funcs,1,-1 do
|
||||
if call_funcs[i]~=nil then
|
||||
if call_funcs[i]==self.func then
|
||||
|
||||
@@ -27,7 +27,8 @@ if not ISTHREAD then
|
||||
GLOBAL = multi.integration.GLOBAL
|
||||
THREAD = multi.integration.THREAD
|
||||
else
|
||||
|
||||
GLOBAL = multi.integration.GLOBAL
|
||||
THREAD = multi.integration.THREAD
|
||||
end
|
||||
|
||||
function multi:newSystemThreadedQueue(name)
|
||||
@@ -218,17 +219,17 @@ function multi:newSystemThreadedConnection(name)
|
||||
c.PING = 0x02
|
||||
c.PONG = 0x03
|
||||
|
||||
local subscribe = multi:newSystemThreadedQueue("SUB_STC_" .. name):init()
|
||||
local subscribe = love.thread.getChannel("SUB_STC_" .. name)
|
||||
|
||||
function c:init()
|
||||
|
||||
self.subscribe = THREAD.waitFor("SUB_STC_" .. self.Name):init()
|
||||
self.subscribe = love.thread.getChannel("SUB_STC_" .. self.Name)
|
||||
|
||||
function self:Fire(...)
|
||||
local args = {...}
|
||||
if self.CID == THREAD.getID() then -- Host Call
|
||||
for _, link in pairs(self.links) do
|
||||
link:push{self.TRIG, args}
|
||||
love.thread.getChannel(link):push{self.TRIG, args}
|
||||
end
|
||||
self.proxy_conn:Fire(...)
|
||||
else
|
||||
@@ -245,7 +246,7 @@ function multi:newSystemThreadedConnection(name)
|
||||
thread:newThread("STC_CONN_MAN" .. self.Name,function()
|
||||
local item
|
||||
local string_self_ref = "LSF_" .. multi.randomString(16)
|
||||
local link_self_ref = multi:newSystemThreadedQueue():init()
|
||||
local link_self_ref = love.thread.getChannel(string_self_ref)
|
||||
self.subscribe:push{self.CONN, string_self_ref}
|
||||
while true do
|
||||
item = thread.hold(function()
|
||||
@@ -256,7 +257,7 @@ function multi:newSystemThreadedConnection(name)
|
||||
link_self_ref:pop()
|
||||
elseif item[1] == self.CONN then
|
||||
if string_self_ref ~= item[2] then
|
||||
table.insert(self.links, THREAD.waitFor(item[2]):init())
|
||||
table.insert(self.links, love.thread.getChannel(item[2]))
|
||||
end
|
||||
link_self_ref:pop()
|
||||
elseif item[1] == self.TRIG then
|
||||
@@ -286,7 +287,7 @@ function multi:newSystemThreadedConnection(name)
|
||||
local ping
|
||||
local pong = function(link, links)
|
||||
local res = thread.hold(function()
|
||||
return link:peek()[1] == c.PONG
|
||||
return love.thread.getChannel(link):peek()[1] == c.PONG
|
||||
end,{sleep=3})
|
||||
|
||||
if not res then
|
||||
@@ -297,7 +298,7 @@ function multi:newSystemThreadedConnection(name)
|
||||
end
|
||||
end
|
||||
else
|
||||
link:pop()
|
||||
love.thread.getChannel(link):pop()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -305,8 +306,8 @@ function multi:newSystemThreadedConnection(name)
|
||||
ping:Pause()
|
||||
|
||||
multi.ForEach(self.links, function(link) -- Sync new connections
|
||||
link:push{self.PING}
|
||||
multi:newThread("pong Thread", pong, link, links)
|
||||
love.thread.getChannel(link):push{self.PING}
|
||||
multi:newThread("pong Thread", pong, link, self.links)
|
||||
end)
|
||||
|
||||
thread.sleep(3)
|
||||
@@ -316,7 +317,7 @@ function multi:newSystemThreadedConnection(name)
|
||||
|
||||
local function fire(...)
|
||||
for _, link in pairs(c.links) do
|
||||
link:push {c.TRIG, {...}}
|
||||
love.thread.getChannel(link):push {c.TRIG, {...}}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -330,11 +331,12 @@ function multi:newSystemThreadedConnection(name)
|
||||
return c.subscribe:pop()
|
||||
end)
|
||||
if item[1] == c.CONN then
|
||||
|
||||
multi.ForEach(c.links, function(link) -- Sync new connections
|
||||
THREAD.waitFor(item[2]):init():push{c.CONN, link.Name}
|
||||
love.thread.getChannel(item[2]):push{c.CONN, link}
|
||||
end)
|
||||
print("Adding link")
|
||||
c.links[#c.links+1] = THREAD.waitFor(item[2]):init()
|
||||
c.links[#c.links+1] = item[2]
|
||||
|
||||
elseif item[1] == c.TRIG then
|
||||
fire(unpack(item[2]))
|
||||
c.proxy_conn:Fire(unpack(item[2]))
|
||||
|
||||
@@ -26,16 +26,23 @@ if ISTHREAD then
|
||||
end
|
||||
local ThreadFileData = [[
|
||||
ISTHREAD = true
|
||||
THREAD = require("multi.integration.loveManager.threads") -- order is important!
|
||||
THREAD = require("multi.integration.loveManager.threads")
|
||||
sThread = THREAD
|
||||
__IMPORTS = {...}
|
||||
__FUNC__=table.remove(__IMPORTS,1)
|
||||
__THREADID__=table.remove(__IMPORTS,1)
|
||||
__THREADNAME__=table.remove(__IMPORTS,1)
|
||||
math.randomseed(__THREADID__)
|
||||
math.random()
|
||||
math.random()
|
||||
math.random()
|
||||
stab = THREAD.createStaticTable(__THREADNAME__)
|
||||
GLOBAL = THREAD.getGlobal()
|
||||
multi, thread = require("multi").init()
|
||||
print(pcall(require,"multi.integration.loveManager.extensions"))
|
||||
multi.integration={}
|
||||
multi.integration.GLOBAL = GLOBAL
|
||||
multi.integration.THREAD = THREAD
|
||||
pcall(require,"multi.integration.loveManager.extensions")
|
||||
stab["returns"] = {THREAD.loadDump(__FUNC__)(unpack(__IMPORTS))}
|
||||
]]
|
||||
local multi, thread = require("multi"):init()
|
||||
@@ -43,7 +50,6 @@ local THREAD = {}
|
||||
__THREADID__ = 0
|
||||
__THREADNAME__ = "MainThread"
|
||||
multi.integration={}
|
||||
multi.integration.love2d={}
|
||||
local THREAD = require("multi.integration.loveManager.threads")
|
||||
local GLOBAL = THREAD.getGlobal()
|
||||
local THREAD_ID = 1
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package = "multi"
|
||||
version = "15.3-1"
|
||||
source = {
|
||||
url = "git://github.com/rayaman/multi.git",
|
||||
tag = "15.3.1",
|
||||
}
|
||||
description = {
|
||||
summary = "Lua Multi tasking library",
|
||||
detailed = [[
|
||||
This library contains many methods for multi tasking. Features non coroutine based multi-tasking, coroutine based multi-tasking, and system threading (Requires use of an integration).
|
||||
Check github for documentation.
|
||||
]],
|
||||
homepage = "https://github.com/rayaman/multi",
|
||||
license = "MIT"
|
||||
}
|
||||
dependencies = {
|
||||
"lua >= 5.1"
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
modules = {
|
||||
["multi"] = "init.lua",
|
||||
["multi.integration.lanesManager"] = "integration/lanesManager/init.lua",
|
||||
["multi.integration.lanesManager.extensions"] = "integration/lanesManager/extensions.lua",
|
||||
["multi.integration.lanesManager.threads"] = "integration/lanesManager/threads.lua",
|
||||
["multi.integration.loveManager"] = "integration/loveManager/init.lua",
|
||||
["multi.integration.loveManager.extensions"] = "integration/loveManager/extensions.lua",
|
||||
["multi.integration.loveManager.threads"] = "integration/loveManager/threads.lua",
|
||||
--["multi.integration.lovrManager"] = "integration/lovrManager/init.lua",
|
||||
--["multi.integration.lovrManager.extensions"] = "integration/lovrManager/extensions.lua",
|
||||
--["multi.integration.lovrManager.threads"] = "integration/lovrManager/threads.lua",
|
||||
["multi.integration.pesudoManager"] = "integration/pesudoManager/init.lua",
|
||||
["multi.integration.pesudoManager.extensions"] = "integration/pesudoManager/extensions.lua",
|
||||
["multi.integration.pesudoManager.threads"] = "integration/pesudoManager/threads.lua",
|
||||
["multi.integration.luvitManager"] = "integration/luvitManager.lua",
|
||||
["multi.integration.threading"] = "integration/threading.lua",
|
||||
--["multi.integration.networkManager"] = "integration/networkManager.lua",
|
||||
}
|
||||
}
|
||||
+91
-91
@@ -5,41 +5,41 @@ multi:getOptimizationConnection()(function(msg)
|
||||
print(msg)
|
||||
end)
|
||||
|
||||
local conn1, conn2, conn3 = multi:newConnection(), multi:newConnection():fastMode(), multi:newConnection()
|
||||
-- local conn1, conn2, conn3 = multi:newConnection(), multi:newConnection():fastMode(), multi:newConnection()
|
||||
|
||||
local link = conn1(function()
|
||||
print("Conn1, first")
|
||||
end)
|
||||
-- local link = conn1(function()
|
||||
-- print("Conn1, first")
|
||||
-- end)
|
||||
|
||||
local link2 = conn1(function()
|
||||
print("Conn1, second")
|
||||
end)
|
||||
-- local link2 = conn1(function()
|
||||
-- print("Conn1, second")
|
||||
-- end)
|
||||
|
||||
local link3 = conn1(function()
|
||||
print("Conn1, third")
|
||||
end)
|
||||
-- local link3 = conn1(function()
|
||||
-- print("Conn1, third")
|
||||
-- end)
|
||||
|
||||
local link4 = conn2(function()
|
||||
print("Conn2, first")
|
||||
end)
|
||||
-- local link4 = conn2(function()
|
||||
-- print("Conn2, first")
|
||||
-- end)
|
||||
|
||||
local link5 = conn2(function()
|
||||
print("Conn2, second")
|
||||
end)
|
||||
-- local link5 = conn2(function()
|
||||
-- print("Conn2, second")
|
||||
-- end)
|
||||
|
||||
local link6 = conn2(function()
|
||||
print("Conn2, third")
|
||||
end)
|
||||
-- local link6 = conn2(function()
|
||||
-- print("Conn2, third")
|
||||
-- end)
|
||||
|
||||
print("All conns\n-------------")
|
||||
conn1:Fire()
|
||||
conn2:Fire()
|
||||
-- print("All conns\n-------------")
|
||||
-- conn1:Fire()
|
||||
-- conn2:Fire()
|
||||
|
||||
conn1:Unconnect(link3)
|
||||
conn2:Unconnect(link6)
|
||||
print("All conns Edit\n---------------------")
|
||||
conn1:Fire()
|
||||
conn2:Fire()
|
||||
-- conn1:Unconnect(link3)
|
||||
-- conn2:Unconnect(link6)
|
||||
-- print("All conns Edit\n---------------------")
|
||||
-- conn1:Fire()
|
||||
-- conn2:Fire()
|
||||
|
||||
-- thread:newThread(function()
|
||||
-- print("Awaiting status")
|
||||
@@ -60,74 +60,74 @@ conn2:Fire()
|
||||
-- conn3:Fire()
|
||||
-- end)
|
||||
|
||||
-- local conn = multi:newSystemThreadedConnection("conn"):init()
|
||||
local conn = multi:newSystemThreadedConnection("conn"):init()
|
||||
|
||||
-- multi:newSystemThread("Thread_Test_1", function()
|
||||
-- local multi, thread = require("multi"):init()
|
||||
-- local conn = GLOBAL["conn"]:init()
|
||||
-- local console = THREAD.getConsole()
|
||||
-- conn(function(a,b,c)
|
||||
-- console.print(THREAD:getName().." was triggered!",a,b,c)
|
||||
-- end)
|
||||
-- multi:mainloop()
|
||||
-- end)
|
||||
multi:newSystemThread("Thread_Test_1", function()
|
||||
local multi, thread = require("multi"):init()
|
||||
local conn = GLOBAL["conn"]:init()
|
||||
local console = THREAD.getConsole()
|
||||
conn(function(a,b,c)
|
||||
console.print(THREAD:getName().." was triggered!",a,b,c)
|
||||
end)
|
||||
multi:mainloop()
|
||||
end)
|
||||
|
||||
-- multi:newSystemThread("Thread_Test_2", function()
|
||||
-- local multi, thread = require("multi"):init()
|
||||
-- local conn = GLOBAL["conn"]:init()
|
||||
-- local console = THREAD.getConsole()
|
||||
-- conn(function(a,b,c)
|
||||
-- console.print(THREAD:getName().." was triggered!",a,b,c)
|
||||
-- end)
|
||||
-- multi:newAlarm(2):OnRing(function()
|
||||
-- console.print("Fire 2!!!")
|
||||
-- conn:Fire(4,5,6)
|
||||
-- THREAD.kill()
|
||||
-- end)
|
||||
multi:newSystemThread("Thread_Test_2", function()
|
||||
local multi, thread = require("multi"):init()
|
||||
local conn = GLOBAL["conn"]:init()
|
||||
local console = THREAD.getConsole()
|
||||
conn(function(a,b,c)
|
||||
console.print(THREAD:getName().." was triggered!",a,b,c)
|
||||
end)
|
||||
multi:newAlarm(2):OnRing(function()
|
||||
console.print("Fire 2!!!")
|
||||
conn:Fire(4,5,6)
|
||||
THREAD.kill()
|
||||
end)
|
||||
|
||||
-- multi:mainloop()
|
||||
-- end)
|
||||
-- local console = THREAD.getConsole()
|
||||
-- conn(function(a,b,c)
|
||||
-- console.print("Mainloop conn got triggered!",a,b,c)
|
||||
-- end)
|
||||
multi:mainloop()
|
||||
end)
|
||||
local console = THREAD.getConsole()
|
||||
conn(function(a,b,c)
|
||||
console.print("Mainloop conn got triggered!",a,b,c)
|
||||
end)
|
||||
|
||||
-- alarm = multi:newAlarm(1)
|
||||
-- alarm:OnRing(function()
|
||||
-- console.print("Fire 1!!!")
|
||||
-- conn:Fire(1,2,3)
|
||||
-- end)
|
||||
alarm = multi:newAlarm(1)
|
||||
alarm:OnRing(function()
|
||||
console.print("Fire 1!!!")
|
||||
conn:Fire(1,2,3)
|
||||
end)
|
||||
|
||||
-- alarm = multi:newAlarm(3):OnRing(function()
|
||||
-- multi:newSystemThread("Thread_Test_3",function()
|
||||
-- local multi, thread = require("multi"):init()
|
||||
-- local conn = GLOBAL["conn"]:init()
|
||||
-- local console = THREAD.getConsole()
|
||||
-- conn(function(a,b,c)
|
||||
-- console.print(THREAD:getName().." was triggered!",a,b,c)
|
||||
-- end)
|
||||
-- multi:newAlarm(4):OnRing(function()
|
||||
-- console.print("Fire 3!!!")
|
||||
-- conn:Fire(7,8,9)
|
||||
-- end)
|
||||
-- multi:mainloop()
|
||||
-- end)
|
||||
-- end)
|
||||
alarm = multi:newAlarm(3):OnRing(function()
|
||||
multi:newSystemThread("Thread_Test_3",function()
|
||||
local multi, thread = require("multi"):init()
|
||||
local conn = GLOBAL["conn"]:init()
|
||||
local console = THREAD.getConsole()
|
||||
conn(function(a,b,c)
|
||||
console.print(THREAD:getName().." was triggered!",a,b,c)
|
||||
end)
|
||||
multi:newAlarm(4):OnRing(function()
|
||||
console.print("Fire 3!!!")
|
||||
conn:Fire(7,8,9)
|
||||
end)
|
||||
multi:mainloop()
|
||||
end)
|
||||
end)
|
||||
|
||||
-- multi:newSystemThread("Thread_Test_4",function()
|
||||
-- local multi, thread = require("multi"):init()
|
||||
-- local conn = GLOBAL["conn"]:init()
|
||||
-- local conn2 = multi:newConnection()
|
||||
-- local console = THREAD.getConsole()
|
||||
-- multi:newAlarm(2):OnRing(function()
|
||||
-- conn2:Fire()
|
||||
-- end)
|
||||
-- multi:newThread(function()
|
||||
-- console.print("Conn Test!")
|
||||
-- thread.hold(conn + conn2)
|
||||
-- console.print("It held!")
|
||||
-- end)
|
||||
-- multi:mainloop()
|
||||
-- end)
|
||||
multi:newSystemThread("Thread_Test_4",function()
|
||||
local multi, thread = require("multi"):init()
|
||||
local conn = GLOBAL["conn"]:init()
|
||||
local conn2 = multi:newConnection()
|
||||
local console = THREAD.getConsole()
|
||||
multi:newAlarm(2):OnRing(function()
|
||||
conn2:Fire()
|
||||
end)
|
||||
multi:newThread(function()
|
||||
console.print("Conn Test!")
|
||||
thread.hold(conn + conn2)
|
||||
console.print("It held!")
|
||||
end)
|
||||
multi:mainloop()
|
||||
end)
|
||||
|
||||
-- multi:mainloop()
|
||||
multi:mainloop()
|
||||
Reference in New Issue
Block a user