summaryrefslogtreecommitdiff
path: root/core/src/xmake
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-05 00:41:19 +0800
committerruki <[email protected]>2020-02-07 22:45:56 +0800
commit71e29f82a04a6a799997eda741c318969c57354b (patch)
treeb6c3e22727a755c8b0edc25810be62b39bb49aba /core/src/xmake
parentccfc8d33cbd80807a3980304b0a0151af2318909 (diff)
remove process.waitlist
Diffstat (limited to 'core/src/xmake')
-rw-r--r--core/src/xmake/machine.c2
-rw-r--r--core/src/xmake/makefile1
-rw-r--r--core/src/xmake/process/waitlist.c148
3 files changed, 0 insertions, 151 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c
index 2bcafad54..5d67992e0 100644
--- a/core/src/xmake/machine.c
+++ b/core/src/xmake/machine.c
@@ -171,7 +171,6 @@ tb_int_t xm_string_startswith(lua_State* lua);
// the process functions
tb_int_t xm_process_open(lua_State* lua);
tb_int_t xm_process_openv(lua_State* lua);
-tb_int_t xm_process_waitlist(lua_State* lua);
tb_int_t xm_process_wait(lua_State* lua);
tb_int_t xm_process_close(lua_State* lua);
@@ -335,7 +334,6 @@ static luaL_Reg const g_process_functions[] =
{
{ "open", xm_process_open }
, { "openv", xm_process_openv }
-, { "waitlist", xm_process_waitlist }
, { "wait", xm_process_wait }
, { "close", xm_process_close }
, { tb_null, tb_null }
diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile
index 44105cd32..d7fd339b7 100644
--- a/core/src/xmake/makefile
+++ b/core/src/xmake/makefile
@@ -100,7 +100,6 @@ xmake_C_FILES += \
process/open \
process/openv \
process/wait \
- process/waitlist \
process/close \
sandbox/interactive \
semver/parse \
diff --git a/core/src/xmake/process/waitlist.c b/core/src/xmake/process/waitlist.c
deleted file mode 100644
index be8d4b406..000000000
--- a/core/src/xmake/process/waitlist.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*!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 waitlist.c
- *
- */
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * trace
- */
-#define TB_TRACE_MODULE_NAME "process.waitlist"
-#define TB_TRACE_MODULE_DEBUG (0)
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * includes
- */
-#include "prefix.h"
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * macros
- */
-
-// the max waited processes count at same time
-#define XM_PROCESS_WAIT_MAXN (512)
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * implementation
- */
-
-/* count, list = process.waitlist(proclist, timeout)
- *
- * count:
- *
- * the finished count: > 0
- * timeout: 0
- * failed: -1
- *
- * for _, procinfo in ipairs(list) do
- * print("proc: ", procinfo[1])
- * print("index: ", procinfo[2])
- * print("status: ", procinfo[3])
- * end
- */
-tb_int_t xm_process_waitlist(lua_State* lua)
-{
- // check
- tb_assert_and_check_return_val(lua, 0);
-
- // is table?
- if (!lua_istable(lua, 1))
- {
- // error
- lua_pushfstring(lua, "invalid argument type(%s) for process.waitlist", luaL_typename(lua, 1));
- lua_error(lua);
- return 0;
- }
-
- // get the processes count
- tb_long_t count = lua_objlen(lua, 1);
- if (count <= 0 || count > XM_PROCESS_WAIT_MAXN)
- {
- // error
- lua_pushfstring(lua, "invalid process count(%d) for process.waitlist", count);
- lua_error(lua);
- return 0;
- }
-
- // get the processes
- tb_int_t i = 0;
- tb_process_ref_t processes[XM_PROCESS_WAIT_MAXN + 1];
- for (i = 0; i < count; i++)
- {
- // get proclist[i]
- lua_pushinteger(lua, i + 1);
- lua_gettable(lua, 1);
-
- // is userdata?
- if (lua_isuserdata(lua, -1))
- {
- // save this process
- processes[i] = (tb_process_ref_t)lua_touserdata(lua, -1);
- if (!processes[i])
- {
- // error
- lua_pushfstring(lua, "process[%d] is null for process.waitlist", i);
- lua_error(lua);
- }
- }
- else
- {
- // error
- lua_pushfstring(lua, "invalid process[%d] type(%s) for process.waitlist", i, luaL_typename(lua, -1));
- lua_error(lua);
- }
-
- // pop it
- lua_pop(lua, 1);
- }
-
- // end
- processes[count] = tb_null;
-
- // get the timeout
- tb_long_t timeout = (tb_long_t)luaL_checkinteger(lua, 2);
-
- // wait it
- tb_process_waitinfo_t infolist[XM_PROCESS_WAIT_MAXN];
- tb_long_t infosize = tb_process_waitlist(processes, infolist, tb_arrayn(infolist), timeout);
-
- // save process info count
- lua_pushinteger(lua, infosize);
- if (infosize >= 0)
- {
- // save process info list
- lua_newtable(lua);
- for (i = 0; i < infosize; i++)
- {
- // save one process info
- lua_newtable(lua);
- lua_pushlightuserdata(lua, (tb_pointer_t)infolist[i].process);
- lua_rawseti(lua, -2, 1);
- lua_pushinteger(lua, infolist[i].index + 1);
- lua_rawseti(lua, -2, 2);
- lua_pushinteger(lua, infolist[i].status);
- lua_rawseti(lua, -2, 3);
-
- lua_rawseti(lua, -2, i + 1);
- }
- }
- else lua_pushnil(lua);
-
- // ok
- return 2;
-}