summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-06 00:01:11 +0800
committerruki <[email protected]>2020-02-07 22:45:57 +0800
commitd40841b322485ec4200a857979b2ea77677a906a (patch)
tree9e11ff1f9f974c59cf3d0fccd9991f0918b93e4a
parenta1e36f03bcae56c52c36ca1692725330cd173043 (diff)
add onext for async/runjobs
-rw-r--r--xmake/actions/require/impl/package.lua5
-rw-r--r--xmake/core/base/utils.lua2
-rw-r--r--xmake/modules/private/async/runjobs.lua37
3 files changed, 42 insertions, 2 deletions
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index 0f34a8839..6afb7b876 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -693,6 +693,11 @@ function _install_packages(packages_install, packages_download)
end
cprintf(" .. %s%s", tips and ("${dim}" .. tips .. "${clear} ") or "", waitchars[waitindex + 1])
io.flush()
+ end, exit = function(errors)
+ if errors then
+ utils.clearline()
+ io.flush()
+ end
end})
end
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua
index dda5077d3..2c83d759f 100644
--- a/xmake/core/base/utils.lua
+++ b/xmake/core/base/utils.lua
@@ -307,7 +307,7 @@ function utils.confirm(opt)
else
utils.cprint("${bright color.warning}note: ${clear}%s (pass -y or --confirm=y/n/d to skip confirm)?", description)
end
- utils.cprint("please input: %s (y/n)", default and "y" or "n")
+ utils.cprint("please input: ${bright}%s${clear} (y/n)", default and "y" or "n")
-- get answer
io.flush()
diff --git a/xmake/modules/private/async/runjobs.lua b/xmake/modules/private/async/runjobs.lua
index 0e56963b3..a96591ff2 100644
--- a/xmake/modules/private/async/runjobs.lua
+++ b/xmake/modules/private/async/runjobs.lua
@@ -125,7 +125,37 @@ function main(name, jobfunc, opt)
while index < max do
index = index + 1
table.insert(running_jobs_indices, index)
- scheduler.co_start_named(name .. '/' .. tostring(index), jobfunc, index)
+ scheduler.co_start_named(name .. '/' .. tostring(index), function(i)
+ try
+ {
+ function()
+ jobfunc(i)
+ end,
+ catch
+ {
+ function (errors)
+
+ -- stop timer and disable show waitchars first
+ stop = true
+
+ -- remove wait charactor
+ if showtips then
+ _print_backchars(backnum)
+ print("")
+ io.flush()
+ end
+
+ -- do exit callback
+ if opt.exit then
+ opt.exit(errors)
+ end
+
+ -- re-throw this errors and abort scheduler
+ raise(errors)
+ end
+ }
+ }
+ end, index)
end
end)
scheduler.co_group_wait(group_name)
@@ -139,4 +169,9 @@ function main(name, jobfunc, opt)
_print_backchars(backnum)
io.flush()
end
+
+ -- do exit callback
+ if opt.exit then
+ opt.exit()
+ end
end