diff options
| author | ruki <[email protected]> | 2020-02-04 00:51:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-07 22:45:56 +0800 |
| commit | ff45e17b26152544961e52671d61aa5f8e838d38 (patch) | |
| tree | 59e0272bfc34e4dc1d5c488809eeeeaf7ee08ac1 | |
| parent | 53e371a2b77b91f85275293f451f51b755e3a479 (diff) | |
use scheduler.runloop as maintask
| -rw-r--r-- | tests/modules/pipe/sched_echo_client.lua | 1 | ||||
| -rw-r--r-- | tests/modules/pipe/sched_echo_server.lua | 1 | ||||
| -rw-r--r-- | tests/modules/pipe/sched_pipe_pair.lua | 1 | ||||
| -rw-r--r-- | tests/modules/process/sched_process.lua | 1 | ||||
| -rw-r--r-- | tests/modules/process/sched_process_pipe.lua | 1 | ||||
| -rw-r--r-- | tests/modules/scheduler/runjobs.lua | 9 | ||||
| -rw-r--r-- | tests/modules/scheduler/sleep.lua | 1 | ||||
| -rw-r--r-- | tests/modules/scheduler/test.lua | 1 | ||||
| -rw-r--r-- | tests/modules/scheduler/yield.lua | 1 | ||||
| -rw-r--r-- | tests/modules/socket/sched_tcp/echo_server.lua | 1 | ||||
| -rw-r--r-- | tests/modules/socket/sched_tcp/file_client.lua | 1 | ||||
| -rw-r--r-- | tests/modules/socket/sched_tcp/file_server.lua | 1 | ||||
| -rw-r--r-- | tests/modules/socket/sched_udp/echo_client.lua | 1 | ||||
| -rw-r--r-- | tests/modules/socket/sched_udp/echo_server.lua | 1 | ||||
| -rw-r--r-- | xmake/core/main.lua | 9 | ||||
| -rw-r--r-- | xmake/modules/private/async/runjobs.lua | 27 |
16 files changed, 44 insertions, 14 deletions
diff --git a/tests/modules/pipe/sched_echo_client.lua b/tests/modules/pipe/sched_echo_client.lua index 725f4cc55..06a95a674 100644 --- a/tests/modules/pipe/sched_echo_client.lua +++ b/tests/modules/pipe/sched_echo_client.lua @@ -20,5 +20,4 @@ function main(count) for i = 1, count do scheduler.co_start(_session, i) end - scheduler.runloop() end diff --git a/tests/modules/pipe/sched_echo_server.lua b/tests/modules/pipe/sched_echo_server.lua index 8da176c7e..8a5b0b2a9 100644 --- a/tests/modules/pipe/sched_echo_server.lua +++ b/tests/modules/pipe/sched_echo_server.lua @@ -28,5 +28,4 @@ function main(count) for i = 1, count do scheduler.co_start(_session, i) end - scheduler.runloop() end diff --git a/tests/modules/pipe/sched_pipe_pair.lua b/tests/modules/pipe/sched_pipe_pair.lua index ddfe445e3..84a055cd9 100644 --- a/tests/modules/pipe/sched_pipe_pair.lua +++ b/tests/modules/pipe/sched_pipe_pair.lua @@ -34,5 +34,4 @@ function main(count) for i = 1, count do scheduler.co_start(_session, i) end - scheduler.runloop() end diff --git a/tests/modules/process/sched_process.lua b/tests/modules/process/sched_process.lua index c9b629b03..a94e25b65 100644 --- a/tests/modules/process/sched_process.lua +++ b/tests/modules/process/sched_process.lua @@ -11,5 +11,4 @@ function main(program, ...) for i = 1, 10 do scheduler.co_start(_session, i, program, ...) end - scheduler.runloop() end diff --git a/tests/modules/process/sched_process_pipe.lua b/tests/modules/process/sched_process_pipe.lua index deb350372..de87f5f4e 100644 --- a/tests/modules/process/sched_process_pipe.lua +++ b/tests/modules/process/sched_process_pipe.lua @@ -42,5 +42,4 @@ function main(program, ...) for i = 1, 10 do scheduler.co_start(_session, i, program, ...) end - scheduler.runloop() end diff --git a/tests/modules/scheduler/runjobs.lua b/tests/modules/scheduler/runjobs.lua new file mode 100644 index 000000000..505573190 --- /dev/null +++ b/tests/modules/scheduler/runjobs.lua @@ -0,0 +1,9 @@ +import("private.async.runjobs") + +function _jobfunc(index) +end + +function main() + runjobs(_jobfunc, 100, 4) +end + diff --git a/tests/modules/scheduler/sleep.lua b/tests/modules/scheduler/sleep.lua index 5c6976a07..3faa1cfff 100644 --- a/tests/modules/scheduler/sleep.lua +++ b/tests/modules/scheduler/sleep.lua @@ -21,6 +21,5 @@ function main() scheduler.co_start(_session1, i) scheduler.co_start(_session2, i) end - scheduler.runloop() end diff --git a/tests/modules/scheduler/test.lua b/tests/modules/scheduler/test.lua index d7f09bd96..07af3dd80 100644 --- a/tests/modules/scheduler/test.lua +++ b/tests/modules/scheduler/test.lua @@ -27,7 +27,6 @@ function test_sleep(t) for i = 1, 3 do scheduler.co_start(task) end - scheduler.runloop() end function test_yield(t) diff --git a/tests/modules/scheduler/yield.lua b/tests/modules/scheduler/yield.lua index f884a0199..c8d6663d3 100644 --- a/tests/modules/scheduler/yield.lua +++ b/tests/modules/scheduler/yield.lua @@ -10,6 +10,5 @@ function main() for i = 1, 10 do scheduler.co_start(_session, i) end - scheduler.runloop() end diff --git a/tests/modules/socket/sched_tcp/echo_server.lua b/tests/modules/socket/sched_tcp/echo_server.lua index 118b932f8..82a2044d8 100644 --- a/tests/modules/socket/sched_tcp/echo_server.lua +++ b/tests/modules/socket/sched_tcp/echo_server.lua @@ -57,5 +57,4 @@ end function main() scheduler.co_start(_listen, "127.0.0.1", 9001) - scheduler.runloop() end diff --git a/tests/modules/socket/sched_tcp/file_client.lua b/tests/modules/socket/sched_tcp/file_client.lua index 311a80eab..1afdceb9b 100644 --- a/tests/modules/socket/sched_tcp/file_client.lua +++ b/tests/modules/socket/sched_tcp/file_client.lua @@ -39,5 +39,4 @@ function main(count) for i = 1, count do scheduler.co_start(_session, "127.0.0.1", 9090) end - scheduler.runloop() end diff --git a/tests/modules/socket/sched_tcp/file_server.lua b/tests/modules/socket/sched_tcp/file_server.lua index 6d2c7c975..c1ae25d33 100644 --- a/tests/modules/socket/sched_tcp/file_server.lua +++ b/tests/modules/socket/sched_tcp/file_server.lua @@ -29,5 +29,4 @@ end function main(filepath) scheduler.co_start(_listen, "127.0.0.1", 9090, filepath) - scheduler.runloop() end diff --git a/tests/modules/socket/sched_udp/echo_client.lua b/tests/modules/socket/sched_udp/echo_client.lua index 7ba49042c..77515812d 100644 --- a/tests/modules/socket/sched_udp/echo_client.lua +++ b/tests/modules/socket/sched_udp/echo_client.lua @@ -15,5 +15,4 @@ end function main(data) scheduler.co_start(_session, "127.0.0.1", 9001, data) - scheduler.runloop() end diff --git a/tests/modules/socket/sched_udp/echo_server.lua b/tests/modules/socket/sched_udp/echo_server.lua index fd2a8d96d..21f8c887d 100644 --- a/tests/modules/socket/sched_udp/echo_server.lua +++ b/tests/modules/socket/sched_udp/echo_server.lua @@ -18,5 +18,4 @@ end function main() scheduler.co_start(_listen, "127.0.0.1", 9001) - scheduler.runloop() end diff --git a/xmake/core/main.lua b/xmake/core/main.lua index 4a8c05b7a..c4eb4aee5 100644 --- a/xmake/core/main.lua +++ b/xmake/core/main.lua @@ -33,6 +33,7 @@ local deprecated = require("base/deprecated") local privilege = require("base/privilege") local task = require("base/task") local colors = require("base/colors") +local scheduler = require("base/scheduler") local theme = require("theme/theme") local project = require("project/project") local history = require("project/history") @@ -253,7 +254,13 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily. end -- run task - ok, errors = taskinst:run() + scheduler:co_start_named("xmake " .. taskname, function () + local ok, errors = taskinst:run() + if not ok then + os.raise(errors) + end + end) + ok, errors = scheduler:runloop() if not ok then utils.error(errors) return -1 diff --git a/xmake/modules/private/async/runjobs.lua b/xmake/modules/private/async/runjobs.lua new file mode 100644 index 000000000..07680003c --- /dev/null +++ b/xmake/modules/private/async/runjobs.lua @@ -0,0 +1,27 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file runjobs.lua +-- + +-- imports +import("core.base.scheduler") + +-- main entry +function main(jobfunc, total, comax) + +end |
