tools/installer/CCriticalSection.h
author David Anderson <dvander@alliedmods.net>
Wed Feb 25 19:22:36 2009 -0500 (2009-02-25)
changeset 2603 fa286305bd3f
parent 1722 2c16f160f5dd
permissions -rw-r--r--
Allow for second private chat trigger (bug 3667, r,a11=pred).
     1 #ifndef _INCLUDE_INSTALLER_CRIT_SECT_H_
     2 #define _INCLUDE_INSTALLER_CRIT_SECT_H_
     3 
     4 #include "platform_headers.h"
     5 
     6 class CCriticalSection
     7 {
     8 public:
     9 	CCriticalSection()
    10 	{
    11 		InitializeCriticalSection(&m_crit);
    12 	}
    13 	~CCriticalSection()
    14 	{
    15 		DeleteCriticalSection(&m_crit);
    16 	}
    17 	void Enter()
    18 	{
    19 		EnterCriticalSection(&m_crit);
    20 	}
    21 	bool TryEnter()
    22 	{
    23 		if (TryEnterCriticalSection(&m_crit))
    24 		{
    25 			return true;
    26 		}
    27 		return false;
    28 	}
    29 	void Leave()
    30 	{
    31 		LeaveCriticalSection(&m_crit);
    32 	}
    33 private:
    34 	CRITICAL_SECTION m_crit;
    35 };
    36 
    37 #endif //_INCLUDE_INSTALLER_CRIT_SECT_H_