2019-08-19 19:19:58 +08:00
|
|
|
#ifndef HGL_PROCESS_MUTEX_INCLUDE
|
|
|
|
#define HGL_PROCESS_MUTEX_INCLUDE
|
|
|
|
|
2019-12-10 15:05:56 +08:00
|
|
|
#include<hgl/platform/Platform.h>
|
2019-08-19 19:19:58 +08:00
|
|
|
|
|
|
|
namespace hgl
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 进程排斥
|
|
|
|
*/
|
|
|
|
class ProcMutex ///进程排斥
|
|
|
|
{
|
2020-02-08 15:03:07 +08:00
|
|
|
proc_mutex_ptr lock;
|
2019-08-19 19:19:58 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ProcMutex();
|
|
|
|
~ProcMutex(){Clear();}
|
|
|
|
|
|
|
|
bool Create(const os_char *); ///<创建进程排斥
|
|
|
|
void Clear(); ///<清除进程排斥
|
|
|
|
|
|
|
|
bool Lock(); ///<锁定
|
|
|
|
bool TryLock(); ///<尝试锁定
|
|
|
|
|
|
|
|
bool Unlock(); ///<解锁
|
|
|
|
};//class ProcMutex
|
|
|
|
}//namespace hgl
|
|
|
|
#endif//HGL_PROCESS_MUTEX_INCLUDE
|