This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

56
thread/MUTEX.HPP Normal file
View File

@@ -0,0 +1,56 @@
#ifndef _THREAD_MUTEX_HPP_
#define _THREAD_MUTEX_HPP_
#ifndef _COMMON_STDIO_HPP_
#include <common/stdio.hpp>
#endif
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
class Mutex
{
public:
Mutex(void);
Mutex(const String &mutexName,BOOL postFixup=TRUE);
virtual ~Mutex();
WORD requestMutex(DWORD waitTime=INFINITE,WORD alertable=FALSE)const;
WORD releaseMutex(void)const;
WORD closeMutex(void);
BOOL openMutex(const String &strMutexName);
const String &mutexName(void)const;
BOOL isOkay(void)const;
private:
HANDLE mhMutex;
String mMutexName;
};
inline
Mutex::~Mutex()
{
closeMutex();
}
inline
BOOL Mutex::openMutex(const String &strMutexName)
{
closeMutex();
mMutexName=strMutexName;
mhMutex=::OpenMutex(EVENT_ALL_ACCESS,TRUE,(LPSTR)(String&)strMutexName);
return isOkay();
}
inline
const String &Mutex::mutexName(void)const
{
return mMutexName;
}
inline
BOOL Mutex::isOkay(void)const
{
return mhMutex?TRUE:FALSE;
}
#endif