summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-03-20 00:43:39 +0800
committerruki <[email protected]>2025-04-08 15:31:54 +0800
commit79522ada6117fb6bc87dc5cc7a0a88cfde5e12fc (patch)
treeecb1a07915dbf868e39463db0a6669ec0fe6e405
parentbc4f14679956d6eac336cb23d72e5e91c189a5bf (diff)
rename to dag
-rw-r--r--xmake/modules/async/jobgraph.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/xmake/modules/async/jobgraph.lua b/xmake/modules/async/jobgraph.lua
index 684b7d7d8..ecd5ff7f1 100644
--- a/xmake/modules/async/jobgraph.lua
+++ b/xmake/modules/async/jobgraph.lua
@@ -25,13 +25,16 @@ import("core.base.graph")
-- define module
local jobqueue = jobqueue or object {_init = {"_jobgraph"}}
-local jobgraph = jobgraph or object {_init = {"_name", "_jobs", "_size", "_deps", "_dirty"}}
+local jobgraph = jobgraph or object {_init = {"_name", "_jobs", "_size", "_dag", "_dirty"}}
-- build the job queue
function jobqueue:_build()
local graph = self._jobgraph
- -- TODO
- print("build job queue")
+ local dag = graph._dag
+ local queue = dag:topological_sort()
+ for _, v in ipairs(queue) do
+ print(v.name)
+ end
end
-- update the job queue
@@ -89,12 +92,12 @@ end
function jobgraph:add_deps(...)
local prev
local dirty
+ local dag = self._dag
local jobs = self._jobs
- local deps = self._deps
for _, name in ipairs(table.pack(...)) do
local curr = assert(jobs[name], "job(%s) not found in jobgraph(%s)", name, self)
if prev then
- deps:add_edge(prev, curr)
+ dag:add_edge(prev, curr)
dirty = true
end
prev = curr