diff --git a/integration/debugManager/init.lua b/integration/debugManager/init.lua index bb6f24b..c467547 100644 --- a/integration/debugManager/init.lua +++ b/integration/debugManager/init.lua @@ -38,22 +38,62 @@ end .. multi:newConnection() local creation_hook, destruction_hook local types -local processes = {} +local objects = {} creation_hook = function(obj, process) types = multi:getTypes() if obj.Type == multi.PROCESS and not dbg.processors[obj] then obj.OnObjectCreated(creation_hook) obj.OnObjectDestroyed(destruction_hook) - dbg.processors[obj] = {} end + + table.insert(objects, obj) + dbg.OnObjectCreated:Fire(obj, process) end destruction_hook = function(obj, process) + for i = 1, #objects do + if objects[i] == obj then + table.remove(objects, i) + break + end + end dbg.OnObjectDestroyed:Fire(obj, process) end +function dbg:getObjects(typ) + if type(typ) == "string" then + local objs = {} + for i = 1, #objects do + if objects[i].Type == typ then + objs[#objs+1] = objects[i] + end + end + return objs + elseif type(typ) == "table" then -- Process + local objs = {} + for i = 1, #objects do + if objects[i].Parent == typ then + objs[#objs+1] = objects[i] + end + end + return objs + elseif type(typ) == "function" then + local objs = {} + -- Keep objects local/private, return true to add to list, false to reject, "break" to break loop + for i = 1, #objects do + local ret = typ(objects[i]) + if ret then + objs[#objs+1] = objects[i] + elseif ret == "break" then + break + end + end + return objs + end +end + local debug_stats = {} local tmulti = multi:getThreadManagerProcess() diff --git a/integration/sharedExtensions/init.lua b/integration/sharedExtensions/init.lua index 7d4af48..a5b7caa 100644 --- a/integration/sharedExtensions/init.lua +++ b/integration/sharedExtensions/init.lua @@ -184,10 +184,10 @@ 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) diff --git a/lovethreads/multi b/lovethreads/multi deleted file mode 120000 index b870225..0000000 --- a/lovethreads/multi +++ /dev/null @@ -1 +0,0 @@ -../ \ No newline at end of file diff --git a/lovethreads/multi b/lovethreads/multi new file mode 100644 index 0000000..b870225 --- /dev/null +++ b/lovethreads/multi @@ -0,0 +1 @@ +../ \ No newline at end of file diff --git a/tests/threadtests.lua b/tests/threadtests.lua index dcf3a8b..bb5754b 100644 --- a/tests/threadtests.lua +++ b/tests/threadtests.lua @@ -180,16 +180,6 @@ multi:newThread("Scheduler Thread",function() -- end -- multi.success("SystemThreadedConnections: Ok") local proxy_test = false - multi:newThread(function() - t, val = thread.hold(function() - return proxy_test - end,{sleep=5}) - if val == multi.TIMEOUT then - multi.error("SystemThreadedProcessor/Proxies: Failed") - end - thread.sleep(1) - os.exit(1) - end) local stp = multi:newSystemThreadedProcessor(5) local tloop = stp:newTLoop(function() @@ -251,6 +241,7 @@ multi:newThread("Scheduler Thread",function() we_good = true multi:Stop() -- Needed in love2d tests to stop the main runner + os.exit(0) end).OnError(multi.error) multi.OnExit(function(err_or_errorcode)