diff --git a/inc/hgl/platform/os/BSD.h b/inc/hgl/platform/os/BSD.h index 6bf3aef..172351e 100644 --- a/inc/hgl/platform/os/BSD.h +++ b/inc/hgl/platform/os/BSD.h @@ -62,8 +62,6 @@ typedef void * ExternalModulePointer; #define pi_get dlsym #define pi_close dlclose -typedef pthread_mutex_t hgl_thread_mutex; - #define hgl_stat64 stat #define hgl_open64 open #define hgl_lseek64 lseek diff --git a/inc/hgl/platform/os/MSWindows.h b/inc/hgl/platform/os/MSWindows.h index 6f2ebf8..af1d17f 100644 --- a/inc/hgl/platform/os/MSWindows.h +++ b/inc/hgl/platform/os/MSWindows.h @@ -72,7 +72,7 @@ using ExternalModulePointer =HMODULE; #define hgl_read64 _read #define hgl_write64 _write -using hgl_thread_mutex =CRITICAL_SECTION; +using thread_mutex_ptr =CRITICAL_SECTION; using thread_ptr =HANDLE; using rwlock_ptr =SRWLOCK; using semaphore_ptr =HANDLE; @@ -80,5 +80,7 @@ using conv_var_ptr =CONDITION_VARIABLE; #define THREAD_FUNC DWORD WINAPI #define HGL_THREAD_DETACH_SELF + +using proc_mutex_ptr =HANDLE; //-------------------------------------------------------------------------------------------------- #endif//HGL_OS_WIN_INCLUDE diff --git a/inc/hgl/platform/os/PosixThread.h b/inc/hgl/platform/os/PosixThread.h index 32288b7..d9ee4ad 100644 --- a/inc/hgl/platform/os/PosixThread.h +++ b/inc/hgl/platform/os/PosixThread.h @@ -9,7 +9,7 @@ namespace hgl { - using hgl_thread_mutex =pthread_mutex_t; + using thread_mutex_ptr =pthread_mutex_t; using thread_ptr =pthread_t; using rwlock_ptr =pthread_rwlock_t *; @@ -24,5 +24,7 @@ namespace hgl #define THREAD_FUNC void * #define HGL_THREAD_DETACH_SELF pthread_detach(pthread_self()); + + using proc_mutex_ptr =sem_t *; }//namespace hgl #endif//HGL_POSIX_THREAD_INCLUDE diff --git a/inc/hgl/proc/ProcMutex.h b/inc/hgl/proc/ProcMutex.h index e24bcbb..5818ae9 100644 --- a/inc/hgl/proc/ProcMutex.h +++ b/inc/hgl/proc/ProcMutex.h @@ -1,11 +1,7 @@ #ifndef HGL_PROCESS_MUTEX_INCLUDE #define HGL_PROCESS_MUTEX_INCLUDE -#include - -#if HGL_OS!=HGL_OS_Windows - #include -#endif//HGL_OS!=HGL_OS_Windows +#include namespace hgl { @@ -14,11 +10,7 @@ namespace hgl */ class ProcMutex ///进程排斥 { -#if HGL_OS==HGL_OS_Windows - void *lock; -#else - sem_t *lock; -#endif//HGL_OS==HGL_OS_Windows + proc_mutex_ptr lock; public: diff --git a/inc/hgl/thread/ThreadMutex.h b/inc/hgl/thread/ThreadMutex.h index 9773db8..e947447 100644 --- a/inc/hgl/thread/ThreadMutex.h +++ b/inc/hgl/thread/ThreadMutex.h @@ -11,14 +11,14 @@ namespace hgl */ class ThreadMutex ///排斥访问类(仅当前进程) { - hgl_thread_mutex ptr; + thread_mutex_ptr ptr; public: ThreadMutex(); ///<本类构造函数 virtual ~ThreadMutex(); ///<本类析构函数 - hgl_thread_mutex *GetThreadMutex(){return &ptr;} + thread_mutex_ptr *GetThreadMutex(){return &ptr;} virtual void Lock(); ///<取得的控制权(如果对象处于排斥状态,则等待) virtual bool TryLock(); ///<尝试取得控制权