mirror of
https://github.com/rayaman/multi.git
synced 2026-09-05 07:27:35 -04:00
Testing actions, fixing bugs with lanes
This commit is contained in:
@@ -34,6 +34,7 @@ function multi:newSystemThreadedQueue(name)
|
||||
local c = {}
|
||||
c.Name = name
|
||||
c.linda = lanes.linda()
|
||||
c.Type = multi.SQUEUE
|
||||
|
||||
function c:push(v)
|
||||
self.linda:send("Q", v)
|
||||
@@ -57,6 +58,8 @@ function multi:newSystemThreadedQueue(name)
|
||||
GLOBAL[name] = c
|
||||
end
|
||||
|
||||
self:create(c)
|
||||
|
||||
return c
|
||||
end
|
||||
|
||||
@@ -65,6 +68,7 @@ function multi:newSystemThreadedTable(name)
|
||||
local c = {}
|
||||
c.link = lanes.linda()
|
||||
c.Name = name
|
||||
c.Type = multi.STABLE
|
||||
|
||||
function c:init()
|
||||
return self
|
||||
@@ -85,12 +89,15 @@ function multi:newSystemThreadedTable(name)
|
||||
GLOBAL[name] = c
|
||||
end
|
||||
|
||||
self:create(c)
|
||||
|
||||
return c
|
||||
end
|
||||
|
||||
function multi:newSystemThreadedJobQueue(n)
|
||||
local c = {}
|
||||
c.cores = n or THREAD.getCores()*2
|
||||
c.Type = multi.SJOBQUEUE
|
||||
c.OnJobCompleted = multi:newConnection()
|
||||
local funcs = multi:newSystemThreadedTable():init()
|
||||
local queueJob = multi:newSystemThreadedQueue():init()
|
||||
@@ -133,7 +140,6 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
link = c.OnJobCompleted(function(jid,...)
|
||||
if id==jid then
|
||||
rets = multi.pack(...)
|
||||
c.OnJobCompleted:Unconnect(link)
|
||||
end
|
||||
end)
|
||||
return thread.hold(function()
|
||||
@@ -207,12 +213,16 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
multi:mainloop()
|
||||
end,i).OnError(multi.error)
|
||||
end
|
||||
|
||||
self:create(c)
|
||||
|
||||
return c
|
||||
end
|
||||
|
||||
function multi:newSystemThreadedConnection(name)
|
||||
local name = name or multi.randomString(16)
|
||||
local c = {}
|
||||
c.Type = multi.SCONNECTION
|
||||
c.CONN = 0x00
|
||||
c.TRIG = 0x01
|
||||
c.PING = 0x02
|
||||
@@ -348,6 +358,8 @@ function multi:newSystemThreadedConnection(name)
|
||||
GLOBAL[name] = c
|
||||
end
|
||||
|
||||
self:create(c)
|
||||
|
||||
return c
|
||||
end
|
||||
require("multi.integration.sharedExtensions")
|
||||
@@ -32,9 +32,7 @@ if multi.integration then -- This allows us to call the lanes manager from suppo
|
||||
}
|
||||
end
|
||||
-- Step 1 get lanes
|
||||
lanes = require("lanes").configure{
|
||||
nb_keepers = 4,
|
||||
}
|
||||
lanes = require("lanes").configure()
|
||||
multi.SystemThreads = {}
|
||||
multi.isMainThread = true
|
||||
|
||||
@@ -63,7 +61,7 @@ local livingThreads = {}
|
||||
function THREAD:newFunction(func, holdme)
|
||||
return thread:newFunctionBase(function(...)
|
||||
return multi:newSystemThread("TempSystemThread",func,...)
|
||||
end, holdme)()
|
||||
end, holdme, multi.SFUNCTION)()
|
||||
end
|
||||
|
||||
function multi:newSystemThread(name, func, ...)
|
||||
@@ -143,7 +141,9 @@ function multi:newSystemThread(name, func, ...)
|
||||
return c
|
||||
end
|
||||
|
||||
THREAD.newSystemThread = multi.newSystemThread
|
||||
THREAD.newSystemThread = function(...)
|
||||
multi:newSystemThread(...)
|
||||
end
|
||||
|
||||
function multi.InitSystemThreadErrorHandler()
|
||||
if started == true then
|
||||
|
||||
Reference in New Issue
Block a user