diff options
| author | ruki <[email protected]> | 2020-03-04 23:14:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-03-04 13:27:13 +0800 |
| commit | 24c308f5f7772615e50d537895ff214df7ef8751 (patch) | |
| tree | 20bb0f9232d453b2e7416794c21510738f7fa5f4 | |
| parent | 609e9bddc9aa1315ff8cc6ebf57bc3acab0f10b1 (diff) | |
fix scheduler
| -rw-r--r-- | xmake/core/base/scheduler.lua | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua index 6740e1464..f2c9df03d 100644 --- a/xmake/core/base/scheduler.lua +++ b/xmake/core/base/scheduler.lua @@ -263,28 +263,30 @@ function scheduler:_co_groups_resume() -- get coroutine and limit in waiting group local co_group_waiting = self._CO_GROUPS_WAITING[name] - local co_waiting = co_group_waiting[1] - local limit = co_group_waiting[2] + if co_group_waiting then + local co_waiting = co_group_waiting[1] + local limit = co_group_waiting[2] - -- get dead coroutines count in this group - local count = 0 - for _, co in ipairs(co_group) do - if count < limit then - if co:is_dead() then - count = count + 1 + -- get dead coroutines count in this group + local count = 0 + for _, co in ipairs(co_group) do + if count < limit then + if co:is_dead() then + count = count + 1 + end + else + break end - else - break end - end - -- resume the waiting coroutine of this group if some coroutines are dead in this group - if count >= limit and co_waiting and co_waiting:is_suspended() then - resumed_count = resumed_count + 1 - self._CO_GROUPS_WAITING[name] = nil - local ok, errors = self:co_resume(co_waiting) - if not ok then - return -1, errors + -- resume the waiting coroutine of this group if some coroutines are dead in this group + if count >= limit and co_waiting and co_waiting:is_suspended() then + resumed_count = resumed_count + 1 + self._CO_GROUPS_WAITING[name] = nil + local ok, errors = self:co_resume(co_waiting) + if not ok then + return -1, errors + end end end end |
