diff options
| author | ruki <[email protected]> | 2020-02-05 00:34:53 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-07 22:45:56 +0800 |
| commit | 94d3eb649e489a597a2f5d966d2249a9e64d87e3 (patch) | |
| tree | c5bb5c3286c64a5ca491b2aacc0c09a4c9cc84ba /xmake/core/base | |
| parent | a615d353a701e0d23e322060e5dd8e364d38dfee (diff) | |
impl private.async.runjobs
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/os.lua | 24 | ||||
| -rw-r--r-- | xmake/core/base/scheduler.lua | 10 |
2 files changed, 6 insertions, 28 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 46a0ad1a1..35099cc9e 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -659,29 +659,7 @@ function os.execv(program, argv, opt) if proc ~= nil then -- wait process - local waitok = -1 - local status = -1 - if coroutine.running() then - - -- save the current directory - local curdir = os.curdir() - - -- wait it - repeat - -- poll it - waitok, status = proc:wait(0) - if waitok == 0 then - waitok, status = coroutine.yield(proc) - end - until waitok ~= 0 - - -- resume the current directory - os.cd(curdir) - else - waitok, status = proc:wait(-1) - end - - -- get status + local waitok, status = proc:wait(-1) if waitok > 0 then ok = status end diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua index 6c3b511b1..b1091caf6 100644 --- a/xmake/core/base/scheduler.lua +++ b/xmake/core/base/scheduler.lua @@ -89,7 +89,7 @@ end -- tostring(coroutine) function _coroutine:__tostring() - return string.format("<co: %s/%s>", self:thread(), self:name()) + return string.format("<co: %s/%s>", self:name(), self:status()) end -- gc(coroutine) @@ -265,13 +265,13 @@ function scheduler:_co_groups_resume() -- resume the waiting coroutine of this group local co_waiting = self._CO_GROUPS_WAITING[name] if co_waiting and co_waiting:is_suspended() then + resumed_count = resumed_count + 1 + self._CO_GROUPS_WAITING[name] = nil + self:_co_tasks_suspended():remove(co_waiting) local ok, errors = self:co_resume(co_waiting) if not ok then return -1, errors end - resumed_count = resumed_count + 1 - self._CO_GROUPS_WAITING[name] = nil - self:_co_tasks_suspended():remove(co_waiting) end end end @@ -703,7 +703,7 @@ function scheduler:runloop() if resumed_count < 0 then ok = false errors = resumed_errors - break; + break elseif resumed_count == 0 then -- get the next timeout |
