diff options
| author | ruki <[email protected]> | 2019-12-13 00:54:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-12-12 23:29:13 +0800 |
| commit | 48c503cbca85ecea9e2ef9b5215f2e5c99c8bb24 (patch) | |
| tree | feffd02ceb2904d256f5216a93c09a5f500c9c62 /core/src | |
| parent | 880b3b96f8222a027b0387bd1bfbbd793267d5a6 (diff) | |
add poller.support
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/io/poller_support.c | 51 | ||||
| -rw-r--r-- | core/src/xmake/machine.c | 2 | ||||
| -rw-r--r-- | core/src/xmake/makefile | 1 |
3 files changed, 54 insertions, 0 deletions
diff --git a/core/src/xmake/io/poller_support.c b/core/src/xmake/io/poller_support.c new file mode 100644 index 000000000..b3b349242 --- /dev/null +++ b/core/src/xmake/io/poller_support.c @@ -0,0 +1,51 @@ +/*!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 - 2019, TBOOX Open Source Group. + * + * @author ruki + * @file poller_support.c + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "poller_support" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "poller.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +// io.poller_support(events) +tb_int_t xm_io_poller_support(lua_State* lua) +{ + // check + tb_assert_and_check_return_val(lua, 0); + + // get events + tb_size_t events = (tb_size_t)luaL_checknumber(lua, 1); + + // support events for poller + lua_pushboolean(lua, tb_poller_support(xm_io_poller(), events)); + return 1; +} + diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index dd606f0b6..4fdc73204 100644 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -128,6 +128,7 @@ tb_int_t xm_io_socket_close(lua_State* lua); tb_int_t xm_io_poller_insert(lua_State* lua); tb_int_t xm_io_poller_modify(lua_State* lua); tb_int_t xm_io_poller_remove(lua_State* lua); +tb_int_t xm_io_poller_support(lua_State* lua); tb_int_t xm_io_poller_wait(lua_State* lua); // the path functions @@ -278,6 +279,7 @@ static luaL_Reg const g_io_functions[] = , { "poller_insert", xm_io_poller_insert } , { "poller_modify", xm_io_poller_modify } , { "poller_remove", xm_io_poller_remove } +, { "poller_support", xm_io_poller_support } , { "poller_wait", xm_io_poller_wait } , { tb_null, tb_null } }; diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index 9c2a5d15b..67a340933 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -65,6 +65,7 @@ xmake_C_FILES += \ io/poller_insert \ io/poller_remove \ io/poller_modify \ + io/poller_support \ io/socket_open \ io/socket_rawfd \ io/socket_wait \ |
