3 //////////////////////////////////////////////////////////////////////////
5 // Description: Wraps a critical section.
6 //////////////////////////////////////////////////////////////////////////
11 CRITICAL_SECTION m_criticalSection;
15 InitializeCriticalSectionEx(&m_criticalSection, 100, 0);
20 DeleteCriticalSection(&m_criticalSection);
23 _Acquires_lock_(m_criticalSection)
26 EnterCriticalSection(&m_criticalSection);
29 _Releases_lock_(m_criticalSection)
32 LeaveCriticalSection(&m_criticalSection);
37 //////////////////////////////////////////////////////////////////////////
39 // Description: Provides automatic locking and unlocking of a
40 // of a critical section.
42 // Note: The AutoLock object must go out of scope before the CritSec.
43 //////////////////////////////////////////////////////////////////////////
48 CritSec *m_pCriticalSection;
50 _Acquires_lock_(m_pCriticalSection)
51 AutoLock(CritSec& crit)
53 m_pCriticalSection = &crit;
54 m_pCriticalSection->Lock();
57 _Releases_lock_(m_pCriticalSection)
60 m_pCriticalSection->Unlock();