mirror of
https://github.com/rayaman/multi.git
synced 2026-09-05 07:27:35 -04:00
Working on new type system, planning out debugmanager
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
local multi, thread = require("multi"):init()
|
||||
|
||||
multi.defaultSettings.debugging = true
|
||||
|
||||
local dbg = {}
|
||||
|
||||
local creation_hook
|
||||
@@ -11,6 +13,8 @@ creation_hook = function(obj, process)
|
||||
end
|
||||
end
|
||||
|
||||
local debug_stats = {}
|
||||
|
||||
local tmulti = multi:getThreadManagerProcess()
|
||||
multi.OnObjectCreated(creation_hook)
|
||||
tmulti.OnObjectCreated(creation_hook)
|
||||
@@ -32,6 +36,4 @@ tmulti.OnObjectCreated(creation_hook)
|
||||
multi.SERVICE = "service"
|
||||
multi.PROXY = "proxy"
|
||||
multi.THREADEDFUNCTION = "threaded_function"
|
||||
]]
|
||||
|
||||
return dbg
|
||||
]]
|
||||
@@ -34,7 +34,7 @@ function multi:newSystemThreadedQueue(name)
|
||||
local c = {}
|
||||
c.Name = name
|
||||
c.linda = lanes.linda()
|
||||
c.Type = multi.SQUEUE
|
||||
c.Type = multi.registerType("s_queue")
|
||||
|
||||
function c:push(v)
|
||||
self.linda:send("Q", v)
|
||||
@@ -81,7 +81,7 @@ function multi:newSystemThreadedTable(name)
|
||||
local c = {}
|
||||
c.link = lanes.linda()
|
||||
c.Name = name
|
||||
c.Type = multi.STABLE
|
||||
c.Type = multi.registerType("s_table")
|
||||
|
||||
function c:init()
|
||||
return self
|
||||
@@ -121,7 +121,7 @@ end
|
||||
function multi:newSystemThreadedJobQueue(n)
|
||||
local c = {}
|
||||
c.cores = n or THREAD.getCores()*2
|
||||
c.Type = multi.SJOBQUEUE
|
||||
c.Type = multi.registerType("s_jobqueue")
|
||||
c.OnJobCompleted = multi:newConnection()
|
||||
local funcs = multi:newSystemThreadedTable()
|
||||
local queueJob = multi:newSystemThreadedQueue()
|
||||
@@ -250,7 +250,7 @@ end
|
||||
function multi:newSystemThreadedConnection(name)
|
||||
local name = name or multi.randomString(16)
|
||||
local c = {}
|
||||
c.Type = multi.SCONNECTION
|
||||
c.Type = multi.registerType("s_connection")
|
||||
c.CONN = 0x00
|
||||
c.TRIG = 0x01
|
||||
c.PING = 0x02
|
||||
|
||||
@@ -61,7 +61,7 @@ local livingThreads = {}
|
||||
function THREAD:newFunction(func, holdme)
|
||||
return thread:newFunctionBase(function(...)
|
||||
return multi:newSystemThread("TempSystemThread",func,...)
|
||||
end, holdme, multi.SFUNCTION)()
|
||||
end, holdme, multi.registerType("s_function"))()
|
||||
end
|
||||
|
||||
function multi:newSystemThread(name, func, ...)
|
||||
@@ -75,7 +75,7 @@ function multi:newSystemThread(name, func, ...)
|
||||
c.loadString = {"base","package","os","io","math","table","string","coroutine"}
|
||||
livingThreads[count] = {true, name}
|
||||
c.returns = return_linda
|
||||
c.Type = multi.STHREAD
|
||||
c.Type = multi.registerType("s_thread")
|
||||
c.creationTime = os.clock()
|
||||
c.alive = true
|
||||
c.priority = THREAD.Priority_Normal
|
||||
|
||||
@@ -10,7 +10,7 @@ function multi:newSystemThreadedQueue(name)
|
||||
local c = {}
|
||||
|
||||
c.Name = name
|
||||
c.Type = multi.SQUEUE
|
||||
c.Type = multi.registerType("s_queue")
|
||||
c.chan = love.thread.newChannel()
|
||||
|
||||
function c:push(dat)
|
||||
@@ -54,7 +54,7 @@ function multi:newSystemThreadedTable(name)
|
||||
local c = {}
|
||||
|
||||
c.Name = name
|
||||
c.Type = multi.STABLE
|
||||
c.Type = multi.registerType("s_table")
|
||||
c.tab = THREAD.createTable(name)
|
||||
|
||||
function c:init()
|
||||
@@ -104,7 +104,7 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
|
||||
c.cores = n or THREAD.getCores()
|
||||
c.registerQueue = {}
|
||||
c.Type = multi.SJOBQUEUE
|
||||
c.Type = multi.registerType("s_jobqueue")
|
||||
c.funcs = THREAD.createTable("__JobQueue_"..jqc.."_table")
|
||||
c.queue = multi:newSystemThreadedQueue("__JobQueue_"..jqc.."_queue")
|
||||
c.queueReturn = multi:newSystemThreadedQueue("__JobQueue_"..jqc.."_queueReturn")
|
||||
|
||||
@@ -33,6 +33,9 @@ _G.THREAD_ID = 0
|
||||
local multi, thread = require("multi"):init()
|
||||
local GLOBAL, THREAD = require("multi.integration.loveManager.threads"):init()
|
||||
|
||||
multi.registerType("s_function")
|
||||
multi.registerType("s_thread")
|
||||
|
||||
multi.integration = {}
|
||||
multi.isMainThread = true
|
||||
local threads = {}
|
||||
|
||||
@@ -102,7 +102,7 @@ priorityManager.uManager = function(self)
|
||||
end
|
||||
|
||||
local function processHook(obj, proc)
|
||||
if obj.Type == multi.PROCESS or not(obj.IsAnActor) then return end
|
||||
if obj.Type == multi.registerType("process", "processes") or not(obj.IsAnActor) then return end
|
||||
obj.__restoreProc = proc
|
||||
obj.__profiling = {}
|
||||
obj:reallocate(priorityManager)
|
||||
@@ -171,7 +171,7 @@ local function init()
|
||||
|
||||
function multi:setPriorityScheme(scheme)
|
||||
|
||||
if not self.Type == multi.PROCESS or not self.Type == multi.ROOTPROCESS then
|
||||
if not self.Type == multi.registerType("process", "processes") or not self.Type == multi.registerType("rootprocess") then
|
||||
multi.warn("You should only invoke setPriorityScheme on a processor object!")
|
||||
end
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ end
|
||||
|
||||
function multi:newSystemThreadedQueue(name)
|
||||
local c = {}
|
||||
c.Type = multi.registerType("s_queue")
|
||||
function c:push(v)
|
||||
table.insert(self,v)
|
||||
end
|
||||
@@ -64,6 +65,7 @@ end
|
||||
|
||||
function multi:newSystemThreadedTable(name)
|
||||
local c = {}
|
||||
c.Type = multi.registerType("s_table")
|
||||
function c:init()
|
||||
return self
|
||||
end
|
||||
@@ -88,7 +90,7 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
|
||||
c.cores = n or THREAD.getCores()
|
||||
c.registerQueue = {}
|
||||
c.Type = multi.SJOBQUEUE
|
||||
c.Type = multi.registerType("s_jobqueue")
|
||||
c.funcs = multi:newSystemThreadedTable("__JobQueue_"..jqc.."_table")
|
||||
c.queue = multi:newSystemThreadedQueue("__JobQueue_"..jqc.."_queue")
|
||||
c.queueReturn = multi:newSystemThreadedQueue("__JobQueue_"..jqc.."_queueReturn")
|
||||
|
||||
@@ -91,6 +91,7 @@ function multi:newSystemThread(name, func, ...)
|
||||
local GLOBAL, THREAD = activator.init(thread, env)
|
||||
|
||||
local th = thread:newISOThread(name, func, env, ...)
|
||||
th.Type = multi.registerType("s_thread", "pseudoThreads")
|
||||
|
||||
id = id + 1
|
||||
|
||||
@@ -104,7 +105,7 @@ THREAD.newSystemThread = multi.newSystemThread
|
||||
function THREAD:newFunction(func,holdme)
|
||||
return thread:newFunctionBase(function(...)
|
||||
return multi:newSystemThread("TempSystemThread",func,...)
|
||||
end,holdme)()
|
||||
end, holdme, multi.registerType("s_function", "pseudoFunctions"))()
|
||||
end
|
||||
|
||||
multi.print("Integrated Pesudo Threading!")
|
||||
|
||||
@@ -35,9 +35,9 @@ function multi:chop(obj)
|
||||
local list = {[0] = multi.randomString(12)}
|
||||
_G[list[0]] = obj
|
||||
for i,v in pairs(obj) do
|
||||
if type(v) == "function" or type(v) == "table" and v.Type == multi.THREADEDFUNCTION then
|
||||
if type(v) == "function" or type(v) == "table" and v.Type == multi.registerType("s_function") then
|
||||
table.insert(list, i)
|
||||
elseif type(v) == "table" and v.Type == multi.CONNECTOR then
|
||||
elseif type(v) == "table" and v.Type == multi.registerType("connector", "connections") then
|
||||
table.insert(list, {i, multi:newProxy(multi:chop(v)):init()})
|
||||
end
|
||||
end
|
||||
@@ -79,7 +79,7 @@ function multi:newProxy(list)
|
||||
self.recv = multi:newSystemThreadedQueue(self.name.."_R"):init()
|
||||
self.funcs = list
|
||||
self._funcs = copy(list)
|
||||
self.Type = multi.PROXY
|
||||
self.Type = multi.registerType("proxy", "proxies")
|
||||
self.TID = THREAD_ID
|
||||
|
||||
thread:newThread("Proxy_Handler_" .. multi.randomString(4), function()
|
||||
@@ -99,7 +99,7 @@ function multi:newProxy(list)
|
||||
end
|
||||
|
||||
for i = 1,#ret do
|
||||
if type(ret[i]) == "table" and ret[i].Type ~= nil and ret[i].Type ~= multi.PROXY then
|
||||
if type(ret[i]) == "table" and ret[i].Type ~= nil and ret[i].Type ~= multi.registerType("proxy", "proxies") then
|
||||
ret[i] = "\1PARENT_REF"
|
||||
end
|
||||
if type(ret[i]) == "table" and getmetatable(ret[i]) then
|
||||
@@ -133,7 +133,7 @@ function multi:newProxy(list)
|
||||
end
|
||||
self.send = THREAD.waitFor(self.name.."_S"):init()
|
||||
self.recv = THREAD.waitFor(self.name.."_R"):init()
|
||||
self.Type = multi.PROXY
|
||||
self.Type = multi.registerType("proxy", "proxies")
|
||||
for _,v in pairs(funcs) do
|
||||
if type(v) == "table" then
|
||||
-- We have a connection
|
||||
@@ -184,11 +184,14 @@ function multi:newProxy(list)
|
||||
cp.funcs = copy(self._funcs)
|
||||
cp.init = function(self)
|
||||
local multi, thread = require("multi"):init()
|
||||
if multi.integration then
|
||||
GLOBAL = multi.integration.GLOBAL
|
||||
THREAD = multi.integration.THREAD
|
||||
end
|
||||
-- if multi.integration then
|
||||
-- GLOBAL = multi.integration.GLOBAL
|
||||
-- THREAD = multi.integration.THREAD
|
||||
-- end
|
||||
local proxy = THREAD.waitFor(self.proxy_link)
|
||||
for i,v in pairs(proxy) do
|
||||
print("proxy",i,v)
|
||||
end
|
||||
proxy.funcs = self.funcs
|
||||
return proxy:init()
|
||||
end
|
||||
@@ -211,7 +214,7 @@ function multi:newSystemThreadedProcessor(cores)
|
||||
|
||||
setmetatable(c,{__index = multi})
|
||||
|
||||
c.Type = multi.SPROCESS
|
||||
c.Type = multi.registerType("s_process", "s_processes")
|
||||
c.threads = {}
|
||||
c.cores = cores or 8
|
||||
c.Name = name
|
||||
@@ -331,3 +334,4 @@ function multi:newSystemThreadedProcessor(cores)
|
||||
|
||||
return c
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user