summaryrefslogtreecommitdiff
path: root/core/src/xmake/thread/prefix.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/xmake/thread/prefix.h')
-rw-r--r--core/src/xmake/thread/prefix.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/src/xmake/thread/prefix.h b/core/src/xmake/thread/prefix.h
index 6c25b234e..be06d952e 100644
--- a/core/src/xmake/thread/prefix.h
+++ b/core/src/xmake/thread/prefix.h
@@ -55,6 +55,14 @@ typedef struct __xm_thread_mutex_t
}xm_thread_mutex_t;
+// the thread semaphore type
+typedef struct __xm_thread_semaphore_t
+{
+ tb_semaphore_ref_t handle;
+ tb_atomic_t refn;
+
+}xm_thread_semaphore_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)
{
@@ -73,6 +81,15 @@ static __tb_inline__ xm_thread_mutex_t* xm_thread_mutex_get(lua_State* lua, tb_i
return thread_mutex;
}
+// get the thread semaphore from arguments
+static __tb_inline__ xm_thread_semaphore_t* xm_thread_semaphore_get(lua_State* lua, tb_int_t index)
+{
+ xm_thread_semaphore_t* thread_semaphore = tb_null;
+ if (xm_lua_isinteger(lua, index)) thread_semaphore = (xm_thread_semaphore_t*)(tb_size_t)(tb_long_t)lua_tointeger(lua, index);
+ else if (xm_lua_ispointer(lua, index)) thread_semaphore = (xm_thread_semaphore_t*)xm_lua_topointer(lua, index);
+ return thread_semaphore;
+}
+
#endif