Working on getting pseudoThreading tests to work
This commit is contained in:
parent
ad929da484
commit
ef7464f70d
3
init.lua
3
init.lua
@ -1423,7 +1423,7 @@ function thread:newFunctionBase(generator, holdme, TYPE)
|
||||
end
|
||||
}
|
||||
t.OnDeath(function(...) temp.OnReturn:Fire(...) end)
|
||||
t.OnError(function(self,err) temp.OnError:Fire(err) end)
|
||||
t.OnError(function(self,err) temp.OnError:Fire(err) temp.OnError(multi.error) end)
|
||||
t.linkedFunction = temp
|
||||
t.statusconnector = temp.OnStatus
|
||||
return temp
|
||||
@ -1885,6 +1885,7 @@ function multi:newService(func) -- Priority managed threads
|
||||
end)
|
||||
|
||||
th.OnError = c.OnError -- use the threads onerror as our own
|
||||
th.OnError(multi.error)
|
||||
|
||||
function c.Destroy()
|
||||
th:kill()
|
||||
|
||||
@ -207,9 +207,9 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
local jid = table.remove(dat, 1)
|
||||
local args = table.remove(dat, 1)
|
||||
queueReturn:push{jid, funcs[name](args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]), queue}
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
end
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
thread:newThread("DoAllHandler",function()
|
||||
while true do
|
||||
local dat = thread.hold(function()
|
||||
@ -225,7 +225,7 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
end
|
||||
end
|
||||
end
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
thread:newThread("IdleHandler",function()
|
||||
while true do
|
||||
thread.hold(function()
|
||||
@ -233,9 +233,9 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
end)
|
||||
THREAD.sleep(.01)
|
||||
end
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
multi:mainloop()
|
||||
end,i).OnError(multi.error)
|
||||
end,i)
|
||||
end
|
||||
|
||||
function c:Hold(opt)
|
||||
|
||||
@ -130,6 +130,7 @@ function multi:newSystemThread(name, func, ...)
|
||||
c.OnDeath = multi:newConnection()
|
||||
c.OnError = multi:newConnection()
|
||||
GLOBAL["__THREADS__"] = livingThreads
|
||||
c.OnError(multi.error)
|
||||
|
||||
if self.isActor then
|
||||
self:create(c)
|
||||
|
||||
@ -172,6 +172,7 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
multi:newSystemThread("JobQueue_"..jqc.."_worker_"..i,function(jqc)
|
||||
local multi, thread = require("multi"):init()
|
||||
require("love.timer")
|
||||
love.timer.sleep(1)
|
||||
local clock = os.clock
|
||||
local funcs = THREAD.createTable("__JobQueue_"..jqc.."_table")
|
||||
local queue = THREAD.waitFor("__JobQueue_"..jqc.."_queue")
|
||||
@ -208,11 +209,12 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
local id = table.remove(dat,1)
|
||||
local tab = {funcs[name](multi.unpack(dat))}
|
||||
table.insert(tab,1,id)
|
||||
--local test = queueReturn.push
|
||||
queueReturn:push(tab)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
thread:newThread("Idler",function()
|
||||
while true do
|
||||
thread.yield()
|
||||
|
||||
@ -60,6 +60,8 @@ function multi:newSystemThread(name, func, ...)
|
||||
|
||||
table.insert(threads, c)
|
||||
|
||||
c.OnError(multi.error)
|
||||
|
||||
if self.isActor then
|
||||
self:create(c)
|
||||
else
|
||||
|
||||
@ -300,7 +300,7 @@ function multi:newSystemThreadedConnection(name)
|
||||
-- This shouldn't be the case
|
||||
end
|
||||
end
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
return self
|
||||
end
|
||||
|
||||
@ -377,7 +377,7 @@ function multi:newSystemThreadedConnection(name)
|
||||
c.proxy_conn:Fire(multi.unpack(item[2]))
|
||||
end
|
||||
end
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
--- ^^^ This will only exist in the init thread
|
||||
|
||||
THREAD.package(name,c)
|
||||
|
||||
@ -104,6 +104,8 @@ function multi:newSystemThread(name, func, ...)
|
||||
c.stab.returns = nil
|
||||
end
|
||||
end)
|
||||
|
||||
c.OnError(multi.error)
|
||||
|
||||
if self.isActor then
|
||||
self:create(c)
|
||||
|
||||
@ -210,7 +210,7 @@ local function init_chronos()
|
||||
thread.yield()
|
||||
priorityManager.run()
|
||||
end
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
end
|
||||
|
||||
if chronos then
|
||||
|
||||
@ -35,15 +35,16 @@ end
|
||||
|
||||
function multi:newSystemThreadedQueue(name)
|
||||
local c = {}
|
||||
c.data = {}
|
||||
c.Type = multi.registerType("s_queue")
|
||||
function c:push(v)
|
||||
table.insert(self,v)
|
||||
end
|
||||
function c:pop()
|
||||
return table.remove(self,1)
|
||||
return table.remove(self.data,1)
|
||||
end
|
||||
function c:peek()
|
||||
return self[1]
|
||||
return self.data[1]
|
||||
end
|
||||
function c:init()
|
||||
return self
|
||||
@ -156,6 +157,7 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
end)
|
||||
for i=1,c.cores do
|
||||
multi:newSystemThread("JobQueue_"..jqc.."_worker_"..i,function(jqc)
|
||||
local GLOBAL, THREAD = require("multi.integration.pseudoManager"):init()
|
||||
local multi, thread = require("multi"):init()
|
||||
local clock = os.clock
|
||||
local funcs = THREAD.waitFor("__JobQueue_"..jqc.."_table")
|
||||
@ -197,7 +199,7 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
thread:newThread("Idler",function()
|
||||
while true do
|
||||
thread.yield()
|
||||
|
||||
@ -92,6 +92,7 @@ function multi:newSystemThread(name, func, ...)
|
||||
|
||||
local th = thread:newISOThread(name, func, env, ...)
|
||||
th.Type = multi.registerType("s_thread", "pseudoThreads")
|
||||
th.OnError(multi.error)
|
||||
|
||||
id = id + 1
|
||||
|
||||
|
||||
@ -92,6 +92,8 @@ function multi:newProxy(list)
|
||||
local sref = table.remove(data, 1)
|
||||
local ret
|
||||
|
||||
print(_G[list[0]], func)
|
||||
|
||||
if sref then
|
||||
ret = {_G[list[0]][func](_G[list[0]], multi.unpack(data))}
|
||||
else
|
||||
@ -115,7 +117,7 @@ function multi:newProxy(list)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
return self
|
||||
else
|
||||
local function copy(obj)
|
||||
@ -143,6 +145,7 @@ function multi:newProxy(list)
|
||||
setmetatable(v[2],getmetatable(multi:newConnection()))
|
||||
else
|
||||
self[v] = thread:newFunction(function(self,...)
|
||||
multi.print("Pushing: " .. v)
|
||||
if self == me then
|
||||
me.send:push({v, true, ...})
|
||||
else
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package.path = "../?/init.lua;../?.lua;"..package.path
|
||||
require("runtests")
|
||||
require("threadtests")
|
||||
-- require("runtests")
|
||||
-- require("threadtests")
|
||||
-- Allows you to run "love tests" which runs the tests
|
||||
|
||||
multi, thread = require("multi"):init()
|
||||
GLOBAL, THREAD = require("multi.integration.loveManager"):init()
|
||||
|
||||
|
||||
function love.update()
|
||||
multi:uManager()
|
||||
end
|
||||
@ -1,4 +1,5 @@
|
||||
package.path = "../?/init.lua;../?.lua;"..package.path
|
||||
package.path = "D:/VSCWorkspace/?/init.lua;D:/VSCWorkspace/?.lua;"..package.path
|
||||
package.cpath = "C:/luaInstalls/lua5.4/lib/lua/5.4/?/core.dll;" .. package.cpath
|
||||
multi, thread = require("multi"):init{error=true,warning=true,print=true}--{priority=true}
|
||||
proc = multi:newProcessor("Thread Test",true)
|
||||
local LANES, LOVE, PSEUDO = 1, 2, 3
|
||||
@ -37,12 +38,12 @@ THREAD.setENV({
|
||||
})
|
||||
|
||||
multi:newThread("Scheduler Thread",function()
|
||||
multi:newThread(function()
|
||||
thread.sleep(30)
|
||||
print("Timeout tests took longer than 30 seconds")
|
||||
multi:Stop()
|
||||
os.exit(1)
|
||||
end)
|
||||
-- multi:newThread(function()
|
||||
-- thread.sleep(30)
|
||||
-- print("Timeout tests took longer than 30 seconds")
|
||||
-- multi:Stop()
|
||||
-- os.exit(1)
|
||||
-- end)
|
||||
queue = multi:newSystemThreadedQueue("Test_Queue"):init()
|
||||
|
||||
multi:newSystemThread("Test_Thread_0", function()
|
||||
@ -201,7 +202,7 @@ multi:newThread("Scheduler Thread",function()
|
||||
print(THREAD_NAME, "Got loop...")
|
||||
end)
|
||||
multi:mainloop()
|
||||
end, tloop:getTransferable()).OnError(multi.error)
|
||||
end, tloop:getTransferable())
|
||||
|
||||
multi.print("tloop", tloop.Type)
|
||||
multi.print("tloop.OnLoop", tloop.OnLoop.Type)
|
||||
@ -213,12 +214,13 @@ multi:newThread("Scheduler Thread",function()
|
||||
thread.hold(tloop.OnLoop)
|
||||
multi.print("Held on proxy connection... twice")
|
||||
proxy_test = true
|
||||
end).OnError(multi.error)
|
||||
end)
|
||||
|
||||
thread:newThread(function()
|
||||
print("While Test!")
|
||||
while true do
|
||||
thread.hold(tloop.OnLoop)
|
||||
print(THREAD_NAME,"Loopy")
|
||||
print(THREAD_NAME,"Local Loopy")
|
||||
end
|
||||
end)
|
||||
|
||||
@ -228,7 +230,7 @@ multi:newThread("Scheduler Thread",function()
|
||||
|
||||
t, val = thread.hold(function()
|
||||
return proxy_test
|
||||
end,{sleep=5})
|
||||
end--[[,{sleep=5}]]) -- No timeouts
|
||||
|
||||
if val == multi.TIMEOUT then
|
||||
multi.error("SystemThreadedProcessor/Proxies: Failed")
|
||||
@ -242,7 +244,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)
|
||||
end)
|
||||
|
||||
multi.OnExit(function(err_or_errorcode)
|
||||
print("Error Code: ", err_or_errorcode)
|
||||
|
||||
1102
tests/vscode-debuggee.lua
Normal file
1102
tests/vscode-debuggee.lua
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user