thread_mutex.proc_mutex refresh define

This commit is contained in:
hyzboy 2019-12-10 15:05:56 +08:00
parent 1bfb503e13
commit 2d9765839e
5 changed files with 10 additions and 16 deletions

View File

@ -62,8 +62,6 @@ typedef void * ExternalModulePointer;
#define pi_get dlsym #define pi_get dlsym
#define pi_close dlclose #define pi_close dlclose
typedef pthread_mutex_t hgl_thread_mutex;
#define hgl_stat64 stat #define hgl_stat64 stat
#define hgl_open64 open #define hgl_open64 open
#define hgl_lseek64 lseek #define hgl_lseek64 lseek

View File

@ -72,7 +72,7 @@ using ExternalModulePointer =HMODULE;
#define hgl_read64 _read #define hgl_read64 _read
#define hgl_write64 _write #define hgl_write64 _write
using hgl_thread_mutex =CRITICAL_SECTION; using thread_mutex_ptr =CRITICAL_SECTION;
using thread_ptr =HANDLE; using thread_ptr =HANDLE;
using rwlock_ptr =SRWLOCK; using rwlock_ptr =SRWLOCK;
using semaphore_ptr =HANDLE; using semaphore_ptr =HANDLE;
@ -80,5 +80,7 @@ using conv_var_ptr =CONDITION_VARIABLE;
#define THREAD_FUNC DWORD WINAPI #define THREAD_FUNC DWORD WINAPI
#define HGL_THREAD_DETACH_SELF #define HGL_THREAD_DETACH_SELF
using proc_mutex_ptr =HANDLE;
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
#endif//HGL_OS_WIN_INCLUDE #endif//HGL_OS_WIN_INCLUDE

View File

@ -9,7 +9,7 @@
namespace hgl namespace hgl
{ {
using hgl_thread_mutex =pthread_mutex_t; using thread_mutex_ptr =pthread_mutex_t;
using thread_ptr =pthread_t; using thread_ptr =pthread_t;
using rwlock_ptr =pthread_rwlock_t *; using rwlock_ptr =pthread_rwlock_t *;
@ -24,5 +24,7 @@ namespace hgl
#define THREAD_FUNC void * #define THREAD_FUNC void *
#define HGL_THREAD_DETACH_SELF pthread_detach(pthread_self()); #define HGL_THREAD_DETACH_SELF pthread_detach(pthread_self());
using proc_mutex_ptr =sem_t *;
}//namespace hgl }//namespace hgl
#endif//HGL_POSIX_THREAD_INCLUDE #endif//HGL_POSIX_THREAD_INCLUDE

View File

@ -1,11 +1,7 @@
#ifndef HGL_PROCESS_MUTEX_INCLUDE #ifndef HGL_PROCESS_MUTEX_INCLUDE
#define HGL_PROCESS_MUTEX_INCLUDE #define HGL_PROCESS_MUTEX_INCLUDE
#include<hgl/type/DataType.h> #include<hgl/platform/Platform.h>
#if HGL_OS!=HGL_OS_Windows
#include<semaphore.h>
#endif//HGL_OS!=HGL_OS_Windows
namespace hgl namespace hgl
{ {
@ -14,11 +10,7 @@ namespace hgl
*/ */
class ProcMutex ///进程排斥 class ProcMutex ///进程排斥
{ {
#if HGL_OS==HGL_OS_Windows proc_mutex_ptr lock;
void *lock;
#else
sem_t *lock;
#endif//HGL_OS==HGL_OS_Windows
public: public:

View File

@ -11,14 +11,14 @@ namespace hgl
*/ */
class ThreadMutex ///排斥访问类(仅当前进程) class ThreadMutex ///排斥访问类(仅当前进程)
{ {
hgl_thread_mutex ptr; thread_mutex_ptr ptr;
public: public:
ThreadMutex(); ///<本类构造函数 ThreadMutex(); ///<本类构造函数
virtual ~ThreadMutex(); ///<本类析构函数 virtual ~ThreadMutex(); ///<本类析构函数
hgl_thread_mutex *GetThreadMutex(){return &ptr;} thread_mutex_ptr *GetThreadMutex(){return &ptr;}
virtual void Lock(); ///<取得的控制权(如果对象处于排斥状态,则等待) virtual void Lock(); ///<取得的控制权(如果对象处于排斥状态,则等待)
virtual bool TryLock(); ///<尝试取得控制权 virtual bool TryLock(); ///<尝试取得控制权