diff options
Diffstat (limited to 'xmake/modules/async/runjobs.lua')
| -rw-r--r-- | xmake/modules/async/runjobs.lua | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/xmake/modules/async/runjobs.lua b/xmake/modules/async/runjobs.lua index 299b868df..1f59a7359 100644 --- a/xmake/modules/async/runjobs.lua +++ b/xmake/modules/async/runjobs.lua @@ -154,9 +154,6 @@ function main(name, jobs, opt) -- run jobs local index = 0 local count = 0 - local priority_prev = 0 - local priority_curr = 0 - local job_pending = nil local abort = false local abort_errors local progress_wrapper = {} @@ -190,44 +187,29 @@ function main(name, jobs, opt) while index < total_max do -- uses job pool? + local job local jobname local distccjob = false if not jobs_cb then - -- get job priority - local job, priority - if job_pending then - job = job_pending - priority = priority_prev - else - job, priority = jobs:pop() - end - if not job then - break - end - - -- priority changed? we need to wait all running jobs exited - priority_curr = priority or priority_prev - assert(priority_curr >= priority_prev, "runjobs: invalid priority(%d < %d)!", priority_curr, priority_prev) - if priority_curr > priority_prev then - job_pending = job - break - end - -- we can only continue to run the job with distcc if local jobs are full if distcc and index >= local_max then if job.distcc then distccjob = true else - job_pending = job break end end + -- get free job + job = jobs:getfree() + if not job then + break + end + -- get run function jobfunc = job.run jobname = job.name - job_pending = nil else jobname = tostring(index) end @@ -287,20 +269,22 @@ function main(name, jobs, opt) end end end + }, + finally + { + function () + if job then + jobs:remove(job) + end + end } } end, index) end end) - -- only need one job exited if be same priority - if priority_curr == priority_prev then - scheduler.co_group_wait(group_name, {limit = 1}) - else - -- need to wait all running jobs exited first if be different priority - scheduler.co_group_wait(group_name) - priority_prev = priority_curr - end + -- wait for free jobs + scheduler.co_group_wait(group_name, {limit = 1}) end -- wait all jobs exited |
