summaryrefslogtreecommitdiff
path: root/xmake/modules/async
diff options
context:
space:
mode:
authorruki <[email protected]>2024-04-08 23:06:48 +0800
committerruki <[email protected]>2024-04-08 23:06:48 +0800
commit14f497e354aa9ec61f54e201d4db211da4d2086f (patch)
tree9518e3c939f64bad7bd9e0e67c040642514c9af3 /xmake/modules/async
parentb1f552fae364bcc48884b9f3f8d1d52a0531e92e (diff)
improve jobpool
Diffstat (limited to 'xmake/modules/async')
-rw-r--r--xmake/modules/async/runjobs.lua25
1 files changed, 9 insertions, 16 deletions
diff --git a/xmake/modules/async/runjobs.lua b/xmake/modules/async/runjobs.lua
index 6d19efe17..1508a71d8 100644
--- a/xmake/modules/async/runjobs.lua
+++ b/xmake/modules/async/runjobs.lua
@@ -154,7 +154,6 @@ function main(name, jobs, opt)
-- run jobs
local index = 0
local count = 0
- local job_pending = nil
local abort = false
local abort_errors
local progress_wrapper = {}
@@ -188,21 +187,18 @@ 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
- local job
- if job_pending then
- job = job_pending
- else
- job = jobs:pop()
- end
+ -- get free job
+ job = jobs:getfree()
if not job then
break
end
+ -- TODO
-- 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
@@ -216,7 +212,6 @@ function main(name, jobs, opt)
-- get run function
jobfunc = job.run
jobname = job.name
- job_pending = nil
else
jobname = tostring(index)
end
@@ -243,6 +238,9 @@ function main(name, jobs, opt)
end
count = count + 1
jobfunc(i, total, {progress = progress_wrapper})
+ if job then
+ jobs:remove(job)
+ end
print("finished", jobname)
end
running_jobs_indices[i] = nil
@@ -283,13 +281,8 @@ function main(name, jobs, opt)
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)
- end
+ -- wait for free jobs
+ scheduler.co_group_wait(group_name, {limit = 1})
end
-- wait all jobs exited