6 Commits
Author SHA1 Message Date
server 72733394ac Fixed connections * 2023-01-04 10:33:36 -05:00
server dc9cee5a3e Fixing connection * issue 2023-01-04 10:28:02 -05:00
server 71ab702a75 Updated progress 2022-12-31 02:23:12 -05:00
server 1bb7410210 Merge pull request #51 from rayaman/v15.3.0
V15.3.0
2022-12-31 02:22:22 -05:00
server ec5bf74009 Fixed love2d STCs! Actually before new years :P 2022-12-31 02:21:01 -05:00
server 7ea6873c1f Fixed issue where fastmode connections wouldn't properly be removed 2022-12-30 15:22:37 -05:00
7 changed files with 196 additions and 112 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ My multitasking library for lua. It is a pure lua binding, with exceptions of th
</br> </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> </br>
+24
View File
@@ -1,10 +1,34 @@
# Changelog # Changelog
Table of contents 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.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.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.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 # Update 15.3.0 - A world of Connections
Full Update Showcase Full Update Showcase
+16 -3
View File
@@ -35,7 +35,7 @@ if not _G["$multi"] then
_G["$multi"] = {multi=multi,thread=thread} _G["$multi"] = {multi=multi,thread=thread}
end end
multi.Version = "15.3.0" multi.Version = "15.3.1"
multi.Name = "root" multi.Name = "root"
multi.NIL = {Type="NIL"} multi.NIL = {Type="NIL"}
local NIL = multi.NIL local NIL = multi.NIL
@@ -168,17 +168,23 @@ function multi:newConnection(protect,func,kill)
c1(function(...) c1(function(...)
cn.__count[1] = cn.__count[1] + 1 cn.__count[1] = cn.__count[1] + 1
c1:Lock()
if cn.__count[1] == cn.__hasInstances[1] then if cn.__count[1] == cn.__hasInstances[1] then
cn:Fire(...) cn:Fire(...)
cn.__count[1] = 0 cn.__count[1] = 0
c1:Unlock()
c2:Unlock()
end end
end) end)
c2(function(...) c2(function(...)
cn.__count[1] = cn.__count[1] + 1 cn.__count[1] = cn.__count[1] + 1
c2:Lock()
if cn.__count[1] == cn.__hasInstances[1] then if cn.__count[1] == cn.__hasInstances[1] then
cn:Fire(...) cn:Fire(...)
cn.__count[1] = 0 cn.__count[1] = 0
c1:Unlock()
c2:Unlock()
end end
end) end)
return cn return cn
@@ -246,7 +252,11 @@ function multi:newConnection(protect,func,kill)
function c:Unconnect(conn) function c:Unconnect(conn)
if conn.fast then 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 elseif conn.Destroy then
conn:Destroy() conn:Destroy()
end end
@@ -255,13 +265,14 @@ function multi:newConnection(protect,func,kill)
function c:fastMode() function c:fastMode()
if find_optimization then return self end if find_optimization then return self end
function self:Fire(...) function self:Fire(...)
if lock then return end
for i=1,#fast do for i=1,#fast do
fast[i](...) fast[i](...)
end end
end end
function self:Connect(func) function self:Connect(func)
table.insert(fast, func) table.insert(fast, func)
local temp = {fast = true, ind = #fast} local temp = {fast = true}
setmetatable(temp,{ setmetatable(temp,{
__call=function(s,...) __call=function(s,...)
return self:Connect(...) return self:Connect(...)
@@ -279,6 +290,7 @@ function multi:newConnection(protect,func,kill)
rawset(t,k,v) rawset(t,k,v)
end, end,
}) })
temp.ref = func
return temp return temp
end end
return self return self
@@ -337,6 +349,7 @@ function multi:newConnection(protect,func,kill)
end end
function temp:Destroy() 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 for i=#call_funcs,1,-1 do
if call_funcs[i]~=nil then if call_funcs[i]~=nil then
if call_funcs[i]==self.func then if call_funcs[i]==self.func then
+16 -14
View File
@@ -27,7 +27,8 @@ if not ISTHREAD then
GLOBAL = multi.integration.GLOBAL GLOBAL = multi.integration.GLOBAL
THREAD = multi.integration.THREAD THREAD = multi.integration.THREAD
else else
GLOBAL = multi.integration.GLOBAL
THREAD = multi.integration.THREAD
end end
function multi:newSystemThreadedQueue(name) function multi:newSystemThreadedQueue(name)
@@ -218,17 +219,17 @@ function multi:newSystemThreadedConnection(name)
c.PING = 0x02 c.PING = 0x02
c.PONG = 0x03 c.PONG = 0x03
local subscribe = multi:newSystemThreadedQueue("SUB_STC_" .. name):init() local subscribe = love.thread.getChannel("SUB_STC_" .. name)
function c:init() function c:init()
self.subscribe = THREAD.waitFor("SUB_STC_" .. self.Name):init() self.subscribe = love.thread.getChannel("SUB_STC_" .. self.Name)
function self:Fire(...) function self:Fire(...)
local args = {...} local args = {...}
if self.CID == THREAD.getID() then -- Host Call if self.CID == THREAD.getID() then -- Host Call
for _, link in pairs(self.links) do for _, link in pairs(self.links) do
link:push{self.TRIG, args} love.thread.getChannel(link):push{self.TRIG, args}
end end
self.proxy_conn:Fire(...) self.proxy_conn:Fire(...)
else else
@@ -245,7 +246,7 @@ function multi:newSystemThreadedConnection(name)
thread:newThread("STC_CONN_MAN" .. self.Name,function() thread:newThread("STC_CONN_MAN" .. self.Name,function()
local item local item
local string_self_ref = "LSF_" .. multi.randomString(16) 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} self.subscribe:push{self.CONN, string_self_ref}
while true do while true do
item = thread.hold(function() item = thread.hold(function()
@@ -256,7 +257,7 @@ function multi:newSystemThreadedConnection(name)
link_self_ref:pop() link_self_ref:pop()
elseif item[1] == self.CONN then elseif item[1] == self.CONN then
if string_self_ref ~= item[2] 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 end
link_self_ref:pop() link_self_ref:pop()
elseif item[1] == self.TRIG then elseif item[1] == self.TRIG then
@@ -286,7 +287,7 @@ function multi:newSystemThreadedConnection(name)
local ping local ping
local pong = function(link, links) local pong = function(link, links)
local res = thread.hold(function() local res = thread.hold(function()
return link:peek()[1] == c.PONG return love.thread.getChannel(link):peek()[1] == c.PONG
end,{sleep=3}) end,{sleep=3})
if not res then if not res then
@@ -297,7 +298,7 @@ function multi:newSystemThreadedConnection(name)
end end
end end
else else
link:pop() love.thread.getChannel(link):pop()
end end
end end
@@ -305,8 +306,8 @@ function multi:newSystemThreadedConnection(name)
ping:Pause() ping:Pause()
multi.ForEach(self.links, function(link) -- Sync new connections multi.ForEach(self.links, function(link) -- Sync new connections
link:push{self.PING} love.thread.getChannel(link):push{self.PING}
multi:newThread("pong Thread", pong, link, links) multi:newThread("pong Thread", pong, link, self.links)
end) end)
thread.sleep(3) thread.sleep(3)
@@ -316,7 +317,7 @@ function multi:newSystemThreadedConnection(name)
local function fire(...) local function fire(...)
for _, link in pairs(c.links) do for _, link in pairs(c.links) do
link:push {c.TRIG, {...}} love.thread.getChannel(link):push {c.TRIG, {...}}
end end
end end
@@ -330,11 +331,12 @@ function multi:newSystemThreadedConnection(name)
return c.subscribe:pop() return c.subscribe:pop()
end) end)
if item[1] == c.CONN then if item[1] == c.CONN then
multi.ForEach(c.links, function(link) -- Sync new connections 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) end)
print("Adding link") c.links[#c.links+1] = item[2]
c.links[#c.links+1] = THREAD.waitFor(item[2]):init()
elseif item[1] == c.TRIG then elseif item[1] == c.TRIG then
fire(unpack(item[2])) fire(unpack(item[2]))
c.proxy_conn:Fire(unpack(item[2])) c.proxy_conn:Fire(unpack(item[2]))
+9 -3
View File
@@ -26,16 +26,23 @@ if ISTHREAD then
end end
local ThreadFileData = [[ local ThreadFileData = [[
ISTHREAD = true ISTHREAD = true
THREAD = require("multi.integration.loveManager.threads") -- order is important! THREAD = require("multi.integration.loveManager.threads")
sThread = THREAD sThread = THREAD
__IMPORTS = {...} __IMPORTS = {...}
__FUNC__=table.remove(__IMPORTS,1) __FUNC__=table.remove(__IMPORTS,1)
__THREADID__=table.remove(__IMPORTS,1) __THREADID__=table.remove(__IMPORTS,1)
__THREADNAME__=table.remove(__IMPORTS,1) __THREADNAME__=table.remove(__IMPORTS,1)
math.randomseed(__THREADID__)
math.random()
math.random()
math.random()
stab = THREAD.createStaticTable(__THREADNAME__) stab = THREAD.createStaticTable(__THREADNAME__)
GLOBAL = THREAD.getGlobal() GLOBAL = THREAD.getGlobal()
multi, thread = require("multi").init() 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))} stab["returns"] = {THREAD.loadDump(__FUNC__)(unpack(__IMPORTS))}
]] ]]
local multi, thread = require("multi"):init() local multi, thread = require("multi"):init()
@@ -43,7 +50,6 @@ local THREAD = {}
__THREADID__ = 0 __THREADID__ = 0
__THREADNAME__ = "MainThread" __THREADNAME__ = "MainThread"
multi.integration={} multi.integration={}
multi.integration.love2d={}
local THREAD = require("multi.integration.loveManager.threads") local THREAD = require("multi.integration.loveManager.threads")
local GLOBAL = THREAD.getGlobal() local GLOBAL = THREAD.getGlobal()
local THREAD_ID = 1 local THREAD_ID = 1
+39
View File
@@ -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
View File
@@ -5,41 +5,41 @@ multi:getOptimizationConnection()(function(msg)
print(msg) print(msg)
end) 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() -- local link = conn1(function()
print("Conn1, first") -- print("Conn1, first")
end) -- end)
local link2 = conn1(function() -- local link2 = conn1(function()
print("Conn1, second") -- print("Conn1, second")
end) -- end)
local link3 = conn1(function() -- local link3 = conn1(function()
print("Conn1, third") -- print("Conn1, third")
end) -- end)
local link4 = conn2(function() -- local link4 = conn2(function()
print("Conn2, first") -- print("Conn2, first")
end) -- end)
local link5 = conn2(function() -- local link5 = conn2(function()
print("Conn2, second") -- print("Conn2, second")
end) -- end)
local link6 = conn2(function() -- local link6 = conn2(function()
print("Conn2, third") -- print("Conn2, third")
end) -- end)
print("All conns\n-------------") -- print("All conns\n-------------")
conn1:Fire() -- conn1:Fire()
conn2:Fire() -- conn2:Fire()
conn1:Unconnect(link3) -- conn1:Unconnect(link3)
conn2:Unconnect(link6) -- conn2:Unconnect(link6)
print("All conns Edit\n---------------------") -- print("All conns Edit\n---------------------")
conn1:Fire() -- conn1:Fire()
conn2:Fire() -- conn2:Fire()
-- thread:newThread(function() -- thread:newThread(function()
-- print("Awaiting status") -- print("Awaiting status")
@@ -60,74 +60,74 @@ conn2:Fire()
-- conn3:Fire() -- conn3:Fire()
-- end) -- end)
-- local conn = multi:newSystemThreadedConnection("conn"):init() local conn = multi:newSystemThreadedConnection("conn"):init()
-- multi:newSystemThread("Thread_Test_1", function() multi:newSystemThread("Thread_Test_1", function()
-- local multi, thread = require("multi"):init() local multi, thread = require("multi"):init()
-- local conn = GLOBAL["conn"]:init() local conn = GLOBAL["conn"]:init()
-- local console = THREAD.getConsole() local console = THREAD.getConsole()
-- conn(function(a,b,c) conn(function(a,b,c)
-- console.print(THREAD:getName().." was triggered!",a,b,c) console.print(THREAD:getName().." was triggered!",a,b,c)
-- end) end)
-- multi:mainloop() multi:mainloop()
-- end) end)
-- multi:newSystemThread("Thread_Test_2", function() multi:newSystemThread("Thread_Test_2", function()
-- local multi, thread = require("multi"):init() local multi, thread = require("multi"):init()
-- local conn = GLOBAL["conn"]:init() local conn = GLOBAL["conn"]:init()
-- local console = THREAD.getConsole() local console = THREAD.getConsole()
-- conn(function(a,b,c) conn(function(a,b,c)
-- console.print(THREAD:getName().." was triggered!",a,b,c) console.print(THREAD:getName().." was triggered!",a,b,c)
-- end) end)
-- multi:newAlarm(2):OnRing(function() multi:newAlarm(2):OnRing(function()
-- console.print("Fire 2!!!") console.print("Fire 2!!!")
-- conn:Fire(4,5,6) conn:Fire(4,5,6)
-- THREAD.kill() THREAD.kill()
-- end) end)
-- multi:mainloop() multi:mainloop()
-- end) end)
-- local console = THREAD.getConsole() local console = THREAD.getConsole()
-- conn(function(a,b,c) conn(function(a,b,c)
-- console.print("Mainloop conn got triggered!",a,b,c) console.print("Mainloop conn got triggered!",a,b,c)
-- end) end)
-- alarm = multi:newAlarm(1) alarm = multi:newAlarm(1)
-- alarm:OnRing(function() alarm:OnRing(function()
-- console.print("Fire 1!!!") console.print("Fire 1!!!")
-- conn:Fire(1,2,3) conn:Fire(1,2,3)
-- end) end)
-- alarm = multi:newAlarm(3):OnRing(function() alarm = multi:newAlarm(3):OnRing(function()
-- multi:newSystemThread("Thread_Test_3",function() multi:newSystemThread("Thread_Test_3",function()
-- local multi, thread = require("multi"):init() local multi, thread = require("multi"):init()
-- local conn = GLOBAL["conn"]:init() local conn = GLOBAL["conn"]:init()
-- local console = THREAD.getConsole() local console = THREAD.getConsole()
-- conn(function(a,b,c) conn(function(a,b,c)
-- console.print(THREAD:getName().." was triggered!",a,b,c) console.print(THREAD:getName().." was triggered!",a,b,c)
-- end) end)
-- multi:newAlarm(4):OnRing(function() multi:newAlarm(4):OnRing(function()
-- console.print("Fire 3!!!") console.print("Fire 3!!!")
-- conn:Fire(7,8,9) conn:Fire(7,8,9)
-- end) end)
-- multi:mainloop() multi:mainloop()
-- end) end)
-- end) end)
-- multi:newSystemThread("Thread_Test_4",function() multi:newSystemThread("Thread_Test_4",function()
-- local multi, thread = require("multi"):init() local multi, thread = require("multi"):init()
-- local conn = GLOBAL["conn"]:init() local conn = GLOBAL["conn"]:init()
-- local conn2 = multi:newConnection() local conn2 = multi:newConnection()
-- local console = THREAD.getConsole() local console = THREAD.getConsole()
-- multi:newAlarm(2):OnRing(function() multi:newAlarm(2):OnRing(function()
-- conn2:Fire() conn2:Fire()
-- end) end)
-- multi:newThread(function() multi:newThread(function()
-- console.print("Conn Test!") console.print("Conn Test!")
-- thread.hold(conn + conn2) thread.hold(conn + conn2)
-- console.print("It held!") console.print("It held!")
-- end) end)
-- multi:mainloop() multi:mainloop()
-- end) end)
-- multi:mainloop() multi:mainloop()