MFC Grid manual

CThreadRecursionProtector Class Reference

The class is destined to detect a function recursive call in multi-threaded applications. More...

#include <Dapfor/Common/ThreadRecursionProtector.h>

Inheritance diagram for CThreadRecursionProtector:

CRecursionProtector

List of all members.


Public Member Functions

 CThreadRecursionProtector ()
 Constructor.
virtual ~CThreadRecursionProtector ()
 Virtual destructor.
virtual void Enter ()
 Increments an internal counter for a calling thread.
virtual void Leave ()
 Decrements an internal counter for a calling thread.

Detailed Description

The class is destined to detect a function recursive call in multi-threaded applications.

The protector has an individual counter for every thread. The function Enter() increments a counter that corresponds to the calling thread. As soon as the counter value exceeds 1, CRecursionProtector::CRecursionException is raised. The function Leave() decrements the appropriate counter.

Thread safety
All functions are thread-safe.

Member Function Documentation

void Enter (  )  [virtual]

Increments an internal counter for a calling thread.

The function increments the recursion counter for the calling thread by 1. If the counter value becomes more than 1, the function will throw CRecursionException.

Reimplemented from CRecursionProtector.

void Leave (  )  [virtual]

Decrements an internal counter for a calling thread.

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

Reimplemented from CRecursionProtector.