diff options
| author | ruki <[email protected]> | 2025-03-20 22:37:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-04-08 15:31:54 +0800 |
| commit | 2277ac87ba989b2b4004c07627235b48760579cc (patch) | |
| tree | 1f1d6a324c733394f15ab6783bec2615db5a358c /xmake/modules/async/jobgraph.lua | |
| parent | 30ca6c18a4070e5f699f5fc61bf5fca475bcd67b (diff) | |
improve graph
Diffstat (limited to 'xmake/modules/async/jobgraph.lua')
| -rw-r--r-- | xmake/modules/async/jobgraph.lua | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/xmake/modules/async/jobgraph.lua b/xmake/modules/async/jobgraph.lua index 458c20f5a..bfeee3863 100644 --- a/xmake/modules/async/jobgraph.lua +++ b/xmake/modules/async/jobgraph.lua @@ -33,7 +33,9 @@ function jobqueue:_build() local dag = graph._dag local queue = self._queue queue:clear() + -- TODO find cycle for _, job in ipairs(dag:topological_sort()) do + print("build job", job.name) queue:insert(job) end end @@ -86,9 +88,12 @@ end -- remove a given job function jobgraph:remove(name) local jobs = self._jobs - if jobs[name] then + local job = jobs[name] + local dag = self._dag + if job then assert(self._size > 0) jobs[name] = nil + dag:remove_vertex(job) self._size = self._size - 1 self._dirty = true end @@ -103,8 +108,10 @@ function jobgraph:add_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 - dag:add_edge(prev, curr) - dirty = true + if not dag:has_edge(prev, curr) then + dag:add_edge(prev, curr) + dirty = true + end end prev = curr end |
