diff options
| author | ruki <[email protected]> | 2020-03-17 23:17:42 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-03-17 13:46:16 +0800 |
| commit | d32578f6b5c788e31e08a6705e4b884626dafd75 (patch) | |
| tree | 98a388af9d6ee5b0fefab94d4db6df468badaa59 | |
| parent | 0924c3f19f63006333f05dbf83f6f152d8a1c920 (diff) | |
fix jobpool deps
| -rw-r--r-- | xmake/core/base/hashset.lua | 7 | ||||
| -rw-r--r-- | xmake/modules/private/async/jobpool.lua | 13 |
2 files changed, 12 insertions, 8 deletions
diff --git a/xmake/core/base/hashset.lua b/xmake/core/base/hashset.lua index a30bd69f7..6cd94ceba 100644 --- a/xmake/core/base/hashset.lua +++ b/xmake/core/base/hashset.lua @@ -100,7 +100,7 @@ end -- convert hashset to an array, nil in the set will be ignored function hashset_impl:to_array() local result = {} - for k,_ in pairs(self._DATA) do + for k, _ in pairs(self._DATA) do if k ~= hashset._NIL then table.insert(result, k) end @@ -126,6 +126,11 @@ function hashset_impl:size() return self._SIZE end +-- is empty? +function hashset_impl:empty() + return self:size() == 0 +end + -- get data of hashset function hashset_impl:data() return self._DATA diff --git a/xmake/modules/private/async/jobpool.lua b/xmake/modules/private/async/jobpool.lua index ca38d397f..b1c643f8f 100644 --- a/xmake/modules/private/async/jobpool.lua +++ b/xmake/modules/private/async/jobpool.lua @@ -19,7 +19,6 @@ -- -- imports -import("core.base.dlist") import("core.base.object") import("core.base.hashset") @@ -55,8 +54,8 @@ function jobpool:add(job, rootjob) -- add job to the root job rootjob = rootjob or self:rootjob() - rootjob._deps = rootjob._deps or dlist:new() - rootjob._deps:push(job) + rootjob._deps = rootjob._deps or hashset.new() + rootjob._deps:insert(job) -- attach parents node local parents = job._parents @@ -70,8 +69,8 @@ function jobpool:add(job, rootjob) -- in group? attach the group node local group = self._group if group then - job._deps = job._deps or dlist:new() - job._deps:push(group) + job._deps = job._deps or hashset.new() + job._deps:insert(group) group._parents = group._parents or {} table.insert(group._parents, job) end @@ -150,7 +149,7 @@ end function jobpool:_genleafjobs(job, leafjobs, refs) local deps = job._deps if deps and not deps:empty() then - for dep in deps:items() do + for _, dep in deps:keys() do local depkey = tostring(dep) if not refs[depkey] then refs[depkey] = true @@ -167,7 +166,7 @@ function jobpool:_gentree(job, refs) local tree = {job.group and ("group(" .. job.name .. ")") or job.name} local deps = job._deps if deps and not deps:empty() then - for dep in deps:items() do + for _, dep in deps:keys() do local depkey = tostring(dep) if refs[depkey] then local depname = dep.group and ("group(" .. dep.name .. ")") or dep.name |
