summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-14 12:23:13 +0800
committerruki <[email protected]>2022-05-14 12:23:13 +0800
commit60b2376a7520df9a611a1051663da67b119925aa (patch)
treef4fa39f9955b4726a0cae1a0aac745918b4e045b /xmake
parent6b8299c79e6b8f1548f52b02295a03dcfeccd995 (diff)
schedule local jobs
Diffstat (limited to 'xmake')
-rw-r--r--xmake/core/base/scheduler.lua17
-rw-r--r--xmake/modules/private/async/runjobs.lua17
-rw-r--r--xmake/modules/private/service/distcc_build/client.lua15
3 files changed, 46 insertions, 3 deletions
diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua
index f4928a887..d961c1c75 100644
--- a/xmake/core/base/scheduler.lua
+++ b/xmake/core/base/scheduler.lua
@@ -62,6 +62,23 @@ function _coroutine:waitobj_set(obj)
self._WAITOBJ = obj
end
+-- get user private data
+function _coroutine:data(name)
+ return self._DATA and self._DATA[name]
+end
+
+-- set user private data
+function _coroutine:data_set(name, data)
+ self._DATA = self._DATA or {}
+ self._DATA[name] = data
+end
+
+-- add user private data
+function _coroutine:data_add(name, data)
+ self._DATA = self._DATA or {}
+ self._DATA[name] = table.unwrap(table.join(self._DATA[name] or {}, data))
+end
+
-- get the raw coroutine thread
function _coroutine:thread()
return self._THREAD
diff --git a/xmake/modules/private/async/runjobs.lua b/xmake/modules/private/async/runjobs.lua
index 9179e6a76..0089456bf 100644
--- a/xmake/modules/private/async/runjobs.lua
+++ b/xmake/modules/private/async/runjobs.lua
@@ -171,6 +171,7 @@ function main(name, jobs, opt)
-- uses job pool?
local jobname
+ local localjob = true
if not jobs_cb then
-- get job priority
@@ -194,9 +195,13 @@ function main(name, jobs, opt)
end
-- we can only continue to run the job with distcc if local jobs are full
- if index >= local_max and not job.distcc then
- job_pending = job
- break
+ if distcc and index >= local_max then
+ if job.distcc then
+ localjob = false
+ else
+ job_pending = job
+ break
+ end
end
-- get run function
@@ -213,6 +218,12 @@ function main(name, jobs, opt)
try
{
function()
+ if distcc then
+ local co_running = scheduler.co_running()
+ if co_running then
+ co_running:data_set("distcc.localjob", localjob)
+ end
+ end
running_jobs_indices[i] = i
if jobfunc then
if opt.curdir then
diff --git a/xmake/modules/private/service/distcc_build/client.lua b/xmake/modules/private/service/distcc_build/client.lua
index 9100a5e1c..736a67f48 100644
--- a/xmake/modules/private/service/distcc_build/client.lua
+++ b/xmake/modules/private/service/distcc_build/client.lua
@@ -164,6 +164,9 @@ end
-- run compilation job
function distcc_build_client:iorunv(program, argv, opt)
+ if self:_is_localjob() then
+ return os.iorunv(program, argv, opt)
+ end
return os.iorunv(program, argv, opt)
end
@@ -201,6 +204,18 @@ function distcc_build_client:workdir()
return self._WORKDIR
end
+-- only run the local job?
+function distcc_build_client:_is_localjob()
+ local co_running = scheduler.co_running()
+ if co_running then
+ local localjob = co_running:data("distcc.localjob")
+ if localjob then
+ return true
+ end
+ end
+ return self:freejobs() == 0
+end
+
-- get the session id, only for unique project
function distcc_build_client:_session_id(addr, port)
local hosts = self:status().hosts