Tervel  1.0.0
A collection of wait-free containers and algorithms.
Public Member Functions | Private Member Functions | List of all members
tervel::util::Descriptor Class Referenceabstract

This defines the Descriptor class, this class is designed to be extend and be used in conjunction with primarily the RC memory pool objects. More...

#include <descriptor.h>

Inheritance diagram for tervel::util::Descriptor:
ShiftHelper< ShiftOp, T > tervel::algorithms::wf::mcas::Helper< T > tervel::containers::lf::mcas_buffer::Node< T > tervel::containers::wf::vector::PopOpHelper< T > tervel::containers::wf::vector::PopOpSubHelper< T > tervel::containers::wf::vector::PopWRAOpHelper< T > tervel::containers::wf::vector::PushDescr< T > tervel::containers::wf::vector::PushOpHelper< T > tervel::containers::wf::vector::PushWRAOpHelper< T > tervel::containers::wf::vector::WriteHelper< T >

Public Member Functions

 Descriptor ()
 
virtual ~Descriptor ()
 
virtual void * complete (void *current, std::atomic< void * > *address)=0
 This method is implemented by each sub class and must guarantee that upon return that the descriptor no longer exists at the address it was placed. More...
 
virtual void * get_logical_value ()=0
 This method is implemented by each sub class. More...
 
virtual bool on_watch (std::atomic< void * > *, void *)
 This method is optional to implement for each sub class. More...
 
virtual void on_unwatch ()
 This method must be implemented if on_watch is implemented, and is optional otherwise. More...
 
virtual bool on_is_watched ()
 This method is optional to implement for each sub class. More...
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (Descriptor)
 

Detailed Description

This defines the Descriptor class, this class is designed to be extend and be used in conjunction with primarily the RC memory pool objects.

Extending this class allows the developer to quickly create RC protected elements.

Classes that extend this class must implement the following functions: complete get_logical_function. This allows for various algorithms and data structures to be executed on overlapping regions of memory.

For use with memory protection schemes we provide the following functions: on_watch on_is_watched on_unwatch These are called by the memory protection scheme in the event more advance logic is required to safely dereference of free such objects.

If an object contains a reference to other object(s) that can only be freed when it is freed then this must expressed in the objects destructor.

Constructor & Destructor Documentation

tervel::util::Descriptor::Descriptor ( )
inline
virtual tervel::util::Descriptor::~Descriptor ( )
inlinevirtual

Member Function Documentation

virtual void* tervel::util::Descriptor::complete ( void *  current,
std::atomic< void * > *  address 
)
pure virtual

This method is implemented by each sub class and must guarantee that upon return that the descriptor no longer exists at the address it was placed.

Parameters
currentthe reference to this object as it is at the address,
addressthe location this object was read from

Implemented in tervel::containers::wf::vector::PopOpSubHelper< T >, tervel::containers::wf::vector::PushOpHelper< T >, tervel::containers::wf::vector::PopOpHelper< T >, tervel::containers::wf::vector::PushDescr< T >, tervel::containers::wf::vector::WriteHelper< T >, tervel::containers::wf::vector::PopWRAOpHelper< T >, tervel::containers::wf::vector::PushWRAOpHelper< T >, tervel::algorithms::wf::mcas::Helper< T >, and tervel::containers::lf::mcas_buffer::Node< T >.

tervel::util::Descriptor::DISALLOW_COPY_AND_ASSIGN ( Descriptor  )
private
virtual void* tervel::util::Descriptor::get_logical_value ( )
pure virtual

This method is implemented by each sub class.

It returns the logical value of the past address. If the associated operation is still in progress then it will generally return the value that was replaced by this descriptor. Otherwise it will generally return the result of the operation for the specified address.

It can only be called from the static function which protects the object from being reused during the function.

Implemented in tervel::containers::wf::vector::PopOpSubHelper< T >, tervel::containers::wf::vector::PushOpHelper< T >, tervel::containers::wf::vector::PopOpHelper< T >, tervel::containers::wf::vector::PushDescr< T >, tervel::containers::wf::vector::WriteHelper< T >, tervel::containers::wf::vector::PushWRAOpHelper< T >, tervel::algorithms::wf::mcas::Helper< T >, tervel::containers::lf::mcas_buffer::Node< T >, and ShiftHelper< ShiftOp, T >.

virtual bool tervel::util::Descriptor::on_is_watched ( )
inlinevirtual

This method is optional to implement for each sub class.

This function must be implemented if on_watch is implemented.

Returns
true if the item is watched by another thread

Reimplemented in tervel::containers::wf::vector::PopOpHelper< T >.

virtual void tervel::util::Descriptor::on_unwatch ( )
inlinevirtual

This method must be implemented if on_watch is implemented, and is optional otherwise.

It must unwatch any object watched by on_watch. It should not unwatch itself. It is called when this descriptor is unwatched.

Reimplemented in tervel::containers::wf::vector::PopOpHelper< T >.

virtual bool tervel::util::Descriptor::on_watch ( std::atomic< void * > *  ,
void *   
)
inlinevirtual

This method is optional to implement for each sub class.

In the event there is a complex dependency between descriptor objects, where watching one implies performing other actions, such as watching a parent object, a developer will implement this function to encapsulate that logic

This function is called by the static watch function It should not watch itself.

Parameters
addressThe location to check.
expectedThe expected value for that location
Returns
true if successful, false otherwise

Reimplemented in tervel::containers::wf::vector::PopOpSubHelper< T >, tervel::containers::wf::vector::PushOpHelper< T >, tervel::containers::wf::vector::PopOpHelper< T >, tervel::containers::wf::vector::WriteHelper< T >, tervel::containers::wf::vector::PushWRAOpHelper< T >, tervel::algorithms::wf::mcas::Helper< T >, and ShiftHelper< ShiftOp, T >.


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