summaryrefslogtreecommitdiff
path: root/osframework/source/SexyAppFramework/AutoCrit.h
blob: 09357e39ba56938702ae7c836a5a73759728f883 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef __AUTOCRIT_INCLUDED__
#define __AUTOCRIT_INCLUDED__

#include "Common.h"
#include "CritSect.h"

namespace Sexy
{

class AutoCrit
{
	LPCRITICAL_SECTION		mCritSec;
public:
	AutoCrit(LPCRITICAL_SECTION theCritSec) : 
		mCritSec(theCritSec)
	{ 
		EnterCriticalSection(mCritSec); 
	}

	AutoCrit(const CritSect& theCritSect) : 
		mCritSec((LPCRITICAL_SECTION) &theCritSect.mCriticalSection)
	{ 
		EnterCriticalSection(mCritSec); 
	}

	~AutoCrit()
	{ 
		LeaveCriticalSection(mCritSec); 
	}
};

}

#endif //__AUTOCRIT_INCLUDED__