summaryrefslogtreecommitdiff
path: root/tests/modules/thread/sleep.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-04-16 22:32:58 +0800
committerruki <[email protected]>2025-08-28 11:35:53 +0800
commitd985de5de38fb0d041f8e9182c076575603b5b4f (patch)
treee3f4d6fa47335e74285ce5888495190717b00383 /tests/modules/thread/sleep.lua
parentd8862afe89a16a9f4ad0a21188bd174b3c81a935 (diff)
improve api and tests
Diffstat (limited to 'tests/modules/thread/sleep.lua')
-rw-r--r--tests/modules/thread/sleep.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/modules/thread/sleep.lua b/tests/modules/thread/sleep.lua
index 1890278b3..4dc350cd3 100644
--- a/tests/modules/thread/sleep.lua
+++ b/tests/modules/thread/sleep.lua
@@ -1,17 +1,20 @@
import("core.thread.thread")
function callback(id)
- print("%s: %d ..", thread.running(), id)
+ print("%s: %d starting ..", thread.running(), id)
local dt = os.mclock()
- os.sleep(1000)
+ for i = 1, 10 do
+ print("%s: %d", thread.running(), i)
+ os.sleep(1000)
+ end
dt = os.mclock() - dt
print("%s: %d end, dt: %d ms", thread.running(), id, dt)
end
function main()
- for i = 1, 10 do
- thread.start_named("thread_" .. i, callback, i)
- end
- --thread.wait()
+ local t0 = thread.start_named("thread_0", callback, 0)
+ local t1 = thread.start_named("thread_1", callback, 1)
+ thread.wait(t0, -1)
+ thread.wait(t1, -1)
end