summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-14 17:28:27 +0800
committerruki <[email protected]>2022-05-14 17:28:27 +0800
commit2f912bbb6b53a8359390c1159a4dc08b976796ac (patch)
tree105fc22c0ebdcfe4dcbfdd14b4d773f1982e7c2d
parenta2782c2e8811f7ab9327b8253721111f83875a92 (diff)
get host status
-rw-r--r--xmake/modules/private/service/distcc_build/client.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/xmake/modules/private/service/distcc_build/client.lua b/xmake/modules/private/service/distcc_build/client.lua
index 2b90a96e9..3d3f5aa16 100644
--- a/xmake/modules/private/service/distcc_build/client.lua
+++ b/xmake/modules/private/service/distcc_build/client.lua
@@ -84,6 +84,19 @@ function distcc_build_client:hosts_set(hosts)
self._HOSTS = hostinfos
end
+-- get the status of client hosts
+function distcc_build_client:hosts_status()
+ local hosts_status = self._HOSTS_STATUS
+ if hosts_status == nil then
+ hosts_status = table.copy(self:status().hosts)
+ for _, host_status in pairs(hosts_status) do
+ self:_update_status(hosts_status)
+ end
+ self._HOSTS_STATUS = hosts_status
+ end
+ return hosts_status
+end
+
-- connect to the distcc server
function distcc_build_client:connect()
if self:is_connected() then
@@ -219,6 +232,17 @@ function distcc_build_client:workdir()
return self._WORKDIR
end
+-- update the host status
+function distcc_build_client:_update_status(host_status)
+ local running = host_status.running or 0
+ if running > host_status.njob then
+ running = host_status.njob
+ end
+ host_status.running = running
+ host_status.freejobs = host_status.njob - host_status.running
+ host_status.weight = host_status.freejobs
+end
+
-- has free jobs?
function distcc_build_client:_has_freejobs()
return self:freejobs() > 0