diff options
| author | ruki <[email protected]> | 2025-08-28 23:14:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-08-28 23:14:13 +0800 |
| commit | 628371d0edea22eb177fa2b1a6b9f28e8c0cff2d (patch) | |
| tree | 2c8e834e76870f3cfa2e2b2b3b3342d69b0f83bf /core/src/xmake/thread/prefix.h | |
| parent | 8a331ab64fe560924b8bc3ab3dc4ac2831dd8920 (diff) | |
add thread queue
Diffstat (limited to 'core/src/xmake/thread/prefix.h')
| -rw-r--r-- | core/src/xmake/thread/prefix.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/core/src/xmake/thread/prefix.h b/core/src/xmake/thread/prefix.h index be06d952e..8fc303b10 100644 --- a/core/src/xmake/thread/prefix.h +++ b/core/src/xmake/thread/prefix.h @@ -63,6 +63,40 @@ typedef struct __xm_thread_semaphore_t }xm_thread_semaphore_t; +// the thread queue type +typedef struct __xm_thread_queue_t +{ + tb_queue_ref_t handle; + tb_atomic_t refn; + +}xm_thread_queue_t; + +// the thread queue item kind +typedef enum __xm_thread_queue_item_kind_e +{ + XM_THREAD_QUEUE_ITEM_NIL = 0, + XM_THREAD_QUEUE_ITEM_BOOL = 1, + XM_THREAD_QUEUE_ITEM_INT = 2, + XM_THREAD_QUEUE_ITEM_NUM = 3, + XM_THREAD_QUEUE_ITEM_STR = 4 + +}xm_thread_queue_item_kind_e; + +// the thread queue item type +typedef struct __xm_thread_queue_item_t +{ + tb_uint32_t kind : 3; + tb_uint32_t size : 29; + union + { + tb_char_t* string; + tb_bool_t boolean; + lua_Integer integer; + lua_Number number; + } u; + +}xm_thread_queue_item_t; + // get the thread event from arguments static __tb_inline__ xm_thread_event_t* xm_thread_event_get(lua_State* lua, tb_int_t index) { @@ -90,6 +124,15 @@ static __tb_inline__ xm_thread_semaphore_t* xm_thread_semaphore_get(lua_State* l return thread_semaphore; } +// get the thread queue from arguments +static __tb_inline__ xm_thread_queue_t* xm_thread_queue_get(lua_State* lua, tb_int_t index) +{ + xm_thread_queue_t* thread_queue = tb_null; + if (xm_lua_isinteger(lua, index)) thread_queue = (xm_thread_queue_t*)(tb_size_t)(tb_long_t)lua_tointeger(lua, index); + else if (xm_lua_ispointer(lua, index)) thread_queue = (xm_thread_queue_t*)xm_lua_topointer(lua, index); + return thread_queue; +} + #endif |
