MFC Grid manual

CRecursionProtector Class Reference

The class is destined to detect a function recursive call. More...

#include <Dapfor/Common/RecursionProtector.h>

Inheritance diagram for CRecursionProtector:

CThreadRecursionProtector

List of all members.


Public Member Functions

 CRecursionProtector ()
 Constructor.
virtual ~CRecursionProtector ()
 Virtual destructor.
virtual void Enter ()
 Increments an internal counter.
virtual void Leave ()
 Decrements an internal counter.

Classes

struct  CRecursionException
 Exception is raised when recursion is detected. More...

Detailed Description

The class is destined to detect a function recursive call.

Each object of CRecursionProtector class contains a counter, which is incremented by Enter() call and it is decremented by Leave() call. Initially, the counter value is equal to 0. As soon as the counter value exceeds 1, CrecursionException() is raised. This class is designed for work in one thread. If it is necessary to detect a recursion in a multi-threaded application, CThreadRecursionProtector class should be applied.


Member Function Documentation

void Enter (  )  [virtual]

Increments an internal counter.

The function increments the recursion counter by 1. If the counter value becomes more than 1, the function will throws CRecursionException.

Reimplemented in CThreadRecursionProtector.

void Leave (  )  [virtual]

Decrements an internal counter.

The function decrements the recursion counter by 1. If the counter value becomes less than 0, CRecursionException() exception is thrown

Reimplemented in CThreadRecursionProtector.