Removed system threaded connections, soon to be replaced by proxies
This commit is contained in:
parent
81fc7b95c9
commit
acc94ea17e
7
init.lua
7
init.lua
@ -2389,7 +2389,7 @@ end
|
|||||||
function multi.print(...)
|
function multi.print(...)
|
||||||
if multi.defaultSettings.print then
|
if multi.defaultSettings.print then
|
||||||
local t = {}
|
local t = {}
|
||||||
for i,v in pairs(multi.pack(...)) do t[#t+1] = tostring(v) end
|
for i,v in ipairs(multi.pack(...)) do t[#t+1] = tostring(v) end
|
||||||
io.write("\x1b[94mINFO:\x1b[0m " .. table.concat(t," ") .. "\n")
|
io.write("\x1b[94mINFO:\x1b[0m " .. table.concat(t," ") .. "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2397,7 +2397,7 @@ end
|
|||||||
function multi.warn(...)
|
function multi.warn(...)
|
||||||
if multi.defaultSettings.warn then
|
if multi.defaultSettings.warn then
|
||||||
local t = {}
|
local t = {}
|
||||||
for i,v in pairs(multi.pack(...)) do t[#t+1] = tostring(v) end
|
for i,v in ipairs(multi.pack(...)) do t[#t+1] = tostring(v) end
|
||||||
io.write("\x1b[93mWARNING:\x1b[0m " .. table.concat(t," ") .. "\n")
|
io.write("\x1b[93mWARNING:\x1b[0m " .. table.concat(t," ") .. "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2414,7 +2414,7 @@ end
|
|||||||
|
|
||||||
function multi.success(...)
|
function multi.success(...)
|
||||||
local t = {}
|
local t = {}
|
||||||
for i,v in pairs(multi.pack(...)) do t[#t+1] = tostring(v) end
|
for i,v in ipairs(multi.pack(...)) do t[#t+1] = tostring(v) end
|
||||||
io.write("\x1b[92mSUCCESS:\x1b[0m " .. table.concat(t," ") .. "\n")
|
io.write("\x1b[92mSUCCESS:\x1b[0m " .. table.concat(t," ") .. "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2431,7 +2431,6 @@ multi.SetName = multi.setName
|
|||||||
local _os = os.exit
|
local _os = os.exit
|
||||||
|
|
||||||
function os.exit(n)
|
function os.exit(n)
|
||||||
print("ERROR_"..n)
|
|
||||||
multi.OnExit:Fire(n or 0)
|
multi.OnExit:Fire(n or 0)
|
||||||
_os(n)
|
_os(n)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -381,3 +381,4 @@ function multi:newSystemThreadedConnection(name)
|
|||||||
|
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
|
require("multi.integration.sharedExtensions")
|
||||||
@ -153,3 +153,4 @@ function multi:newSystemThreadedConnection(name)
|
|||||||
GLOBAL[name or "_"] = conn
|
GLOBAL[name or "_"] = conn
|
||||||
return conn
|
return conn
|
||||||
end
|
end
|
||||||
|
require("multi.integration.sharedExtensions")
|
||||||
@ -22,26 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local function copy(obj)
|
|
||||||
if type(obj) ~= 'table' then return obj end
|
|
||||||
local res = {}
|
|
||||||
for k, v in pairs(obj) do res[copy(k)] = copy(v) end
|
|
||||||
return res
|
|
||||||
end
|
|
||||||
|
|
||||||
function tprint (tbl, indent)
|
|
||||||
if not indent then indent = 0 end
|
|
||||||
for k, v in pairs(tbl) do
|
|
||||||
formatting = string.rep(" ", indent) .. k .. ": "
|
|
||||||
if type(v) == "table" then
|
|
||||||
print(formatting)
|
|
||||||
tprint(v, indent+1)
|
|
||||||
else
|
|
||||||
print(formatting .. tostring(v))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local multi, thread = require("multi"):init()
|
local multi, thread = require("multi"):init()
|
||||||
|
|
||||||
-- Returns a handler that allows a user to interact with an object on another thread!
|
-- Returns a handler that allows a user to interact with an object on another thread!
|
||||||
@ -73,6 +53,12 @@ function multi:newProxy(list)
|
|||||||
local multi, thread = nil, nil
|
local multi, thread = nil, nil
|
||||||
function c:init()
|
function c:init()
|
||||||
local multi, thread = nil, nil
|
local multi, thread = nil, nil
|
||||||
|
local function copy(obj)
|
||||||
|
if type(obj) ~= 'table' then return obj end
|
||||||
|
local res = {}
|
||||||
|
for k, v in pairs(obj) do res[copy(k)] = copy(v) end
|
||||||
|
return res
|
||||||
|
end
|
||||||
if not(c.is_init) then
|
if not(c.is_init) then
|
||||||
c.is_init = true
|
c.is_init = true
|
||||||
local multi, thread = require("multi"):init()
|
local multi, thread = require("multi"):init()
|
||||||
@ -132,6 +118,12 @@ function multi:newProxy(list)
|
|||||||
end).OnError(multi.error)
|
end).OnError(multi.error)
|
||||||
return self
|
return self
|
||||||
else
|
else
|
||||||
|
local function copy(obj)
|
||||||
|
if type(obj) ~= 'table' then return obj end
|
||||||
|
local res = {}
|
||||||
|
for k, v in pairs(obj) do res[copy(k)] = copy(v) end
|
||||||
|
return res
|
||||||
|
end
|
||||||
local multi, thread = require("multi"):init()
|
local multi, thread = require("multi"):init()
|
||||||
local me = self
|
local me = self
|
||||||
local funcs = copy(self.funcs)
|
local funcs = copy(self.funcs)
|
||||||
@ -180,6 +172,12 @@ function multi:newProxy(list)
|
|||||||
function c:getTransferable()
|
function c:getTransferable()
|
||||||
local cp = {}
|
local cp = {}
|
||||||
local multi, thread = require("multi"):init()
|
local multi, thread = require("multi"):init()
|
||||||
|
local function copy(obj)
|
||||||
|
if type(obj) ~= 'table' then return obj end
|
||||||
|
local res = {}
|
||||||
|
for k, v in pairs(obj) do res[copy(k)] = copy(v) end
|
||||||
|
return res
|
||||||
|
end
|
||||||
cp.is_init = true
|
cp.is_init = true
|
||||||
cp.proxy_link = self.proxy_link
|
cp.proxy_link = self.proxy_link
|
||||||
cp.name = self.name
|
cp.name = self.name
|
||||||
|
|||||||
@ -131,53 +131,111 @@ multi:newThread("Scheduler Thread",function()
|
|||||||
|
|
||||||
multi.success("SystemThreadedJobQueues: Ok")
|
multi.success("SystemThreadedJobQueues: Ok")
|
||||||
|
|
||||||
queue2 = multi:newSystemThreadedQueue("Test_Queue2"):init()
|
-- queue2 = multi:newSystemThreadedQueue("Test_Queue2"):init()
|
||||||
multi:newSystemThread("Test_Thread_2",function()
|
-- multi:newSystemThread("Test_Thread_2",function()
|
||||||
queue2 = THREAD.waitFor("Test_Queue2"):init()
|
-- queue2 = THREAD.waitFor("Test_Queue2"):init()
|
||||||
connOut = THREAD.waitFor("ConnectionNAMEHERE"):init()
|
-- connOut = THREAD.waitFor("ConnectionNAMEHERE"):init()
|
||||||
connOut(function(arg)
|
-- connOut(function(arg)
|
||||||
queue2:push("Test_Thread_2")
|
-- queue2:push("Test_Thread_2")
|
||||||
end)
|
-- end)
|
||||||
multi:mainloop()
|
-- multi:mainloop()
|
||||||
end).OnError(multi.error)
|
-- end).OnError(multi.error)
|
||||||
multi:newSystemThread("Test_Thread_3",function()
|
-- multi:newSystemThread("Test_Thread_3",function()
|
||||||
queue2 = THREAD.waitFor("Test_Queue2"):init()
|
-- queue2 = THREAD.waitFor("Test_Queue2"):init()
|
||||||
connOut = THREAD.waitFor("ConnectionNAMEHERE"):init()
|
-- connOut = THREAD.waitFor("ConnectionNAMEHERE"):init()
|
||||||
connOut(function(arg)
|
-- connOut(function(arg)
|
||||||
queue2:push("Test_Thread_3")
|
-- queue2:push("Test_Thread_3")
|
||||||
end)
|
-- end)
|
||||||
multi:mainloop()
|
-- multi:mainloop()
|
||||||
end).OnError(multi.error)
|
-- end).OnError(multi.error)
|
||||||
connOut = multi:newSystemThreadedConnection("ConnectionNAMEHERE"):init()
|
-- connOut = multi:newSystemThreadedConnection("ConnectionNAMEHERE"):init()
|
||||||
a=0
|
-- a=0
|
||||||
connOut(function(arg)
|
-- connOut(function(arg)
|
||||||
queue2:push("Main")
|
-- queue2:push("Main")
|
||||||
end)
|
-- end)
|
||||||
for i=1,3 do
|
-- for i=1,3 do
|
||||||
thread.sleep(.1)
|
-- thread.sleep(.1)
|
||||||
connOut:Fire("Test From Main Thread: "..i.."\n")
|
-- connOut:Fire("Test From Main Thread: "..i.."\n")
|
||||||
|
-- end
|
||||||
|
-- thread.sleep(2)
|
||||||
|
-- local count = 0
|
||||||
|
-- multi:newThread(function()
|
||||||
|
-- while count < 9 do
|
||||||
|
-- if queue2:pop() then
|
||||||
|
-- count = count + 1
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end).OnError(multi.error)
|
||||||
|
-- _, err = thread.hold(function() return count == 9 end,{sleep=.3})
|
||||||
|
-- if err == multi.TIMEOUT then
|
||||||
|
-- multi.error("SystemThreadedConnections: Failed")
|
||||||
|
-- end
|
||||||
|
-- multi.success("SystemThreadedConnections: Ok")
|
||||||
|
|
||||||
|
local stp = multi:newSystemThreadedProcessor(8)
|
||||||
|
|
||||||
|
local tloop = stp:newTLoop(nil, 1)
|
||||||
|
|
||||||
|
local proxy_test = false
|
||||||
|
|
||||||
|
multi:newSystemThread("Testing proxy copy THREAD",function(tloop)
|
||||||
|
local multi, thread = require("multi"):init()
|
||||||
|
tloop = tloop:init()
|
||||||
|
multi.print("tloop type:",tloop.Type)
|
||||||
|
multi.print("Testing proxies on other threads")
|
||||||
|
thread:newThread(function()
|
||||||
|
while true do
|
||||||
|
thread.hold(tloop.OnLoop)
|
||||||
|
print(THREAD_NAME,"Loopy")
|
||||||
end
|
end
|
||||||
|
end)
|
||||||
|
tloop.OnLoop(function(a)
|
||||||
|
print(THREAD_NAME, "Got loop...")
|
||||||
|
end)
|
||||||
|
multi:mainloop()
|
||||||
|
end, tloop:getTransferable()).OnError(multi.error)
|
||||||
|
|
||||||
|
multi.print("tloop", tloop.Type)
|
||||||
|
multi.print("tloop.OnLoop", tloop.OnLoop.Type)
|
||||||
|
|
||||||
|
thread:newThread(function()
|
||||||
|
multi.print("Testing holding on a proxy connection!")
|
||||||
|
thread.hold(tloop.OnLoop)
|
||||||
|
multi.print("Held on proxy connection... once")
|
||||||
|
thread.hold(tloop.OnLoop)
|
||||||
|
multi.print("Held on proxy connection... twice")
|
||||||
|
proxy_test = true
|
||||||
|
end).OnError(print)
|
||||||
|
|
||||||
|
thread:newThread(function()
|
||||||
|
while true do
|
||||||
|
thread.hold(tloop.OnLoop)
|
||||||
|
print(THREAD_NAME,"Loopy")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
tloop.OnLoop(function()
|
||||||
|
print("OnLoop",THREAD_NAME)
|
||||||
|
end)
|
||||||
|
|
||||||
|
t, val = thread.hold(function()
|
||||||
|
return count == 10
|
||||||
|
end,{sleep=5})
|
||||||
|
|
||||||
|
if val == multi.TIMEOUT then
|
||||||
|
multi.error("SystemThreadedProcessor/Proxies: Failed")
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
thread.sleep(2)
|
thread.sleep(2)
|
||||||
local count = 0
|
|
||||||
multi:newThread(function()
|
multi.success("SystemThreadedProcessor: OK")
|
||||||
while count < 9 do
|
|
||||||
if queue2:pop() then
|
|
||||||
count = count + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end).OnError(multi.error)
|
|
||||||
_, err = thread.hold(function() return count == 9 end,{sleep=.3})
|
|
||||||
if err == multi.TIMEOUT then
|
|
||||||
multi.error("SystemThreadedConnections: Failed")
|
|
||||||
end
|
|
||||||
multi.success("SystemThreadedConnections: Ok")
|
|
||||||
|
|
||||||
we_good = true
|
we_good = true
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end).OnError(multi.error)
|
end).OnError(multi.error)
|
||||||
|
|
||||||
multi.OnExit(function(err_or_errorcode)
|
multi.OnExit(function(err_or_errorcode)
|
||||||
print("Final status!",err_or_errorcode)
|
|
||||||
if not we_good then
|
if not we_good then
|
||||||
multi.info("There was an error running some tests!")
|
multi.info("There was an error running some tests!")
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user