mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 20:43:00 +00:00
Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.
This commit is contained in:
parent
b94e2d8ca0
commit
c2c66aff7d
24198 changed files with 0 additions and 37285 deletions
78
modules/rosapps/applications/fraginator/Mutex.h
Normal file
78
modules/rosapps/applications/fraginator/Mutex.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Mutex
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MUTEX_H
|
||||
#define MUTEX_H
|
||||
|
||||
|
||||
#include "Unfrag.h"
|
||||
|
||||
|
||||
class Mutex
|
||||
{
|
||||
public:
|
||||
Mutex ()
|
||||
{
|
||||
// NT only code begin ... Win9x disregards this part
|
||||
SECURITY_ATTRIBUTES MutexAttribs;
|
||||
|
||||
memset (&MutexAttribs, 0, sizeof (SECURITY_ATTRIBUTES));
|
||||
|
||||
MutexAttribs.bInheritHandle = false;
|
||||
MutexAttribs.nLength = sizeof (SECURITY_ATTRIBUTES);
|
||||
MutexAttribs.lpSecurityDescriptor = NULL;
|
||||
// NT only code end
|
||||
|
||||
Locked = false;
|
||||
LockCount = 0;
|
||||
MutexHandle = CreateMutex (&MutexAttribs, Locked, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
~Mutex ()
|
||||
{
|
||||
Lock ();
|
||||
CloseHandle (MutexHandle);
|
||||
}
|
||||
|
||||
void Lock (void)
|
||||
{
|
||||
Locked = true;
|
||||
WaitForSingleObject (MutexHandle, INFINITE);
|
||||
LockCount += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void Unlock (void)
|
||||
{
|
||||
LockCount -= 1;
|
||||
if (LockCount <= 0)
|
||||
{
|
||||
LockCount = 0;
|
||||
Locked = false;
|
||||
}
|
||||
|
||||
ReleaseMutex (MutexHandle);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool IsLocked (void)
|
||||
{
|
||||
return (Locked);
|
||||
}
|
||||
|
||||
protected:
|
||||
uint32 LockCount;
|
||||
HANDLE MutexHandle;
|
||||
bool Locked;
|
||||
};
|
||||
|
||||
|
||||
#endif // MUTEX_H
|
Loading…
Add table
Add a link
Reference in a new issue