summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2025-03-21 22:37:17 +0800
committerruki <[email protected]>2025-04-08 15:31:54 +0800
commitce5fb205bbebb83fe6842b00858210f9d4256148 (patch)
treef8cf0c4c2d25c6938ae540bd6a11df2485769284 /xmake/modules
parenta278d3bd3e74027e7fd1f878c7d8c991caf1a75f (diff)
use kahn algorithm for graph by default
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/async/jobgraph.lua24
1 files changed, 2 insertions, 22 deletions
diff --git a/xmake/modules/async/jobgraph.lua b/xmake/modules/async/jobgraph.lua
index 6d96ff0ff..ca8725b28 100644
--- a/xmake/modules/async/jobgraph.lua
+++ b/xmake/modules/async/jobgraph.lua
@@ -28,19 +28,6 @@ import("core.base.hashset")
local jobqueue = jobqueue or object {_init = {"_jobgraph", "_queue"}}
local jobgraph = jobgraph or object {_init = {"_name", "_jobs", "_size", "_dag", "_dirty"}}
--- add job dependency
-function jobqueue:_add_dep(job, dep)
- job._deps = job._deps or hashset.new()
- job._deps:insert(dep)
-
- local parents = dep._parents
- if not parents then
- parents = {}
- dep._parents = parents
- end
- table.insert(parents, job)
-end
-
-- build the job queue
function jobqueue:_build()
local graph = self._jobgraph
@@ -49,7 +36,7 @@ function jobqueue:_build()
-- build job queue
queue:clear()
- local order_jobs, has_cycle = dag:topological_sort({reverse = true})
+ local order_jobs, has_cycle = dag:topological_sort()
if has_cycle then
local cycle = dag:find_cycle()
if cycle then
@@ -62,16 +49,9 @@ function jobqueue:_build()
end
end
for _, job in ipairs(order_jobs) do
- job._deps = nil
- job._parents = nil
+ print("insert", job.name)
queue:insert(job)
end
-
- -- build job dependencies
- for _, e in ipairs(dag:edges()) do
- self:_add_dep(e:from(), e:to())
- print("%s -> %s", e:from().name, e:to().name)
- end
end
-- update the job queue