diff --git a/inc/hgl/platform/os/Linux.h b/inc/hgl/platform/os/Linux.h index ede3759..8e6e820 100644 --- a/inc/hgl/platform/os/Linux.h +++ b/inc/hgl/platform/os/Linux.h @@ -50,7 +50,7 @@ inline T *hgl_aligned_malloc(size_t n) } #define OS_EXTERNAL_H -typedef void * ExternalModulePointer; +using ExternalModulePointer =void *; #define pi_get dlsym #define pi_close dlclose diff --git a/inc/hgl/platform/os/MSWindows.h b/inc/hgl/platform/os/MSWindows.h index 997e0bd..6f2ebf8 100644 --- a/inc/hgl/platform/os/MSWindows.h +++ b/inc/hgl/platform/os/MSWindows.h @@ -59,7 +59,7 @@ using os_char =wchar_t; #endif// #define OS_EXTERNAL_H -typedef HMODULE ExternalModulePointer; +using ExternalModulePointer =HMODULE; #define pi_get GetProcAddress #define pi_close FreeLibrary @@ -74,6 +74,10 @@ typedef HMODULE ExternalModulePointer; using hgl_thread_mutex =CRITICAL_SECTION; using thread_ptr =HANDLE; +using rwlock_ptr =SRWLOCK; +using semaphore_ptr =HANDLE; +using conv_var_ptr =CONDITION_VARIABLE; + #define THREAD_FUNC DWORD WINAPI #define HGL_THREAD_DETACH_SELF //-------------------------------------------------------------------------------------------------- diff --git a/inc/hgl/platform/os/PosixThread.h b/inc/hgl/platform/os/PosixThread.h index 65842a4..32288b7 100644 --- a/inc/hgl/platform/os/PosixThread.h +++ b/inc/hgl/platform/os/PosixThread.h @@ -3,13 +3,26 @@ #include +#ifdef __APPLE__ +#include +#endif//__APPLE__ + namespace hgl { using hgl_thread_mutex =pthread_mutex_t; using thread_ptr =pthread_t; - using THREAD_FUNC =void *; + using rwlock_ptr =pthread_rwlock_t *; +#ifdef __APPLE__ + using semaphore_ptr =dispatch_semaphore_t *; +#else + using semaphore_ptr =sem_t *; +#endif// + + using cond_var_ptr =pthread_cond_t *; + + #define THREAD_FUNC void * #define HGL_THREAD_DETACH_SELF pthread_detach(pthread_self()); }//namespace hgl #endif//HGL_POSIX_THREAD_INCLUDE diff --git a/inc/hgl/thread/CondVar.h b/inc/hgl/thread/CondVar.h index 0cfa6a2..e69762e 100644 --- a/inc/hgl/thread/CondVar.h +++ b/inc/hgl/thread/CondVar.h @@ -12,7 +12,7 @@ namespace hgl */ class CondVar { - void *cond_var; + conv_var_ptr *cond_var; public: diff --git a/inc/hgl/thread/RWLock.h b/inc/hgl/thread/RWLock.h index 3128a8e..a87a29b 100644 --- a/inc/hgl/thread/RWLock.h +++ b/inc/hgl/thread/RWLock.h @@ -9,14 +9,14 @@ namespace hgl */ class RWLock ///读写锁/共享锁 { - void *lock; + rwlock_ptr *lock; public: RWLock(); virtual ~RWLock(); - void *GetRWLock(){ return lock; } ///<返回操作系级锁 + rwlock_ptr *GetRWLock(){ return lock; } ///<返回操作系级锁 bool TryReadLock(); ///<尝试读(共享访问)锁定 bool ReadLock(); ///<读(共享访问)锁定 diff --git a/inc/hgl/thread/Semaphore.h b/inc/hgl/thread/Semaphore.h index ae6ca3f..fd13885 100644 --- a/inc/hgl/thread/Semaphore.h +++ b/inc/hgl/thread/Semaphore.h @@ -1,9 +1,7 @@ #ifndef HGL_SEMAPHORE_INCLUDE #define HGL_SEMAPHORE_INCLUDE -#ifdef __APPLE__ -#include -#endif//__APPLE__ +#include namespace hgl { @@ -13,11 +11,7 @@ namespace hgl */ class Semaphore ///信号 { -#ifdef __APPLE__ - dispatch_semaphore_t ptr; -#else - void *ptr; -#endif//__APPLE__ + semaphore_ptr ptr; public: