summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-31 11:04:42 +0800
committerruki <[email protected]>2020-05-31 11:04:42 +0800
commite92e78dfddbc77ce69c8963731a2b7a798f3a0c6 (patch)
tree10b4bbedfea0d56b1eeaf883b5b1a5db5cc22efd
parentbd6bda1b207af221c574d4f85639cdf46f01710f (diff)
improve runjobs
-rw-r--r--xmake/actions/build/build.lua4
-rw-r--r--xmake/actions/require/impl/package.lua2
-rw-r--r--xmake/modules/private/async/runjobs.lua16
3 files changed, 11 insertions, 11 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index 0df393317..07a958482 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -218,9 +218,9 @@ function main(targetname)
local batchjobs = get_batchjobs(targetname)
if batchjobs and batchjobs:size() > 0 then
environment.enter("toolchains")
- runjobs("build", batchjobs, {comax = option.get("jobs") or 1, exit = function ()
+ runjobs("build", batchjobs, {comax = option.get("jobs") or 1, on_exit = function (errors)
import("private.utils.progress")
- if progress.showing_without_scroll() then
+ if errors and progress.showing_without_scroll() then
print("")
end
end})
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index 4293377b3..8f7671e60 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -631,7 +631,7 @@ function _install_packages(packages_install, packages_download)
packages_installing[index] = nil
packages_downloading[index] = nil
- end, {total = #packages_install, comax = (option.get("verbose") or option.get("diagnosis")) and 1 or 4, timer = function (running_jobs_indices)
+ end, {total = #packages_install, comax = (option.get("verbose") or option.get("diagnosis")) and 1 or 4, on_timer = function (running_jobs_indices)
-- do not print progress info if be verbose
if option.get("verbose") or not show_wait then
diff --git a/xmake/modules/private/async/runjobs.lua b/xmake/modules/private/async/runjobs.lua
index cd130e6c9..d9ecdfa58 100644
--- a/xmake/modules/private/async/runjobs.lua
+++ b/xmake/modules/private/async/runjobs.lua
@@ -35,7 +35,7 @@ end
-- asynchronous run jobs
--
-- e.g.
--- runjobs("test", function (index) print("hello") end, {total = 100, comax = 6, timeout = 1000, timer = function (running_jobs_indices) end})
+-- runjobs("test", function (index) print("hello") end, {total = 100, comax = 6, timeout = 1000, on_timer = function (running_jobs_indices) end})
-- runjobs("test", function () os.sleep(10000) end, { progress = true })
-- runjobs("test", function () os.sleep(10000) end, { progress = { chars = {'/','\'} } }) -- see module private.utils.progress
--
@@ -48,7 +48,7 @@ end
-- print(idx, total)
-- end, root)
-- end
--- runjobs("test", jobs, {comax = 6, timeout = 1000, timer = function (running_jobs_indices) end})
+-- runjobs("test", jobs, {comax = 6, timeout = 1000, on_timer = function (running_jobs_indices) end})
--
--
function main(name, jobs, opt)
@@ -76,12 +76,12 @@ function main(name, jobs, opt)
-- run timer
local stop = false
local running_jobs_indices
- if opt.timer then
+ if opt.on_timer then
scheduler.co_start_named(name .. "/timer", function ()
while not stop do
os.sleep(timeout)
if not stop then
- opt.timer(running_jobs_indices)
+ opt.on_timer(running_jobs_indices)
end
end
end)
@@ -199,8 +199,8 @@ function main(name, jobs, opt)
end
-- do exit callback
- if opt.exit then
- opt.exit(errors)
+ if opt.on_exit then
+ opt.on_exit(errors)
end
-- re-throw this errors and abort scheduler
@@ -235,7 +235,7 @@ function main(name, jobs, opt)
end
-- do exit callback
- if opt.exit then
- opt.exit()
+ if opt.on_exit then
+ opt.on_exit()
end
end