Working on systemthreadedprocess, and experimental newProxy for threading

This commit is contained in:
2023-05-14 00:52:35 -04:00
parent 5caa90f6c7
commit 160c72d2f3
9 changed files with 239 additions and 97 deletions
+22 -12
View File
@@ -22,8 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]
local multi, thread = require("multi"):init()
if not (GLOBAL and THREAD) then
local GLOBAL, THREAD = multi.integration.GLOBAL,multi.integration.THREAD
GLOBAL, THREAD = multi.integration.GLOBAL,multi.integration.THREAD
else
lanes = require("lanes")
end
@@ -54,17 +55,24 @@ function multi:newSystemThreadedTable(name)
local c = {}
c.link = lanes.linda()
c.Name = name
setmetatable(c,{
-- function c:getIndex()
-- return c.link:dump()
-- end
function c:init()
return self
end
setmetatable(c,{
__index = function(t,k)
return c.link:get(k)
end,
__newindex = function(t,k,v)
c.link:set(k,v)
c.link:set(k, v)
end
})
function c:init()
return self
end
GLOBAL[name or "_"] = c
return c
end
@@ -134,7 +142,7 @@ function multi:newSystemThreadedJobQueue(n)
end)
for i=1,c.cores do
multi:newSystemThread("SystemThreadedJobQueue",function(queue)
local multi,thread = require("multi"):init()
local multi, thread = require("multi"):init()
local idle = os.clock()
local clock = os.clock
local ref = 0
@@ -145,12 +153,14 @@ function multi:newSystemThreadedJobQueue(n)
return queueJob:pop()
end)
idle = clock()
local name = table.remove(dat,1)
local jid = table.remove(dat,1)
local args = table.remove(dat,1)
queueReturn:push{jid, funcs[name](unpack(args)),queue}
thread:newThread("test",function()
local name = table.remove(dat, 1)
local jid = table.remove(dat, 1)
local args = table.remove(dat, 1)
queueReturn:push{jid, funcs[name](unpack(args)), queue}
end)
end
end)
end).OnError(multi.error)
thread:newThread("DoAllHandler",function()
while true do
local dat = thread.hold(function()
+2
View File
@@ -97,6 +97,7 @@ function multi:newSystemThread(name, func, ...)
},function(...)
multi, thread = require("multi"):init(multi_settings)
require("multi.integration.lanesManager.extensions")
require("multi.integration.sharedExtensions")
local has_error = true
returns = {pcall(func, ...)}
return_linda:set("returns", returns)
@@ -179,6 +180,7 @@ multi.integration = {} -- for module creators
multi.integration.GLOBAL = GLOBAL
multi.integration.THREAD = THREAD
require("multi.integration.lanesManager.extensions")
require("multi.integration.sharedExtensions")
return {
init = function()
return GLOBAL, THREAD
+2 -4
View File
@@ -122,13 +122,11 @@ local function INIT(__GlobalLinda, __SleepingLinda, __StatusLinda, __Console)
})
function THREAD.setENV(env, name)
name = name or "__env"
GLOBAL[name] = env
GLOBAL[name or "__env"] = env
end
function THREAD.getENV(name)
name = name or "__env"
return GLOBAL[name]
return GLOBAL[name or "__env"]
end
function THREAD.exposeENV(name)