diff options
| author | ruki <[email protected]> | 2025-11-21 00:45:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-21 11:28:51 +0800 |
| commit | 4627107fa7badf70828a6f569e4a8b8ba3d4160d (patch) | |
| tree | 909022a4ff14981d23cb28dd472926431ca86419 | |
| parent | 9447d6b4e5f1060f832cbae1807b95df40a0ddce (diff) | |
improve progress_refresh
| -rw-r--r-- | xmake/modules/async/runjobs.lua | 35 | ||||
| -rw-r--r-- | xmake/modules/private/action/build/target.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/private/check/checkers/clang/tidy.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/format/main.lua | 3 |
4 files changed, 26 insertions, 21 deletions
diff --git a/xmake/modules/async/runjobs.lua b/xmake/modules/async/runjobs.lua index c59027fac..642668921 100644 --- a/xmake/modules/async/runjobs.lua +++ b/xmake/modules/async/runjobs.lua @@ -72,7 +72,7 @@ function _init_progress(state, opt) end }) state.progress_wrapper = progress_wrapper - + -- init progress refresh timeout (for multirow progress refresh timer) state.progress_refresh_timeout = 500 end @@ -231,7 +231,7 @@ function _consume_jobs_loop(state, run_in_remote) -- to avoid running the same task repeatedly, -- we need to update the completion count in advance. state.finished_count = state.finished_count + 1 - + -- check if all tasks have been started (all consumed, but may still be running) if state.finished_count >= total and not state.all_tasks_started then state.all_tasks_started = true @@ -240,7 +240,7 @@ function _consume_jobs_loop(state, run_in_remote) state.progress_refresh_semaphore:post(1) end end - + job_func(job_index, total, {progress = state.progress_wrapper}) -- update progress @@ -306,6 +306,7 @@ end -- runjobs("test", function (index) print("hello") end, {total = 100, comax = 6, timeout = 1000, on_timer = function (running_jobs_indices) end}) -- runjobs("test", function () os.sleep(10000) end, { progress = true }) -- runjobs("test", function () os.sleep(10000) end, { progress = { chars = {'/','\'} } }) -- see module utils.progress +-- runjobs("test", function () os.sleep(10000) end, { progress = true, progress_refresh = true }) -- enable progress refresh timer for multirow progress -- -- local jobs = jobpool.new() -- local root = jobs:addjob("job/root", function (index, total, opt) @@ -368,12 +369,12 @@ function main(name, jobs, opt) scheduler.co_start_withopt({name = name .. "/tips", isolate = opt.isolate}, _progress_loop, state) end) end - + -- start independent refresh timer for multirow progress - local group_refresh_timer = nil - local need_refresh_timer = progress.is_multirow() - if need_refresh_timer then - group_refresh_timer = state.group_name .. "/refresh" + local group_progress_refresh_timer = nil + local need_progress_refresh_timer = opt.progress_refresh and progress.is_multirow() + if need_progress_refresh_timer then + group_progress_refresh_timer = state.group_name .. "/progress_refresh" end -- run jobs @@ -390,9 +391,9 @@ function main(name, jobs, opt) state.distcc_semaphore = scheduler.co_semaphore(state.group_name .. "/distcc", 0) end -- create semaphore for refresh loop - if need_refresh_timer then + if need_progress_refresh_timer then -- semaphore to wait for all tasks started and for refresh timer to signal refresh loop - state.progress_refresh_semaphore = scheduler.co_semaphore(state.group_name .. "/refresh", 0) + state.progress_refresh_semaphore = scheduler.co_semaphore(state.group_name .. "/progress_refresh", 0) end -- @note we can set `remote_only = true` to run all jobs in remote only local local_comax = 0 @@ -410,11 +411,11 @@ function main(name, jobs, opt) end end end) - + -- start refresh loop after semaphore is created - if need_refresh_timer then - scheduler.co_group_begin(group_refresh_timer, function (co_group) - scheduler.co_start_withopt({name = name .. "/refresh", isolate = opt.isolate}, _progress_refresh_loop, state) + if need_progress_refresh_timer then + scheduler.co_group_begin(group_progress_refresh_timer, function (co_group) + scheduler.co_start_withopt({name = name .. "/progress_refresh", isolate = opt.isolate}, _progress_refresh_loop, state) end) end @@ -426,15 +427,15 @@ function main(name, jobs, opt) state.stop = true scheduler.co_group_wait(group_timer) end - + -- wait refresh timer job exited and signal it to exit quickly - if group_refresh_timer then + if group_progress_refresh_timer then state.stop = true -- post signal to refresh loop to wake it up for quick exit if state.progress_refresh_semaphore then state.progress_refresh_semaphore:post(1) end - scheduler.co_group_wait(group_refresh_timer) + scheduler.co_group_wait(group_progress_refresh_timer) end -- restore isolated environments diff --git a/xmake/modules/private/action/build/target.lua b/xmake/modules/private/action/build/target.lua index d623744b4..280610e71 100644 --- a/xmake/modules/private/action/build/target.lua +++ b/xmake/modules/private/action/build/target.lua @@ -797,7 +797,8 @@ function run_targetjobs(targets_root, opt) curdir = curdir, distcc = opt.distcc, remote_only = opt.remote_only, - progress_factor = opt.progress_factor + progress_factor = opt.progress_factor, + progress_refresh = true } async_runjobs(job_kind, jobgraph, runjobs_opt) os.cd(curdir) @@ -817,7 +818,8 @@ function run_filejobs(targets_root, opt) curdir = curdir, distcc = opt.distcc, remote_only = opt.remote_only, - progress_factor = opt.progress_factor + progress_factor = opt.progress_factor, + progress_refresh = true } async_runjobs(job_kind, jobgraph, runjobs_opt) os.cd(curdir) diff --git a/xmake/modules/private/check/checkers/clang/tidy.lua b/xmake/modules/private/check/checkers/clang/tidy.lua index 963bd1bdc..82e9246fb 100644 --- a/xmake/modules/private/check/checkers/clang/tidy.lua +++ b/xmake/modules/private/check/checkers/clang/tidy.lua @@ -158,7 +158,8 @@ function _check_sourcefiles(clang_tidy, sourcefiles, opt) local runjobs_opt = { total = #sourcefiles, comax = opt.jobs or os.default_njob(), - showtips = false + showtips = false, + progress_refresh = true } runjobs("checker.tidy", function (index, total, job_opt) local sourcefile = sourcefiles[index] diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua index 768901f6b..f527b6c00 100644 --- a/xmake/plugins/format/main.lua +++ b/xmake/plugins/format/main.lua @@ -219,7 +219,8 @@ function main() local runjobs_opt = { total = #sourcefiles, comax = jobs, - showtips = false + showtips = false, + progress_refresh = true } runjobs("clang-format", function (index, total, opt) local sourcefile = sourcefiles[index] |
