Protection is handled by Fire Funcction
This commit is contained in:
parent
8f3eb6d9a3
commit
1546076c80
@ -273,15 +273,8 @@ function multi:newConnection(protect,func,kill)
|
|||||||
|
|
||||||
function temp:Fire(...)
|
function temp:Fire(...)
|
||||||
if lock then return end
|
if lock then return end
|
||||||
if protect then
|
|
||||||
local t=pcall(call_funcs,...)
|
|
||||||
if t then
|
|
||||||
return t
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return call_funcs(...)
|
return call_funcs(...)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function temp:Destroy()
|
function temp:Destroy()
|
||||||
for i=#call_funcs,1,-1 do
|
for i=#call_funcs,1,-1 do
|
||||||
@ -298,9 +291,11 @@ function multi:newConnection(protect,func,kill)
|
|||||||
if name then
|
if name then
|
||||||
connections[name]=temp
|
connections[name]=temp
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.callback then
|
if self.callback then
|
||||||
self.callback(temp)
|
self.callback(temp)
|
||||||
end
|
end
|
||||||
|
|
||||||
return temp
|
return temp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -64,10 +64,10 @@ function multi:newSystemThreadedJobQueue(n)
|
|||||||
local c = {}
|
local c = {}
|
||||||
c.cores = n or THREAD.getCores()*2
|
c.cores = n or THREAD.getCores()*2
|
||||||
c.OnJobCompleted = multi:newConnection()
|
c.OnJobCompleted = multi:newConnection()
|
||||||
local funcs = multi:newSystemThreadedTable()
|
local funcs = multi:newSystemThreadedTable():init()
|
||||||
local queueJob = multi:newSystemThreadedQueue()
|
local queueJob = multi:newSystemThreadedQueue():init()
|
||||||
local queueReturn = multi:newSystemThreadedQueue()
|
local queueReturn = multi:newSystemThreadedQueue():init()
|
||||||
local doAll = multi:newSystemThreadedQueue()
|
local doAll = multi:newSystemThreadedQueue():init()
|
||||||
local ID=1
|
local ID=1
|
||||||
local jid = 1
|
local jid = 1
|
||||||
function c:isEmpty()
|
function c:isEmpty()
|
||||||
|
|||||||
19
test.lua
19
test.lua
@ -4,24 +4,35 @@ multi, thread = require("multi"):init{print=true}
|
|||||||
GLOBAL, THREAD = require("multi.integration.lanesManager"):init()
|
GLOBAL, THREAD = require("multi.integration.lanesManager"):init()
|
||||||
|
|
||||||
function multi:newSystemThreadedConnection(name,...)
|
function multi:newSystemThreadedConnection(name,...)
|
||||||
local master_conn = multi:newConnection(...)
|
|
||||||
local c = {}
|
local c = {}
|
||||||
|
local proxy_conn = multi:newConnection(...)
|
||||||
local name = name or multi.randomString(16)
|
local name = name or multi.randomString(16)
|
||||||
local connections = {} -- All triggers sent from main connection. When a connection is triggered on another thread, they speak to the main then send stuff out.
|
local connections = {} -- All triggers sent from main connection. When a connection is triggered on another thread, they speak to the main then send stuff out.
|
||||||
setmetatable(c,master_conn) -- A different approach will be taken for the non main connection objects
|
setmetatable(c,master_conn) -- A different approach will be taken for the non main connection objects
|
||||||
c.subscribe = multi:newSystemThreadedQueue("Subscribe_"..name)
|
c.subscribe = multi:newSystemThreadedQueue("Subscribe_"..name):init() -- Incoming subscriptions
|
||||||
multi:newThread("STC_"..name,function()
|
multi:newThread("STC_"..name,function()
|
||||||
while true do
|
while true do
|
||||||
thread.yield()
|
|
||||||
local item = c.subscribe:pop()
|
local item = c.subscribe:pop()
|
||||||
|
-- We need to check on broken connections
|
||||||
|
-- c:Ping()
|
||||||
|
--
|
||||||
if item ~= nil then
|
if item ~= nil then
|
||||||
connections[#connections+1] = item
|
connections[#connections+1] = item
|
||||||
thread.skip(multi.Priority_Normal) -- Usually a bunch of threads subscribe close to the same time. Process those by ensuring that they come alive around the same time
|
thread.skip(multi.Priority_Normal) -- Usually a bunch of threads subscribe close to the same time. Process those by ensuring that they come alive around the same time
|
||||||
else -- I'm using these "Constant" values since they may change with other releases and this should allow these functions to adjust with them.
|
else -- I'm using these "Constants" since they may change with other releases and this should allow these functions to adjust with them.
|
||||||
thread.skip(multi.Priority_Idle)
|
thread.skip(multi.Priority_Idle)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
function c:Ping() -- Threaded Function call, can use thread.*
|
||||||
|
--
|
||||||
|
end
|
||||||
|
function c:Fire(...)
|
||||||
|
--
|
||||||
|
end
|
||||||
|
function c:Connect(...)
|
||||||
|
--
|
||||||
|
end
|
||||||
function c:init()
|
function c:init()
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user