summaryrefslogtreecommitdiff
path: root/core/src/xmake/thread/queue_push.c
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-10 06:35:04 +0800
committerGitHub <[email protected]>2025-11-10 06:35:04 +0800
commit2b01e46fcf619aaecb8435b0fac975e3aff0587f (patch)
tree8f005a8dfc3272e9f027560e5e1b5881a7a8bc70 /core/src/xmake/thread/queue_push.c
parenta1b0ec856e2c22aac84022feb05b6687912e3d6e (diff)
parent2c387895657ae13cd717d7f42f5baed5eb028a8e (diff)
Merge pull request #7008 from xmake-io/format
format code
Diffstat (limited to 'core/src/xmake/thread/queue_push.c')
-rw-r--r--core/src/xmake/thread/queue_push.c51
1 files changed, 18 insertions, 33 deletions
diff --git a/core/src/xmake/thread/queue_push.c b/core/src/xmake/thread/queue_push.c
index 8125f2b9a..0a9ff63e1 100644
--- a/core/src/xmake/thread/queue_push.c
+++ b/core/src/xmake/thread/queue_push.c
@@ -15,15 +15,15 @@
* Copyright (C) 2015-present, Xmake Open Source Community.
*
* @author ruki
- * @file thread_queue_push.c
+ * @file queue_push.c
*
*/
/* //////////////////////////////////////////////////////////////////////////////////////
* trace
*/
-#define TB_TRACE_MODULE_NAME "thread_queue"
-#define TB_TRACE_MODULE_DEBUG (0)
+#define TB_TRACE_MODULE_NAME "thread_queue"
+#define TB_TRACE_MODULE_DEBUG (0)
/* //////////////////////////////////////////////////////////////////////////////////////
* includes
@@ -33,57 +33,43 @@
/* //////////////////////////////////////////////////////////////////////////////////////
* implementation
*/
-tb_int_t xm_thread_queue_push(lua_State* lua)
-{
+tb_int_t xm_thread_queue_push(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
- xm_thread_queue_t* thread_queue = xm_thread_queue_get(lua, 1);
+ xm_thread_queue_t *thread_queue = xm_thread_queue_get(lua, 1);
tb_assert_and_check_return_val(thread_queue && thread_queue->handle, 0);
- if (tb_queue_full(thread_queue->handle))
- {
+ if (tb_queue_full(thread_queue->handle)) {
lua_pushboolean(lua, tb_false);
lua_pushliteral(lua, "the thread queue is full");
return 2;
}
xm_thread_value_t item;
- if (lua_isstring(lua, 2))
- {
- size_t data_size = 0;
- tb_char_t const* data = luaL_checklstring(lua, 2, &data_size);
+ if (lua_isstring(lua, 2)) {
+ size_t data_size = 0;
+ tb_char_t const *data = luaL_checklstring(lua, 2, &data_size);
tb_assert_and_check_return_val(data, 0);
item.kind = (tb_uint32_t)XM_THREAD_VALUE_STR;
item.size = (tb_uint32_t)data_size;
- if (data_size)
- {
+ if (data_size) {
item.u.string = tb_malloc_cstr(data_size);
tb_assert_and_check_return_val(item.u.string, 0);
tb_memcpy(item.u.string, data, data_size);
}
- }
- else if (xm_lua_isinteger(lua, 2))
- {
- item.kind = (tb_uint32_t)XM_THREAD_VALUE_INT;
+ } else if (xm_lua_isinteger(lua, 2)) {
+ item.kind = (tb_uint32_t)XM_THREAD_VALUE_INT;
item.u.integer = lua_tointeger(lua, 2);
- }
- else if (lua_isnumber(lua, 2))
- {
- item.kind = (tb_uint32_t)XM_THREAD_VALUE_NUM;
+ } else if (lua_isnumber(lua, 2)) {
+ item.kind = (tb_uint32_t)XM_THREAD_VALUE_NUM;
item.u.number = lua_tonumber(lua, 2);
- }
- else if (lua_isboolean(lua, 2))
- {
- item.kind = (tb_uint32_t)XM_THREAD_VALUE_BOOL;
+ } else if (lua_isboolean(lua, 2)) {
+ item.kind = (tb_uint32_t)XM_THREAD_VALUE_BOOL;
item.u.boolean = lua_toboolean(lua, 2);
- }
- else if (lua_isnil(lua, 2))
- {
+ } else if (lua_isnil(lua, 2)) {
item.kind = (tb_uint32_t)XM_THREAD_VALUE_NIL;
- }
- else
- {
+ } else {
lua_pushboolean(lua, tb_false);
lua_pushliteral(lua, "unsupported thread queue item");
return 2;
@@ -93,4 +79,3 @@ tb_int_t xm_thread_queue_push(lua_State* lua)
lua_pushboolean(lua, tb_true);
return 1;
}
-