summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2024-04-07 23:07:41 +0800
committerruki <[email protected]>2024-04-07 23:07:41 +0800
commit62194c3e5dff8141813f9f63993516de98dd367f (patch)
treef39d4fda02efbbd1c5e5cdb7cf5fbe5d335ac51c /xmake/modules
parent7e0f8751549ed166fefa13afb300527b76bb190a (diff)
improve dlist
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/async/runjobs.lua19
-rw-r--r--xmake/modules/private/action/require/impl/package.lua1
-rw-r--r--xmake/modules/private/async/jobpool.lua21
3 files changed, 17 insertions, 24 deletions
diff --git a/xmake/modules/async/runjobs.lua b/xmake/modules/async/runjobs.lua
index 299b868df..6d19efe17 100644
--- a/xmake/modules/async/runjobs.lua
+++ b/xmake/modules/async/runjobs.lua
@@ -154,8 +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
@@ -194,26 +192,17 @@ function main(name, jobs, opt)
local distccjob = false
if not jobs_cb then
- -- get job priority
- local job, priority
+ -- get job
+ local job
if job_pending then
job = job_pending
- priority = priority_prev
else
- job, priority = jobs:pop()
+ job = 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
@@ -254,6 +243,7 @@ function main(name, jobs, opt)
end
count = count + 1
jobfunc(i, total, {progress = progress_wrapper})
+ print("finished", jobname)
end
running_jobs_indices[i] = nil
end,
@@ -299,7 +289,6 @@ function main(name, jobs, opt)
else
-- need to wait all running jobs exited first if be different priority
scheduler.co_group_wait(group_name)
- priority_prev = priority_curr
end
end
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 6a860d99a..d8a5af7be 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -942,6 +942,7 @@ function _load_package(packagename, requireinfo, opt)
-- get package key
local packagekey = _get_packagekey(packagename, requireinfo, version)
+ print("packagekey", packagekey)
-- get package from cache first
local package_cached = _memcache():get2("packages", packagekey)
diff --git a/xmake/modules/private/async/jobpool.lua b/xmake/modules/private/async/jobpool.lua
index 7f9067343..653be2328 100644
--- a/xmake/modules/private/async/jobpool.lua
+++ b/xmake/modules/private/async/jobpool.lua
@@ -20,6 +20,7 @@
-- imports
import("core.base.object")
+import("core.base.dlist")
import("core.base.hashset")
-- define module
@@ -111,14 +112,13 @@ function jobpool:pop()
end
-- pop a job from the leaf jobs
- if #leafjobs > 0 then
+ if not leafjobs:empty() then
-- get job
- local job = leafjobs[#leafjobs]
- table.remove(leafjobs, #leafjobs)
+ local job = leafjobs:last()
+ leafjobs:remove(job)
- -- get priority and parents node
- local priority = job._priority or 0
+ -- get parents node
local parents = assert(job._parents, "invalid job without parents node!")
-- update all parents nodes
@@ -126,7 +126,6 @@ function jobpool:pop()
-- we need to avoid adding it to leafjobs repeatly, it will cause dead-loop when poping group job
-- @see https://github.com/xmake-io/xmake/issues/2740
if not p._leaf then
- p._priority = math.max(p._priority or 0, priority + 1)
p._deps:remove(job)
if p._deps:empty() and self._size > 0 then
p._leaf = true
@@ -145,11 +144,15 @@ function jobpool:pop()
-- pop this job
self._size = self._size - 1
poprefs[jobkey] = true
- return job, priority
+ return job
end
end
end
+-- get free jobs
+function jobpool:freejobs()
+end
+
-- enter group
--
-- @param name the group name
@@ -191,7 +194,7 @@ function jobpool:_genleafjobs(job, leafjobs, refs)
end
else
job._leaf = true
- table.insert(leafjobs, job)
+ leafjobs:push(job)
end
end
@@ -232,5 +235,5 @@ end
-- new a jobpool
function new()
- return jobpool {0, {name = "root"}, {}, {}}
+ return jobpool {0, {name = "root"}, dlist.new(), {}}
end