This class works like an automatic pointer, but with specifics for critical sections. In the future it will be made an alternative object deleter
that can be passed to the automatic pointer. Be aware that this update will happen in the future, although this class will not be deprecated at that point.
To use this class, you should create it as a local variable. This enters the critical section. When the scope is deleted it will also leave the critical section
void foo(double *array, const long size) { // We enter the critical section wiht this call CCriticalSectionScope scope(new CCriticalSection); // Do our critical thing array[0] = 1.0; // scope is automatically destroyed here and takes out the critical section with it... // you do not need to manually exit the critical section }
Definition at line 47 of file CCriticalSectionScope.hpp.
Exponent::Threading::CCriticalSectionScope::CCriticalSectionScope | ( | CCriticalSection & | criticalSection | ) |
Construction
criticalSection | The critical section to use |
Exponent::Threading::CCriticalSectionScope::CCriticalSectionScope | ( | CCriticalSection * | criticalSection = NULL |
) |
Construction
criticalSection | The critical section to use |
Exponent::Threading::CCriticalSectionScope::CCriticalSectionScope | ( | CCriticalSection & | criticalSection, | |
const long | waitTimeInMilliseconds | |||
) |
Construction
criticalSection | The critical section to use | |
waitTimeInMilliseconds | The amount of time to wait between attempts to enter the critical section |
Exponent::Threading::CCriticalSectionScope::CCriticalSectionScope | ( | CCriticalSection * | criticalSection, | |
const long | waitTimeInMilliseconds | |||
) |
Construction
criticalSection | The critical section to use | |
waitTimeInMilliseconds | The amount of time to wait between attempts to enter the critical section |
Exponent::Threading::CCriticalSectionScope::~CCriticalSectionScope | ( | ) |
Destruction
void Exponent::Threading::CCriticalSectionScope::endCriticalSection | ( | ) |
End the critical section
bool Exponent::Threading::CCriticalSectionScope::hasEntered | ( | ) | const [inline] |
Are we inside the critical section
bool | True if inside critical section, false otherwise |
Definition at line 109 of file CCriticalSectionScope.hpp.
References m_entered.
void Exponent::Threading::CCriticalSectionScope::setAndEnterCriticalSection | ( | CCriticalSection * | criticalSection | ) |
Set the ciritical section and enter it
criticalSection | The critical section to use |
bool Exponent::Threading::CCriticalSectionScope::setAndTryToEnterCriticalSection | ( | CCriticalSection * | criticalSection, | |
const long | waitTimeInMilliseconds | |||
) |
Set the critical section and try to enter it
criticalSection | The critical section to use | |
waitTimeInMilliseconds | The amount of time to wait between attempts to enter the critical section |
bool | True if we entered the critical section sucessfuly, false otherwise or error |
The ciritical section that we are working with
Definition at line 118 of file CCriticalSectionScope.hpp.
bool Exponent::Threading::CCriticalSectionScope::m_entered [protected] |
Have we entered the critical section?
Definition at line 117 of file CCriticalSectionScope.hpp.
Referenced by hasEntered().