diff options
| author | ruki <[email protected]> | 2019-11-06 00:43:54 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-11-05 22:23:24 +0800 |
| commit | 8e6b73d2016fd3a3bf658698e4eb10f82fbcc6f7 (patch) | |
| tree | 36ad703480f39117dfc6f60515b911c0f8190b2b /core/src | |
| parent | 3d8d86c9056c2ed4ba57e61ff0030f2749c847aa (diff) | |
register poller apis
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/io/poller_wait.c | 55 | ||||
| -rw-r--r-- | core/src/xmake/machine.c | 10 | ||||
| -rw-r--r-- | core/src/xmake/makefile | 1 |
3 files changed, 66 insertions, 0 deletions
diff --git a/core/src/xmake/io/poller_wait.c b/core/src/xmake/io/poller_wait.c new file mode 100644 index 000000000..e43a70bff --- /dev/null +++ b/core/src/xmake/io/poller_wait.c @@ -0,0 +1,55 @@ +/*!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_wait.c + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "poller_wait" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "poller.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +// io.poller_wait(sock, events) +tb_int_t xm_io_poller_wait(lua_State* lua) +{ + // check + tb_assert_and_check_return_val(lua, 0); + + // is user data? + if (!lua_isuserdata(lua, 1)) + return 0; + + // get socket + tb_socket_ref_t sock = (tb_socket_ref_t)lua_touserdata(lua, 1); + tb_check_return_val(sock, 0); + + // TODO + return 0; +} + diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index 835e10b73..faeadfe4f 100644 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -124,6 +124,12 @@ tb_int_t xm_io_socket_recv(lua_State* lua); tb_int_t xm_io_socket_recvfrom(lua_State* lua); tb_int_t xm_io_socket_close(lua_State* lua); +// the io/poller functions +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_wait(lua_State* lua); + // the path functions tb_int_t xm_path_relative(lua_State* lua); tb_int_t xm_path_absolute(lua_State* lua); @@ -269,6 +275,10 @@ static luaL_Reg const g_io_functions[] = , { "socket_recv", xm_io_socket_recv } , { "socket_recvfrom", xm_io_socket_recvfrom } , { "socket_close", xm_io_socket_close } +, { "poller_insert", xm_io_poller_insert } +, { "poller_modify", xm_io_poller_modify } +, { "poller_remove", xm_io_poller_remove } +, { "poller_wait", xm_io_poller_wait } , { tb_null, tb_null } }; diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index 960f5ef8b..61574c552 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -61,6 +61,7 @@ xmake_C_FILES += \ io/filelock_trylock \ io/filelock_close \ io/poller \ + io/poller_wait \ io/poller_insert \ io/poller_remove \ io/poller_modify \ |
