diff options
| author | ruki <[email protected]> | 2020-03-04 22:39:46 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-03-04 09:58:36 +0800 |
| commit | 609e9bddc9aa1315ff8cc6ebf57bc3acab0f10b1 (patch) | |
| tree | 3015718ed0c801c4f048dfb93a60030fbb2418f0 | |
| parent | 0f6c36892cf4a3aa5f000d4e1a348a20ae3a21a7 (diff) | |
improve runjobs
| -rw-r--r-- | xmake/core/base/scheduler.lua | 5 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 3 | ||||
| -rw-r--r-- | xmake/modules/private/async/runjobs.lua | 8 |
3 files changed, 7 insertions, 9 deletions
diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua index efd92354a..6740e1464 100644 --- a/xmake/core/base/scheduler.lua +++ b/xmake/core/base/scheduler.lua @@ -414,13 +414,14 @@ function scheduler:co_group_begin(name, scopefunc) self._CO_GROUPS_PENDING[name] = self._CO_GROUPS_PENDING[name] or {} -- call the scope function - local ok, errors = utils.trycall(scopefunc) + local co_group = self._CO_GROUPS[name] or {} + local ok, errors = utils.trycall(scopefunc, nil, co_group) if not ok then return false, errors end -- leave groups - self._CO_GROUPS[name] = self._CO_GROUPS[name] or {} + self._CO_GROUPS[name] = co_group table.join2(self._CO_GROUPS[name], self._CO_GROUPS_PENDING[name]) self._CO_GROUPS_PENDING[name] = nil return true diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index 67119ec98..62fef5e22 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -93,7 +93,8 @@ function sandbox_core_project.check() end -- check all options - import("private.async.runjobs", {anonymous = true})("check_options", instance:fork(checktask):script(), {total = #options, comax = 4}) + local jobs = baseoption.get("jobs") or math.ceil(os.cpuinfo().ncpu * 3 / 2) + import("private.async.runjobs", {anonymous = true})("check_options", instance:fork(checktask):script(), {total = #options, comax = jobs}) -- leave toolchains environment environment.leave("toolchains") diff --git a/xmake/modules/private/async/runjobs.lua b/xmake/modules/private/async/runjobs.lua index 422df3560..6a130380b 100644 --- a/xmake/modules/private/async/runjobs.lua +++ b/xmake/modules/private/async/runjobs.lua @@ -120,12 +120,8 @@ function main(name, jobfunc, opt) local index = 0 while index < total do running_jobs_indices = {} - scheduler.co_group_begin(group_name, function () - local freemax = comax - local co_group = scheduler.co_group(group_name) - if co_group then - freemax = freemax - #co_group - end + scheduler.co_group_begin(group_name, function (co_group) + local freemax = comax - #co_group local max = math.min(index + freemax, total) while index < max do index = index + 1 |
