Tervel  1.0.0
A collection of wait-free containers and algorithms.
Public Member Functions | Private Attributes | List of all members
tervel::algorithms::wf::mcas::Helper< T > Class Template Reference

This class is the MCAS operation's helper. More...

#include <mcas_casrow.h>

Inheritance diagram for tervel::algorithms::wf::mcas::Helper< T >:
tervel::util::Descriptor

Public Member Functions

 Helper (MCAS< T > *mcas_op, CasRow< T > *cas_row)
 The Helper object contains a reference to the row it is associated with and the mcas operation that contains the row. More...
 
bool on_watch (std::atomic< void * > *address, void *value)
 This method is optional to implement for each sub class. More...
 
void * complete (void *value, std::atomic< void * > *address)
 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...
 
void * get_logical_value ()
 This method is implemented by each sub class. More...
 
- Public Member Functions inherited from tervel::util::Descriptor
 Descriptor ()
 
virtual ~Descriptor ()
 
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 Attributes

CasRow< T > * cas_row_
 
MCAS< T > * mcas_op_
 

Detailed Description

template<class T>
class tervel::algorithms::wf::mcas::Helper< T >

This class is the MCAS operation's helper.

The Helper or MCH is used to replace the expected value of the specified address.

Constructor & Destructor Documentation

template<class T>
tervel::algorithms::wf::mcas::Helper< T >::Helper ( MCAS< T > *  mcas_op,
CasRow< T > *  cas_row 
)
inline

The Helper object contains a reference to the row it is associated with and the mcas operation that contains the row.

Parameters
mcas_opthe MCAS<T> which contains the referenced cas_row
cas_rowthe referenced row in the MCAS<T>.

Member Function Documentation

template<class T>
void* tervel::algorithms::wf::mcas::Helper< T >::complete ( void *  current,
std::atomic< void * > *  address 
)
inlinevirtual

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

Implements tervel::util::Descriptor.

template<class T>
void* tervel::algorithms::wf::mcas::Helper< T >::get_logical_value ( )
inlinevirtual

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.

Implements tervel::util::Descriptor.

template<class T>
bool tervel::algorithms::wf::mcas::Helper< T >::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 from tervel::util::Descriptor.

Member Data Documentation

template<class T>
CasRow<T>* tervel::algorithms::wf::mcas::Helper< T >::cas_row_
private
template<class T>
MCAS<T>* tervel::algorithms::wf::mcas::Helper< T >::mcas_op_
private

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