summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-05 23:03:41 +0800
committerruki <[email protected]>2020-02-07 22:45:56 +0800
commit97d20dc309b8064ab7bafc69a6784caa4df9b107 (patch)
tree5925aeb2176d719fb4b8b7fa68214649347955af /xmake/core
parent1cac0feefb18328d14deff5b1fddb95fc7175353 (diff)
improve runjobs tips
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/base/scheduler.lua19
-rw-r--r--xmake/core/sandbox/modules/import/core/base/scheduler.lua6
2 files changed, 25 insertions, 0 deletions
diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua
index b1091caf6..5e68be8c2 100644
--- a/xmake/core/base/scheduler.lua
+++ b/xmake/core/base/scheduler.lua
@@ -52,6 +52,16 @@ function _coroutine:name_set(name)
self._NAME = name
end
+-- get the waiting poller object
+function _coroutine:waitobj()
+ return self._WAITOBJ
+end
+
+-- set the waiting poller object
+function _coroutine:waitobj_set(obj)
+ self._WAITOBJ = obj
+end
+
-- get the raw coroutine thread
function _coroutine:thread()
return self._THREAD
@@ -146,6 +156,7 @@ function scheduler:_poller_resume_co(co, events)
assert(co:is_suspended())
-- resume this coroutine task
+ co:waitobj_set(nil)
self:_co_tasks_suspended():remove(co)
return self:co_resume(co, (bit.band(events, poller.EV_POLLER_ERROR) ~= 0) and -1 or events)
end
@@ -550,6 +561,7 @@ function scheduler:poller_wait(obj, events, timeout)
if timeout > 0 then
timer_task = self:_timer():post(function (cancel)
if not cancel and running:is_suspended() then
+ running:waitobj_set(nil)
self:_co_tasks_suspended():remove(running)
self:co_resume(running, 0)
end
@@ -572,6 +584,9 @@ function scheduler:poller_wait(obj, events, timeout)
-- save the suspended coroutine
self:_co_tasks_suspended():insert(running)
+ -- save the waiting poller object
+ running:waitobj_set(obj)
+
-- wait
return self:co_suspend()
end
@@ -621,6 +636,7 @@ function scheduler:poller_waitproc(obj, timeout)
timer_task = self:_timer():post(function (cancel)
if not cancel and running:is_suspended() then
pollerdata.co_waiting = nil
+ running:waitobj_set(nil)
self:_co_tasks_suspended():remove(running)
self:co_resume(running, 0)
end
@@ -636,6 +652,9 @@ function scheduler:poller_waitproc(obj, timeout)
-- save the suspended coroutine
self:_co_tasks_suspended():insert(running)
+ -- save the waiting poller object
+ running:waitobj_set(obj)
+
-- wait
local ok = self:co_suspend()
return ok, pollerdata.proc_status
diff --git a/xmake/core/sandbox/modules/import/core/base/scheduler.lua b/xmake/core/sandbox/modules/import/core/base/scheduler.lua
index c899fcd34..254f78591 100644
--- a/xmake/core/sandbox/modules/import/core/base/scheduler.lua
+++ b/xmake/core/sandbox/modules/import/core/base/scheduler.lua
@@ -22,9 +22,15 @@
local sandbox_core_base_scheduler = sandbox_core_base_scheduler or {}
-- load modules
+local poller = require("base/poller")
local scheduler = require("base/scheduler")
local raise = require("sandbox/modules/raise")
+-- the poller object type
+sandbox_core_base_scheduler.OT_SOCK = poller.OT_SOCK
+sandbox_core_base_scheduler.OT_PIPE = poller.OT_PIPE
+sandbox_core_base_scheduler.OT_PROC = poller.OT_PROC
+
-- start a new coroutine task
function sandbox_core_base_scheduler.co_start(cotask, ...)
local co, errors = scheduler:co_start(cotask, ...)