uLib  User mode C/C++ extended API library for Win32 programmers.
TCritSec Class Reference

#include <uLib/SyncObj.h>

Detailed Description

TCritSec adds some cotton-gloving to critical sections.

It prevents direct access to the CRITICAL_SECTION, prevents copying,
and protects against reinitializing an already initialized section.
It also automatically deletes the section when it goes out of scope.

Note: Keep the following MSDN remark in mind...
"EnterCriticalSection can raise EXCEPTION_POSSIBLE_DEADLOCK
if a wait operation on the critical section times out. Do not handle
a possible deadlock exception; instead, debug the application."

Definition at line 46 of file SyncObj.h.

Public Functions

 TCritSec ()
 
 TCritSec (DWORD SpinCount)
 
 ~TCritSec ()
 
DWORD SetSpinCount (DWORD SpinCount)
 
void Enter ()
 
bool TryEnter ()
 
void Leave ()
 

Protected Attributes

CRITICAL_SECTION _cSec
 

Constructor & Destructor Documentation

◆ TCritSec() [1/2]

TCritSec::TCritSec ( )

Definition at line 29 of file SyncObj.cpp.

◆ TCritSec() [2/2]

TCritSec::TCritSec ( DWORD  SpinCount)

See SetSpinCount().

Definition at line 46 of file SyncObj.cpp.

◆ ~TCritSec()

TCritSec::~TCritSec ( )

Definition at line 62 of file SyncObj.cpp.

Member Function Documentation

◆ SetSpinCount()

DWORD TCritSec::SetSpinCount ( DWORD  SpinCount)

See [MSDN] SetCriticalSectionSpinCount().

Definition at line 67 of file SyncObj.cpp.

◆ Enter()

void TCritSec::Enter ( )

See [MSDN] EnterCriticalSection().

Definition at line 93 of file SyncObj.cpp.

◆ TryEnter()

bool TCritSec::TryEnter ( )

See [MSDN] TryEnterCriticalSection().

Definition at line 111 of file SyncObj.cpp.

◆ Leave()

void TCritSec::Leave ( )

See [MSDN] LeaveCriticalSection().

Definition at line 116 of file SyncObj.cpp.

Member Data Documentation

◆ _cSec

CRITICAL_SECTION TCritSec::_cSec
protected

Definition at line 51 of file SyncObj.h.


The documentation for this class was generated from the following files: