Tervel
1.0.0
A collection of wait-free containers and algorithms.
|
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>
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) | |
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.
|
inline |
|
inlinevirtual |
|
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.
current | the reference to this object as it is at the address, |
address | the 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 >.
|
private |
|
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 >.
|
inlinevirtual |
This method is optional to implement for each sub class.
This function must be implemented if on_watch is implemented.
Reimplemented in tervel::containers::wf::vector::PopOpHelper< T >.
|
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 >.
|
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.
address | The location to check. |
expected | The expected value for that location |
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 >.