summaryrefslogtreecommitdiff
path: root/tests/modules/async/run_callback.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-04-09 22:09:38 +0800
committerGitHub <[email protected]>2025-04-09 22:09:38 +0800
commit48275f817475b398b649f55054e2e60200dcd052 (patch)
tree2e943d22fd4adceb8f0c6e53dbee610ce217f7c3 /tests/modules/async/run_callback.lua
parentd9a5ab70746010c846b815c2b5e14447d268b96f (diff)
parent699e40f3e45469b3597f5fa24ad6bb2c922b8a4b (diff)
Merge pull request #6209 from xmake-io/prepare
Add build jobgraph support
Diffstat (limited to 'tests/modules/async/run_callback.lua')
-rw-r--r--tests/modules/async/run_callback.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/modules/async/run_callback.lua b/tests/modules/async/run_callback.lua
new file mode 100644
index 000000000..21e75014b
--- /dev/null
+++ b/tests/modules/async/run_callback.lua
@@ -0,0 +1,19 @@
+import("core.base.scheduler")
+import("async.runjobs")
+
+function _jobfunc(index, total, opt)
+ print("%s: run job (%d/%d)", scheduler.co_running(), index, total)
+ local dt = os.mclock()
+ os.sleep(1000)
+ dt = os.mclock() - dt
+ print("%s: run job (%d/%d) end, progress: %s, dt: %d ms", scheduler.co_running(), index, total, opt.progress, dt)
+end
+
+function main()
+ print("==================================== test callback ====================================")
+ local t = os.mclock()
+ runjobs("test", _jobfunc, {total = 100, comax = 6, timeout = 1000, timer = function (running_jobs_indices)
+ print("%s: timeout (%d ms), running: %s", scheduler.co_running(), os.mclock() - t, table.concat(running_jobs_indices, ","))
+ end})
+end
+