summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2019-12-16 22:34:06 +0800
committerruki <[email protected]>2019-12-16 09:24:36 +0800
commit4ed6741dd366d1e48d30356657bc77d40e0ac2ca (patch)
treee070e5be51847df31c5473cb9f3957fc5ea192d8 /core/src
parent77c589d08366ec183f03e54106f0899ec127feb9 (diff)
impl scheduler.stop
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/io/poller_spank.c48
-rw-r--r--core/src/xmake/machine.c2
-rw-r--r--core/src/xmake/makefile1
3 files changed, 51 insertions, 0 deletions
diff --git a/core/src/xmake/io/poller_spank.c b/core/src/xmake/io/poller_spank.c
new file mode 100644
index 000000000..e5f6ba5ab
--- /dev/null
+++ b/core/src/xmake/io/poller_spank.c
@@ -0,0 +1,48 @@
+/*!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_spank.c
+ *
+ */
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * trace
+ */
+#define TB_TRACE_MODULE_NAME "poller_spank"
+#define TB_TRACE_MODULE_DEBUG (0)
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+#include "poller.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * interfaces
+ */
+
+// io.poller_spank()
+tb_int_t xm_io_poller_spank(lua_State* lua)
+{
+ // check
+ tb_assert_and_check_return_val(lua, 0);
+
+ // spank the poller, break the tb_poller_wait() and return all events
+ tb_poller_spak(xm_io_poller());
+ return 0;
+}
+
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c
index 4fdc73204..28903ec3a 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_spank(lua_State* lua);
tb_int_t xm_io_poller_support(lua_State* lua);
tb_int_t xm_io_poller_wait(lua_State* lua);
@@ -279,6 +280,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_spank", xm_io_poller_spank }
, { "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 67a340933..935e210a6 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_spank \
io/poller_support \
io/socket_open \
io/socket_rawfd \