summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-03-18 23:55:15 +0800
committerruki <[email protected]>2025-04-08 15:31:54 +0800
commit1621db050a13474f4d79d02c4d306013770d35b4 (patch)
treecf0df4a94324fd1ad80acf1058e6dcc8921715a4
parent00ebba39f7e81d2b52bfb3be458f9825e6d7c070 (diff)
add jobgraph.new
-rw-r--r--tests/modules/async/jobgraph.lua4
-rw-r--r--xmake/modules/async/jobgraph.lua12
2 files changed, 11 insertions, 5 deletions
diff --git a/tests/modules/async/jobgraph.lua b/tests/modules/async/jobgraph.lua
index dd8cb05f8..7a0b87c65 100644
--- a/tests/modules/async/jobgraph.lua
+++ b/tests/modules/async/jobgraph.lua
@@ -1,7 +1,7 @@
-import("core.base.scheduler")
import("async.jobgraph")
function main()
-
+ local gh = jobgraph.new()
+ print(gh)
end
diff --git a/xmake/modules/async/jobgraph.lua b/xmake/modules/async/jobgraph.lua
index 519544cf2..3fd36194a 100644
--- a/xmake/modules/async/jobgraph.lua
+++ b/xmake/modules/async/jobgraph.lua
@@ -20,17 +20,23 @@
-- imports
import("core.base.object")
+import("core.base.list")
import("core.base.graph")
-- define module
-local jobgraph = jobgraph or object {_init = {"_size"}}
+local jobgraph = jobgraph or object {_init = {"_jobs", "_graph"}}
+
+-- get jobs
+function jobgraph:jobs()
+ return self._jobs
+end
-- tostring
function jobgraph:__tostring()
- return "<jobgraph>"
+ return string.format("<jobgraph:%s>", self:jobs():size())
end
-- new a jobgraph
function new()
- return jobgraph {0}
+ return jobgraph {list.new(), graph.new(true)}
end