Proud::CriticalSection Class Reference

Public Member Functions

PROUD_API CriticalSection ()
 
PROUD_API CriticalSection (CriticalSectionSettings &settings)
 
PROUD_API ~CriticalSection (void)
 
PROUD_API void Lock ()
 
void UnsafeLock ()
 
PROUD_API void Unlock ()
 
PROUD_API bool TryLock ()
 
bool IsValid ()
 
CRITICAL_SECTION * GetWin32Object () const
 
bool IsLockedByCurrentThread () const
 
bool IsLocked () const
 
PROUD_API void Reset (CriticalSectionSettings &settings)
 
void ShowErrorOnInvalidState ()
 
uint64_t GetLastLockedThreadID ()
 

Public Attributes

bool m_neverCallDtor
 
int m_tryLockSuccessCount
 
int m_tryLockFailCount
 
CRITICAL_SECTION * m_platformSpecificObject
 

Detailed Description

Critical section (class)

  • More fortified features than CCriticalSection of MFC environment
  • A spin lock is set as default in order to minimize thread sleep state under SMP environment. General usage
  • It is possible to perform critical section lock/unlock through CriticalSectionLock object after creating it.

Constructor & Destructor Documentation

PROUD_API Proud::CriticalSection::CriticalSection ( )

Initializes a critical section object.

PROUD_API Proud::CriticalSection::CriticalSection ( CriticalSectionSettings settings)

Initializes a critical section object.

PROUD_API Proud::CriticalSection::~CriticalSection ( void  )

Destroyer

  • There must be no thread occupying the critical section before the desruction.

Member Function Documentation

uint64_t Proud::CriticalSection::GetLastLockedThreadID ( )
inline
returns ID of the thread where the last acquire (lock) is done.

You must set Proud.CriticalSectionSettings.m_updateLastLockedThreadID to true before using this function.

NOTE: on unix, this is pthread_t value. This may differ from thread ID shown in debugger.

NOTE: This value does not set to zero if last unacquire (unlock) is done.

CRITICAL_SECTION* Proud::CriticalSection::GetWin32Object ( ) const
inline

Returns CRITICAL_SECTION object for Windows platform. Useful for getting LockCount or OwningThread value.

bool Proud::CriticalSection::IsLocked ( ) const

Returns true if this is locked by any thread.

bool Proud::CriticalSection::IsLockedByCurrentThread ( ) const

Returns true if this is locked by current thread.

PROUD_API void Proud::CriticalSection::Lock ( )

The critical section is to be occupied by the thread calling this method.

PROUD_API bool Proud::CriticalSection::TryLock ( )

Use TryEnterCriticalSection rather than EnterCriticalSection.

Returns
If it locked successfully, it is true.
PROUD_API void Proud::CriticalSection::Unlock ( )

The critical section is to be relieved by the thread calling this method.

void Proud::CriticalSection::UnsafeLock ( )

TODO:translate needed. The critical section is to be occupied by the thread calling this method.

Member Data Documentation

CRITICAL_SECTION* Proud::CriticalSection::m_platformSpecificObject

여러분이 디버거에서 이 내부 상태값을 보고 싶으시면 이 멤버 변수의 값을 확인하십시오.