diff options
| author | ruki <[email protected]> | 2025-08-28 22:45:48 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-08-28 11:35:54 +0800 |
| commit | 8a331ab64fe560924b8bc3ab3dc4ac2831dd8920 (patch) | |
| tree | 1b7406be4f6db49c198d36d180b4f98ff8185847 /core/src/xmake/engine.c | |
| parent | a3ff692d028873e06cc9827e1ff72dc9ec8b54d4 (diff) | |
add thread semaphore
Diffstat (limited to 'core/src/xmake/engine.c')
| -rw-r--r-- | core/src/xmake/engine.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 24b95d1fd..850be59f4 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -361,6 +361,13 @@ tb_int_t xm_thread_event_post(lua_State* lua); tb_int_t xm_thread_event_wait(lua_State* lua); tb_int_t xm_thread_event_incref(lua_State* lua); +// the thread/semaphore functions +tb_int_t xm_thread_semaphore_init(lua_State* lua); +tb_int_t xm_thread_semaphore_exit(lua_State* lua); +tb_int_t xm_thread_semaphore_post(lua_State* lua); +tb_int_t xm_thread_semaphore_wait(lua_State* lua); +tb_int_t xm_thread_semaphore_incref(lua_State* lua); + // open cjson __tb_extern_c_enter__ tb_int_t luaopen_cjson(lua_State *l); @@ -650,23 +657,28 @@ static luaL_Reg const g_utils_functions[] = // the thread functions static luaL_Reg const g_thread_functions[] = { - { "thread_init", xm_thread_init } -, { "thread_exit", xm_thread_exit } -, { "thread_wait", xm_thread_wait } -, { "thread_resume", xm_thread_resume } -, { "thread_suspend", xm_thread_suspend } -, { "mutex_init", xm_thread_mutex_init } -, { "mutex_exit", xm_thread_mutex_exit } -, { "mutex_lock", xm_thread_mutex_lock } -, { "mutex_trylock", xm_thread_mutex_trylock } -, { "mutex_unlock", xm_thread_mutex_unlock } -, { "mutex_incref", xm_thread_mutex_incref } -, { "event_init", xm_thread_event_init } -, { "event_exit", xm_thread_event_exit } -, { "event_post", xm_thread_event_post } -, { "event_wait", xm_thread_event_wait } -, { "event_incref", xm_thread_event_incref } -, { tb_null, tb_null } + { "thread_init", xm_thread_init } +, { "thread_exit", xm_thread_exit } +, { "thread_wait", xm_thread_wait } +, { "thread_resume", xm_thread_resume } +, { "thread_suspend", xm_thread_suspend } +, { "mutex_init", xm_thread_mutex_init } +, { "mutex_exit", xm_thread_mutex_exit } +, { "mutex_lock", xm_thread_mutex_lock } +, { "mutex_trylock", xm_thread_mutex_trylock } +, { "mutex_unlock", xm_thread_mutex_unlock } +, { "mutex_incref", xm_thread_mutex_incref } +, { "event_init", xm_thread_event_init } +, { "event_exit", xm_thread_event_exit } +, { "event_post", xm_thread_event_post } +, { "event_wait", xm_thread_event_wait } +, { "event_incref", xm_thread_event_incref } +, { "semaphore_init", xm_thread_semaphore_init } +, { "semaphore_exit", xm_thread_semaphore_exit } +, { "semaphore_post", xm_thread_semaphore_post } +, { "semaphore_wait", xm_thread_semaphore_wait } +, { "semaphore_incref", xm_thread_semaphore_incref } +, { tb_null, tb_null } }; // the lua global instance for signal handler |
