PCL
Thread-Safe Protection of Non-Reentrant Code

Classes

class  pcl::AutoReentrancyGuard
 Automatic reentrancy guard sentinel. More...
 

Macros

#define PCL_CLASS_REENTRANCY_GUARD   mutable pcl::AtomicInt __pcl_guard__;
 
#define PCL_CLASS_REENTRANCY_GUARDED_BEGIN
 
#define PCL_MEMBER_REENTRANCY_GUARD(member)   mutable pcl::AtomicInt __pcl_guard_##member##__;
 
#define PCL_MEMBER_REENTRANCY_GUARDED_BEGIN(member)
 
#define PCL_REENTRANCY_GUARDED_BEGIN
 
#define PCL_REENTRANCY_GUARDED_END
 

Detailed Description

Macro Definition Documentation

◆ PCL_CLASS_REENTRANCY_GUARD

#define PCL_CLASS_REENTRANCY_GUARD   mutable pcl::AtomicInt __pcl_guard__;

Declares a class data member for class-wide protection of non-reentrant member functions with the PCL_CLASS_REENTRANCY_GUARDED_BEGIN and PCL_REENTRANCY_GUARDED_END macros.

Example:

class foo
{
public:
// ...
private:
void bar1()
{
// Protected code
}
void bar2() const
{
// Protected code
}
};

In this example the bar1 and bar2 member functions are protected against reentrant execution. Note that reentrancy protection is a per-instance, class-wide property in this case: the bar1() and bar2() functions can be executed simultaneously for different objects, but they cannot be re-entered for the same instance. Furthermore, one of these functions cannot call the other for the same object, since both share the same reentrancy guard member in the foo class.

See the AutoReentrancyGuard class for more information on the PCL implementation of reentrancy protection.

Definition at line 569 of file Atomic.h.

◆ PCL_CLASS_REENTRANCY_GUARDED_BEGIN

#define PCL_CLASS_REENTRANCY_GUARDED_BEGIN
Value:
{ \
volatile pcl::AutoReentrancyGuard __a_r_g__( __pcl_guard__ ); \
if ( __a_r_g__ ) \
{
Automatic reentrancy guard sentinel.
Definition: Atomic.h:443

This macro, along with PCL_CLASS_REENTRANCY_GUARD and PCL_REENTRANCY_GUARDED_END, simplifies per-instance protection of non-reentrant class member functions. See PCL_CLASS_REENTRANCY_GUARD for an example.

See the AutoReentrancyGuard class for more information on the PCL implementation of reentrancy protection.

Definition at line 585 of file Atomic.h.

◆ PCL_MEMBER_REENTRANCY_GUARD

#define PCL_MEMBER_REENTRANCY_GUARD (   member)    mutable pcl::AtomicInt __pcl_guard_##member##__;

Declares a class data member for protection of a specific non-reentrant member function with the PCL_MEMBER_REENTRANCY_GUARDED_BEGIN and PCL_REENTRANCY_GUARDED_END macros.

Example:

class foo
{
public:
// ...
private:
void bar1()
{
// Protected code
}
void bar2() const
{
// Protected code
}
};

In this example the bar1 and bar2 member functions are protected against reentrant execution. Note that reentrancy protection is a per-instance, function-specific property in this case: the bar1() and bar2() functions can be executed simultaneously for different objects, but they cannot be re-entered for the same instance. Since each member function uses its own reentrancy guard member in the foo class, each of them can safely call the other for the same object.

See the AutoReentrancyGuard class for more information on the PCL implementation of reentrancy protection.

Definition at line 636 of file Atomic.h.

◆ PCL_MEMBER_REENTRANCY_GUARDED_BEGIN

#define PCL_MEMBER_REENTRANCY_GUARDED_BEGIN (   member)
Value:
{ \
volatile pcl::AutoReentrancyGuard __a_r_g__( __pcl_guard_##member##__ );\
if ( __a_r_g__ ) \
{
Automatic reentrancy guard sentinel.
Definition: Atomic.h:443

This macro, along with PCL_MEMBER_REENTRANCY_GUARD and PCL_REENTRANCY_GUARDED_END, simplifies per-instance protection of specific non-reentrant member functions. See PCL_MEMBER_REENTRANCY_GUARD for an example.

See the AutoReentrancyGuard class for more information on the PCL implementation of reentrancy protection.

Definition at line 652 of file Atomic.h.

◆ PCL_REENTRANCY_GUARDED_BEGIN

#define PCL_REENTRANCY_GUARDED_BEGIN
Value:
{ \
static pcl::AtomicInt __r_g__( 0 ); \
volatile pcl::AutoReentrancyGuard __a_r_g__( __r_g__ ); \
if ( __a_r_g__ ) \
{
Atomic operations on integers.
Definition: Atomic.h:94
Automatic reentrancy guard sentinel.
Definition: Atomic.h:443

This macro along with PCL_REENTRANCY_GUARDED_END simplifies protection of non-reentrant code. See the AutoReentrancyGuard class for detailed information and examples.

Definition at line 505 of file Atomic.h.

◆ PCL_REENTRANCY_GUARDED_END

#define PCL_REENTRANCY_GUARDED_END
Value:
} \
}

This macro, along with PCL_REENTRANCY_GUARDED_BEGIN, simplifies protection of non-reentrant code. See the AutoReentrancyGuard class for detailed information and examples.

Definition at line 521 of file Atomic.h.