summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-12-15 15:30:13 +0800
committerruki <[email protected]>2019-12-15 15:33:26 +0800
commitf0cee734ed73e82364c07158b680d1399464a13e (patch)
treee27ac61d70147ef203d7a28e739dab051d751890
parentf72910c44225935a42b73b2b986c26f958efe5f7 (diff)
fix scheduler tests
-rw-r--r--tests/modules/scheduler/test.lua4
-rw-r--r--tests/modules/socket/sched_tcp/echo_client.lua3
-rw-r--r--tests/modules/socket/sched_tcp/file_client.lua3
-rw-r--r--xmake/core/base/scheduler.lua2
4 files changed, 2 insertions, 10 deletions
diff --git a/tests/modules/scheduler/test.lua b/tests/modules/scheduler/test.lua
index cf87d2588..f794c8a3e 100644
--- a/tests/modules/scheduler/test.lua
+++ b/tests/modules/scheduler/test.lua
@@ -10,6 +10,7 @@ function test_runjobs(t)
for i = 1, 100 do
scheduler.co_start(task, "xmake!")
end
+ scheduler.runloop()
t:are_equal(count, 100)
end
@@ -22,9 +23,6 @@ function test_sleep(t)
dt = os.mclock() - dt
t:require(dt > 100 and dt < 1000)
count = count + 1
- if count == 3 then
- scheduler.stop()
- end
end
for i = 1, 3 do
scheduler.co_start(task)
diff --git a/tests/modules/socket/sched_tcp/echo_client.lua b/tests/modules/socket/sched_tcp/echo_client.lua
index af40a085d..f9c993729 100644
--- a/tests/modules/socket/sched_tcp/echo_client.lua
+++ b/tests/modules/socket/sched_tcp/echo_client.lua
@@ -17,9 +17,6 @@ function _session(addr, port)
end
print("%s: send ok, count: %d!", sock, count)
sock:close()
- if scheduler.co_count() == 1 then
- scheduler.stop()
- end
end
function main(count)
diff --git a/tests/modules/socket/sched_tcp/file_client.lua b/tests/modules/socket/sched_tcp/file_client.lua
index 5dda4be6d..522d05353 100644
--- a/tests/modules/socket/sched_tcp/file_client.lua
+++ b/tests/modules/socket/sched_tcp/file_client.lua
@@ -31,9 +31,6 @@ function _session(addr, port)
end
print("%s: recv ok, size: %d, #data: %d!", sock, recv, data and data:size() or 0)
sock:close()
- if scheduler.co_count() == 1 then
- scheduler.stop()
- end
end
function main(count)
diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua
index 486f04dc0..eefb46694 100644
--- a/xmake/core/base/scheduler.lua
+++ b/xmake/core/base/scheduler.lua
@@ -397,7 +397,7 @@ function scheduler:runloop()
local ok = true
local errors = nil
local timeout = -1
- while self._STARTED do
+ while self._STARTED and self:co_count() > 0 do
-- get the next timeout
timeout = self:_timer():delay() or 1000