- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Exponent::Threading::CCriticalSectionScope Class Reference

List of all members.

## Detailed Description

A wrapper around a cross platform critical section that is scope specific and requires a critical section to be supplied.

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
     }

Date:
  10/08/2005

Author:
  Paul Chana

Version:
  1.0.0 Initial version

Note:
  All contents of this source code are copyright 2005 Exp Digital Uk.
  This source file is covered by the licence conditions of the Infinity API. You should have recieved a copy
  with the source code. If you didnt, please refer to http://www.expdigital.co.uk All content is the Intellectual property of Exp Digital Uk.
  Certain sections of this code may come from other sources. They are credited where applicable.
  If you have comments, suggestions or bug reports please visit http://support.expdigital.co.uk

Id
  CCriticalSectionScope.hpp,v 1.6 2007/02/08 21:06:44 paul Exp

Definition at line 47 of file CCriticalSectionScope.hpp.

## Public Member Functions

- CCriticalSectionScope (CCriticalSection *criticalSection, const long waitTimeInMilliseconds)
- CCriticalSectionScope (CCriticalSection &criticalSection, const long waitTimeInMilliseconds)
- CCriticalSectionScope (CCriticalSection *criticalSection=NULL)
- CCriticalSectionScope (CCriticalSection &criticalSection)
- void endCriticalSection ()
- bool hasEntered () const
- void setAndEnterCriticalSection (CCriticalSection *criticalSection)
- bool setAndTryToEnterCriticalSection (CCriticalSection *criticalSection, const long waitTimeInMilliseconds)
- ~CCriticalSectionScope ()

## Protected Attributes

- CCriticalSection * m_criticalSection
- bool m_entered

## Constructor & Destructor Documentation

Exponent::Threading::CCriticalSectionScope::CCriticalSectionScope | ( | CCriticalSection & | criticalSection | ) |

Construction

Parameters:

  | criticalSection | The critical section to use

Exponent::Threading::CCriticalSectionScope::CCriticalSectionScope | ( | CCriticalSection * | criticalSection = `NULL` | ) |

Construction

Parameters:

  | criticalSection | The critical section to use

Exponent::Threading::CCriticalSectionScope::CCriticalSectionScope | ( | CCriticalSection & | criticalSection,
|  | const long | waitTimeInMilliseconds |
| ) |  |  |

Construction

Parameters:

  | 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

Parameters:

  | 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

## Member Function Documentation

void Exponent::Threading::CCriticalSectionScope::endCriticalSection | ( |  | ) |

End the critical section

bool Exponent::Threading::CCriticalSectionScope::hasEntered | ( |  | ) | const`[inline]`

Are we inside the critical section

Return values:

  | 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

Parameters:

  | 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

Parameters:

  | criticalSection | The critical section to use
  | waitTimeInMilliseconds | The amount of time to wait between attempts to enter the critical section

Return values:

  | bool | True if we entered the critical section sucessfuly, false otherwise or error

## Member Data Documentation

CCriticalSection* Exponent::Threading::CCriticalSectionScope::m_criticalSection`[protected]`

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().