Tervel  1.0.0
A collection of wait-free containers and algorithms.
Public Member Functions | Private Member Functions | Private Attributes | List of all members
tervel::util::memory::hp::Element Class Reference

This class is used for the creation of Hazard Pointer Protected Objects Objects which extend it have the ability to call safeFree which delays the calling of the objects destructor until it is safe to do so. More...

#include <hp_element.h>

Inheritance diagram for tervel::util::memory::hp::Element:
tervel::containers::wf::HashMap< Key, Value, Functor >::DataNode tervel::containers::wf::RingBuffer< T >::Helper< T > tervel::util::OpRecord tervel::algorithms::wf::mcas::MultiWordCompareAndSwap< T > tervel::containers::wf::HashMap< Key, Value, Functor >::ForceExpandOp tervel::containers::wf::RingBuffer< T >::BufferOp tervel::containers::wf::vector::PopOp< T > tervel::containers::wf::vector::PopWRAOp< T > tervel::containers::wf::vector::PushOp< T > tervel::containers::wf::vector::PushWRAOp< T > tervel::containers::wf::vector::ReadOp< T > tervel::containers::wf::vector::WriteOp< T > tervel::util::memory::rc::ReadFirstOp

Public Member Functions

 Element ()
 
virtual ~Element ()
 
void safe_delete (bool no_check=false, ElementList *const element_list=tervel::tl_thread_info->get_hp_element_list())
 This function is used to free a hazard pointer protected object if it is safe to do so OR add it to a list to be freed later. More...
 
virtual bool on_watch (std::atomic< void * > *address, void *expected)
 This function is used to achieve a strong watch on an Element. More...
 
virtual bool on_is_watched ()
 This function is used to check a strong watch on an Element. More...
 
virtual void on_unwatch ()
 This function is used to remove a strong watch on an Element. More...
 

Private Member Functions

Elementnext ()
 Helper method for getting the next pointer. More...
 
void next (Element *next)
 Helper method for setting the next pointer. More...
 
 DISALLOW_COPY_AND_ASSIGN (Element)
 

Private Attributes

Elementnext_ {nullptr}
 
friend ListManager
 
friend ElementList
 

Detailed Description

This class is used for the creation of Hazard Pointer Protected Objects Objects which extend it have the ability to call safeFree which delays the calling of the objects destructor until it is safe to do so.

To achieve more advance functionality, the user can also extend Descriptor class which will provides on_watch, on_unwatch, and on_is_watch functions.

Constructor & Destructor Documentation

tervel::util::memory::hp::Element::Element ( )
inline
virtual tervel::util::memory::hp::Element::~Element ( )
inlinevirtual

Member Function Documentation

tervel::util::memory::hp::Element::DISALLOW_COPY_AND_ASSIGN ( Element  )
private
Element* tervel::util::memory::hp::Element::next ( )
inlineprivate

Helper method for getting the next pointer.

void tervel::util::memory::hp::Element::next ( Element next)
inlineprivate

Helper method for setting the next pointer.

virtual bool tervel::util::memory::hp::Element::on_is_watched ( )
inlinevirtual

This function is used to check a strong watch on an Element.

Classes wishing to express this should override this function.

Returns
whether or not the element is watched.

Reimplemented in tervel::algorithms::wf::mcas::MultiWordCompareAndSwap< T >, and tervel::util::OpRecord.

virtual void tervel::util::memory::hp::Element::on_unwatch ( )
inlinevirtual

This function is used to remove a strong watch on an Element.

Classes wishing to express this should override this function.

Reimplemented in tervel::util::OpRecord.

virtual bool tervel::util::memory::hp::Element::on_watch ( std::atomic< void * > *  address,
void *  expected 
)
inlinevirtual

This function is used to achieve a strong watch on an Element.

Classes wishing to express this should override this function.

Parameters
addressthe expected was load from
expectedthe last known value of address
Returns
whether or not the element was succefully watched.

Reimplemented in tervel::util::OpRecord, and tervel::containers::wf::RingBuffer< T >::Helper< T >.

void tervel::util::memory::hp::Element::safe_delete ( bool  no_check = false,
ElementList *const  element_list = tervel::tl_thread_info->get_hp_element_list() 
)
inline

This function is used to free a hazard pointer protected object if it is safe to do so OR add it to a list to be freed later.

It also calls 'try_to_free_Elements' in an attempt to free previously unfreeable objects.

Parameters
no_checkif true then the object is imeditly deleted
element_listthe list to append the object to until it is safe

Member Data Documentation

friend tervel::util::memory::hp::Element::ElementList
private
friend tervel::util::memory::hp::Element::ListManager
private
Element* tervel::util::memory::hp::Element::next_ {nullptr}
private

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