Tervel
1.0.0
A collection of wait-free containers and algorithms.
|
Classes | |
class | DescriptorPool |
Defines a pool of descriptor objects which is used to allocate descriptors and to store them while they are not safe to delete. More... | |
class | PoolElement |
This class is used to hold the memory management information (Header) and a descriptor object. More... | |
class | PoolManager |
A manager class for the reference count protected memory pools. More... | |
class | ReadFirstOp |
Class used for placement in the Op Table to complete an operation that failed to complete in a bounded number of steps. More... | |
Functions | |
template<typename DescrType , typename... Args > | |
DescrType * | get_descriptor (Args &&...args) |
Constructs and returns a descriptor. More... | |
void | free_descriptor (tervel::util::Descriptor *descr, bool dont_check=false) |
Once a user is done with a descriptor, they should free it with this method. More... | |
bool | is_watched (tervel::util::Descriptor *descr) |
This method is used to determine if the passed descriptor is under rc protection. More... | |
bool | watch (tervel::util::Descriptor *descr, std::atomic< void * > *address, void *value) |
This method is used to increment the reference count of the passed descriptor object. More... | |
void | unwatch (tervel::util::Descriptor *descr) |
This method is used to decrement the reference count of the passed descriptor object. More... | |
void * | mark_first (tervel::util::Descriptor *descr) |
This returns the passed reference with its least signifcant bit set to 1. More... | |
void | atomic_mark_first (std::atomic< void * > *address) |
This function atomically bit marks the value at address. More... | |
tervel::util::Descriptor * | unmark_first (void *descr) |
This returns an unbitmarked reference. More... | |
bool | is_descriptor_first (void *descr) |
This returns whether or not the least significant bit holds a bitmark. More... | |
void * | remove_descriptor (void *expected, std::atomic< void * > *address) |
This method is used to remove a descriptor object that is conflict with another threads operation. More... | |
void * | descriptor_read_first (std::atomic< void * > *address) |
This function determines the logical value of an address which may have either a RC descriptor or a normal value. More... | |
PoolElement * | get_elem_from_descriptor (tervel::util::Descriptor *descr) |
If the given descriptor was allocated through a DescriptorPool, then it has an associated PoolElement header. More... | |
Variables | |
const long | DEBUG_EXPECTED_STAMP = 0xDEADBEEF |
|
inline |
This function atomically bit marks the value at address.
This function atomically bit marks the value at address
address | the address to bitmark |
|
inline |
This function determines the logical value of an address which may have either a RC descriptor or a normal value.
address | to read |
|
inline |
Once a user is done with a descriptor, they should free it with this method.
descr | The descriptor to free. |
dont_check | Don't check if the descriptor is being watched before freeing it. Use this flag if you know that no other thread has had access to this descriptor. |
pool | the pool to use when freeing the descriptor. |
|
inline |
Constructs and returns a descriptor.
Arguments are forwarded to the constructor of the given descriptor type. User should call free_descriptor on the returned pointer when they are done with it to avoid memory leaks.
|
inline |
If the given descriptor was allocated through a DescriptorPool, then it has an associated PoolElement header.
This methods returns that PoolElement.
Use with caution as Descriptors not allocated from a pool will not have an associated header, and, thus, the returned value will be to some random place in memory.
descr | The Descriptor pointer allocated through a descriptor pool which thus has an associated PoolElement. |
|
inline |
This returns whether or not the least significant bit holds a bitmark.
the | reference to check |
|
inline |
This method is used to determine if the passed descriptor is under rc protection.
Internally calls on_is_watched
descr | the descriptor to be checked for rc protection. |
|
inline |
This returns the passed reference with its least signifcant bit set to 1.
descr | the reference to bitmark |
|
inline |
This method is used to remove a descriptor object that is conflict with another threads operation.
It first checks the recursive depth before proceeding. Next it protects against the object being reused else where by acquiring either HP or RC watch on the object. Then once it is safe it will call the objects complete function This function must guarantee that after its return the object has been removed It returns the value.
expected | a marked reference to the object |
address | the location expected was read from dereferenced from. |
|
inline |
This returns an unbitmarked reference.
the | reference to remove the bitmark from |
|
inline |
This method is used to decrement the reference count of the passed descriptor object.
Then it will call on_unwatch and decrement any related objects necessary Internally calls on_unwatch
descr | the descriptor which no longer needs rc protection. |
|
inline |
This method is used to increment the reference count of the passed descriptor object.
If after incrementing the reference count the object is still at the address (indicated by *a == value), it will call on_watch. If that returns true then it will return true. Otherwise it decrements the reference count and returns false Internally calls on_watch
descr | the descriptor which needs rc protection |
address | address it was dereferenced from |
val | the read value of the address |
const long tervel::util::memory::rc::DEBUG_EXPECTED_STAMP = 0xDEADBEEF |