mirror of
https://github.com/rayaman/multi.git
synced 2026-09-04 23:17:35 -04:00
Fixing issues with the new thread scheduler, nested yields need handling
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
function connectionThreadTests(multi,thread)
|
||||
print("Starting Connection and Thread tests!")
|
||||
print("Current Thread:",thread.getRunningThread())
|
||||
func = thread:newFunction(function(count)
|
||||
print("Starting Status test: ",count)
|
||||
print("Current Thread:",thread.getRunningThread().thread)
|
||||
local a = 0
|
||||
while true do
|
||||
a = a + 1
|
||||
@@ -14,8 +17,12 @@ function connectionThreadTests(multi,thread)
|
||||
local ret2 = func(15)
|
||||
local ret3 = func(20)
|
||||
local s1,s2,s3 = 0,0,0
|
||||
ret.OnError(function(...)
|
||||
print("Error:",...)
|
||||
end)
|
||||
ret.OnStatus(function(part,whole)
|
||||
s1 = math.ceil((part/whole)*1000)/10
|
||||
print(s1)
|
||||
end)
|
||||
ret2.OnStatus(function(part,whole)
|
||||
s2 = math.ceil((part/whole)*1000)/10
|
||||
@@ -23,14 +30,22 @@ function connectionThreadTests(multi,thread)
|
||||
ret3.OnStatus(function(part,whole)
|
||||
s3 = math.ceil((part/whole)*1000)/10
|
||||
end)
|
||||
local err, timeout = thread.hold(ret2.OnReturn + ret.OnReturn + ret3.OnReturn,{sleep=3})
|
||||
ret.OnReturn(function()
|
||||
print("Done")
|
||||
end)
|
||||
local err, timeout = thread.hold(ret.OnReturn + ret2.OnReturn + ret3.OnReturn,{sleep=3})
|
||||
print(err,timeout)
|
||||
for i,v in pairs(err) do
|
||||
print(i,v)
|
||||
end
|
||||
os.exit()
|
||||
if s1 == 100 and s2 == 100 and s3 == 100 then
|
||||
print("Threads: Ok")
|
||||
else
|
||||
print("Threads on status error")
|
||||
print("Threads OnStatus or thread.hold(conn) Error!")
|
||||
end
|
||||
if timeout then
|
||||
print("Threads or Connection error!")
|
||||
print("Threads or Connection Error!")
|
||||
else
|
||||
print("Connection Test 1: Ok")
|
||||
end
|
||||
|
||||
@@ -7,12 +7,12 @@ function objectTests(multi,thread)
|
||||
end)
|
||||
multi:newTStep(1,10,1,.1):OnStep(function(t)
|
||||
tsteps = tsteps + 1
|
||||
end):OnEnd(function(step)
|
||||
end).OnEnd(function(step)
|
||||
step:Destroy()
|
||||
end)
|
||||
multi:newStep(1,10):OnStep(function(s)
|
||||
steps = steps + 1
|
||||
end):OnEnd(function(step)
|
||||
end).OnEnd(function(step)
|
||||
step:Destroy()
|
||||
end)
|
||||
local loop = multi:newLoop(function(l)
|
||||
@@ -28,6 +28,7 @@ function objectTests(multi,thread)
|
||||
return alarms
|
||||
end)
|
||||
event.OnEvent(function(evnt)
|
||||
evnt:Destroy()
|
||||
events = true
|
||||
print("Alarms: Ok")
|
||||
print("Events: Ok")
|
||||
@@ -37,6 +38,6 @@ function objectTests(multi,thread)
|
||||
if tloops > 10 then print("TLoops: Ok") else print("TLoops: Bad!") end
|
||||
if updaters > 100 then print("Updaters: Ok") else print("Updaters: Bad!") end
|
||||
end)
|
||||
thread.hold(event.OnEvent)
|
||||
thread.hold(event.OnEvent)
|
||||
end
|
||||
return objectTests
|
||||
+12
-5
@@ -18,15 +18,22 @@ package.path="./?.lua;../?.lua;../?/init.lua;../?.lua;../?/?/init.lua;"..package
|
||||
local multi, thread = require("multi"):init{priority=true}
|
||||
local good = false
|
||||
runTest = thread:newFunction(function()
|
||||
local objects = multi:newProcessor("Basic Object Tests")
|
||||
objects.Start()
|
||||
require("tests/objectTests")(objects,thread)
|
||||
objects.Stop()
|
||||
-- thread.sleep(1)
|
||||
-- local objects = multi:newProcessor("Basic Object Tests")
|
||||
-- objects.OnError(function(...)
|
||||
-- print("Error: ",...)
|
||||
-- end)
|
||||
-- objects.Start()
|
||||
-- require("tests/objectTests")(objects,thread)
|
||||
-- objects.Stop()
|
||||
local conn_thread = multi:newProcessor("Connection/Thread Tests")
|
||||
conn_thread.OnError(function(...)
|
||||
print("Error: ",...)
|
||||
end)
|
||||
conn_thread.Start()
|
||||
require("tests/connectionTest")(conn_thread,thread)
|
||||
conn_thread.Stop()
|
||||
print(multi:getTasksDetails())
|
||||
--print(multi:getTasksDetails())
|
||||
os.exit()
|
||||
end)
|
||||
runTest().OnError(function(...)
|
||||
|
||||
Reference in New Issue
Block a user