|
/////////////////////////////////////////////////////////////////////
// Written by Phillip Sitbon
// Copyright 2003
//
// Win32/Mutex.h
// - Resource locking mechanism using Critical Sections
//
/////////////////////////////////////////////////////////////////////
#ifndef _Mutex_Win32_
#define _Mutex_Win32_
#include "Win32.h"
class Mutex
{
mutable CRITICAL_SECTION C;
void operator=(Mutex &M) {}
Mutex( const Mutex &M ) {}
public:
Mutex()
{ InitializeCriticalSection(&C); }
virtual ~Mutex()
{ DeleteCriticalSection(&C); }
int Lock() const
{ EnterCriticalSection(&C); return 0; }
#if(_WIN32_WINNT >= 0x0400)
int Lock_Try() const
{ return (TryEnterCriticalSection(&C)?0:EBUSY); }
#endif
int Unlock() const
{ LeaveCriticalSection(&C); return 0; }
};
#endif // !_Mutex_Win32_
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
I am a student at Portland State University in Portland, Oregon majoring in Mathematics and minoring in Computer Science and Physics.