diff options
| author | ruki <[email protected]> | 2025-11-20 22:37:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-20 22:37:34 +0800 |
| commit | 800e4177ac9584c30a56bf1c3ce356b76b6653e8 (patch) | |
| tree | d7433c4a115b50557db9f1dde4910e12c2f2a234 /xmake/modules/async | |
| parent | 589847bf9018bec38b0c5ca099c04b3f4a4fd4b3 (diff) | |
fix progress and runjobs
Diffstat (limited to 'xmake/modules/async')
| -rw-r--r-- | xmake/modules/async/runjobs.lua | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/xmake/modules/async/runjobs.lua b/xmake/modules/async/runjobs.lua index 9254cf499..e08acc908 100644 --- a/xmake/modules/async/runjobs.lua +++ b/xmake/modules/async/runjobs.lua @@ -49,11 +49,11 @@ function _init_progress(state, opt) end -- init progress wrapper - state.finished_count = 0 + state.progress_finished_count = 0 state.progress_factor = opt.progress_factor or 1.0 local progress_wrapper = {} progress_wrapper.current = function () - return state.finished_count + return state.progress_finished_count end progress_wrapper.total = function () return state.total @@ -61,7 +61,7 @@ function _init_progress(state, opt) progress_wrapper.percent = function () local total = state.total if total and total > 0 then - return math.floor((state.finished_count * state.progress_factor * 100) / total) + return math.floor((state.progress_finished_count * state.progress_factor * 100) / total) else return 0 end @@ -203,8 +203,14 @@ function _consume_jobs_loop(state, run_in_remote) if curdir then os.cd(curdir) end - job_func(job_index, total, {progress = state.progress_wrapper}) + + -- to avoid running the same task repeatedly, + -- we need to update the completion count in advance. state.finished_count = state.finished_count + 1 + job_func(job_index, total, {progress = state.progress_wrapper}) + + -- update progress + state.progress_finished_count = state.progress_finished_count + 1 end state.running_jobs_indices[job_index] = nil co_running:data_set("runjobs.running", false) |
