cds  2.2.0
cds::urcu::raw_ptr< RCU, ValueType, ReclaimedEnumerator > Class Template Reference

Raw pointer to node of RCU-based container. More...

#include <cds/urcu/raw_ptr.h>

Public Types

typedef RCU rcu
 RCU type - one of cds::urcu::gc< ... >
 
typedef ValueType value_type
 Value type pointed by raw_ptr.
 
typedef ReclaimedEnumerator reclaimed_enumerator
 implementation-defined, for internal use only
 

Public Member Functions

 raw_ptr ()
 Constructs an empty raw pointer.
 
 raw_ptr (raw_ptr &&p)
 Move ctor.
 
 raw_ptr (raw_ptr const &)=delete
 Copy ctor is prohibited.
 
 ~raw_ptr ()
 Releases the raw pointer.
 
raw_ptroperator= (raw_ptr &&p) noexcept()
 Move assignment operator. More...
 
raw_ptroperator= (raw_ptr const &)=delete
 Copy assignment is prohibited.
 
value_typeoperator-> () const noexcept()
 Returns a pointer to stored value.
 
value_typeoperator* ()
 Returns a reference to stored value.
 
value_type const & operator* () const
 Returns a reference to stored value.
 
bool empty () const noexcept()
 Checks if the raw_ptr is nullptr.
 
 operator bool () const noexcept()
 Checks if the raw_ptr is not empty.
 
void release ()
 Releases the raw_ptr object. More...
 

Detailed Description

template<class RCU, typename ValueType, typename ReclaimedEnumerator>
class cds::urcu::raw_ptr< RCU, ValueType, ReclaimedEnumerator >

Raw pointer to node of RCU-based container.

This class is intented for returning a pointer to node of RCU-based container. The objects of raw_ptr class is returned by functions like get() of that containers. Those functions must be called only under RCU-lock, otherwise the node returned can be reclaimed. On the other hand, traversing the container can remove a lot of nodes marked as deleted ones. Since RCU is locked, such nodes cannot be reclaimed immediately and must be retired only outside RCU lock.

The object of raw_ptr solves that problem: it contains the pointer to the node found and a chain of nodes that were be reclaimed during traversing. The raw_ptr object destructor frees the chain (but not the node found) passing it to RCU batch_retire().

The object of raw_ptr class must be destructed only outside RCU-lock of current thread.

Usually, you do not need to use raw_ptr class directly. Each RCU container declares a raw_ptr typedef suitable for the container.

Template arguments:

  • RCU - one of RCU type
  • ValueType - type of values stored in container
  • ReclaimedEnumerator - implementation-defined for each type of container

Example: let Container is an RCU container

Container c;
// ...
// Find a key
typename Container::raw_ptr pRaw;
// RCU locked section
{
typename Container::rcu_lock l;
pRaw = c.get( key );
if ( pRaw ) {
// Deal with pRaw
}
}
// Release outside RCU-lock
pRaw.release();

Member Function Documentation

§ operator=()

template<class RCU , typename ValueType , typename ReclaimedEnumerator >
raw_ptr& cds::urcu::raw_ptr< RCU, ValueType, ReclaimedEnumerator >::operator= ( raw_ptr< RCU, ValueType, ReclaimedEnumerator > &&  p)
inlinenoexcept

Move assignment operator.

This operator may be called only inside RCU-lock.

§ release()

template<class RCU , typename ValueType , typename ReclaimedEnumerator >
void cds::urcu::raw_ptr< RCU, ValueType, ReclaimedEnumerator >::release ( )
inline

Releases the raw_ptr object.

This function may be called only outside RCU locked region. After release() the object becomes empty and can be reused.


The documentation for this class was generated from the following file:

cds 2.2.0 Developed by Maxim Khizhinsky aka khizmax 2007 - 2017
Autogenerated Wed Jan 4 2017 08:50:08 by Doxygen 1.8.12