From ca16db30058d8a512d73a7bee28e57f72de4c338 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 18 Mar 2024 23:44:06 +0800 Subject: improve progress --- tests/modules/scheduler/runjobs.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/modules/scheduler/runjobs.lua b/tests/modules/scheduler/runjobs.lua index d84f23152..4e2a98cc0 100644 --- a/tests/modules/scheduler/runjobs.lua +++ b/tests/modules/scheduler/runjobs.lua @@ -2,12 +2,12 @@ import("core.base.scheduler") import("private.async.jobpool") import("async.runjobs") -function _jobfunc(index, total) +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, dt: %d ms", scheduler.co_running(), index, total, dt) + print("%s: run job (%d/%d) end, progress: %s, dt: %d ms", scheduler.co_running(), index, total, opt.progress, dt) end function main() @@ -22,16 +22,16 @@ function main() -- test jobs print("==================================== test jobs ====================================") local jobs = jobpool.new() - local root = jobs:addjob("job/root", function (idx, total) - _jobfunc(idx, total) + local root = jobs:addjob("job/root", function (index, total, opt) + _jobfunc(index, total, opt) end) for i = 1, 3 do - local job = jobs:addjob("job/" .. i, function (idx, total) - _jobfunc(idx, total) + local job = jobs:addjob("job/" .. i, function (index, total, opt) + _jobfunc(index, total, opt) end, {rootjob = root}) for j = 1, 50 do - jobs:addjob("job/" .. i .. "/" .. j, function (idx, total) - _jobfunc(idx, total) + jobs:addjob("job/" .. i .. "/" .. j, function (index, total, opt) + _jobfunc(index, total, opt) end, {rootjob = job}) end end -- cgit v1.3.1