diff options
| author | ruki <[email protected]> | 2020-02-04 23:10:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-07 22:45:56 +0800 |
| commit | 7cf854042808382beff5e3ceaaa430f8369d980c (patch) | |
| tree | 867e20659d3ffcf9e1a9d484a12cd2a9d65eb3b0 /tests/modules/scheduler/test.lua | |
| parent | 9d205f5db11e184073990883e1a7b94d1d4b783b (diff) | |
improve co_group_begin
Diffstat (limited to 'tests/modules/scheduler/test.lua')
| -rw-r--r-- | tests/modules/scheduler/test.lua | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/modules/scheduler/test.lua b/tests/modules/scheduler/test.lua index d6e090c6a..de62e47ed 100644 --- a/tests/modules/scheduler/test.lua +++ b/tests/modules/scheduler/test.lua @@ -7,11 +7,12 @@ function test_runjobs(t) t:are_equal(a, "xmake!") count = count + 1 end - local cotasks = {} - for i = 1, 100 do - table.insert(cotasks, scheduler.co_start(task, "xmake!")) - end - scheduler.co_waitexit(cotasks) + scheduler.co_group_begin("test", function () + for i = 1, 100 do + scheduler.co_start(task, "xmake!") + end + end) + scheduler.co_group_wait("test") t:are_equal(count, 100) end @@ -37,10 +38,11 @@ function test_yield(t) scheduler.co_yield() count = count + 1 end - local cotasks = {} - for i = 1, 10 do - table.insert(cotasks, scheduler.co_start(task)) - end - scheduler.co_waitexit(cotasks) + scheduler.co_group_begin("test", function () + for i = 1, 10 do + scheduler.co_start(task) + end + end) + scheduler.co_group_wait("test") t:are_equal(count, 10) end |
