summaryrefslogtreecommitdiff
path: root/core/src/xmake/thread/queue_push.c
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-09 19:11:32 +0800
committerruki <[email protected]>2025-11-09 19:44:18 +0800
commitc89c94bf89e98c8e42e786aacc0b334a57474179 (patch)
tree60b4964d58a5289e1444b2375ec5db1a93eccdd6 /core/src/xmake/thread/queue_push.c
parent3f9c6f27ee8f99d5c4393433e8863fec93da43e7 (diff)
format code
Diffstat (limited to 'core/src/xmake/thread/queue_push.c')
-rw-r--r--core/src/xmake/thread/queue_push.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/core/src/xmake/thread/queue_push.c b/core/src/xmake/thread/queue_push.c
index 8125f2b9a..058ac8f81 100644
--- a/core/src/xmake/thread/queue_push.c
+++ b/core/src/xmake/thread/queue_push.c
@@ -22,8 +22,8 @@
/* //////////////////////////////////////////////////////////////////////////////////////
* 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;
}
-