A obstruction-free parallel vector. Properties:
More...
#include <ParallelVector.h>
Inherits gts::AlignedAllocator< GTS_NO_SHARING_CACHE_LINE_SIZE >.
|
using | ticket_vec = internal::ParallelSubVector< T, TSharedMutex, TAllocator > |
|
using | value_type = typename ticket_vec::value_type |
|
using | mutex_type = typename ticket_vec::mutex_type |
|
using | backoff_type = typename ticket_vec::backoff_type |
|
using | size_type = typename ticket_vec::size_type |
|
using | allocator_type = typename ticket_vec::allocator_type |
|
using | read_guard = ReadGuard< value_type, mutex_type, mutex_type > |
|
using | write_guard = WriteGuard< value_type, mutex_type, mutex_type > |
|
|
class | base_const_iterator |
|
class | const_iterator |
|
class | iterator |
|
template<typename T, typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
class gts::ParallelVector< T, TSharedMutex, TAllocator >
A obstruction-free parallel vector. Properties:
- Unbound.
- Reference stable.
- Not linearizable.
- Template Parameters
-
T | The element type stored in the container. |
TAccessorSharedMutex | The shared mutex type to access individual elements. |
TGrowSharedMutex | The shared mutex type used to grow the table. |
TAllocator | The allocator used by the storage backing. |
- Todo:
Implement insert()
Implement delete()
Make more methods thread-safe.
◆ ParallelVector() [1/4]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Constructs an empty container with the given 'allocator'. The number of sub vectors is equal to the number of HW threads on the machine.
◆ ParallelVector() [2/4]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Constructs an empty container with 'subVectorCount' sub vectors and with the given 'allocator'.
◆ ~ParallelVector()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
ParallelVector::~ParallelVector |
( |
| ) |
|
Destructs the container. The destructors of the elements are called and the used storage is deallocated.
◆ ParallelVector() [3/4]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
ParallelVector::ParallelVector |
( |
ParallelVector< T, TSharedMutex, TAllocator > const & |
other | ) |
|
Copy constructor. Constructs the container with the copy of the contents of 'other'.
◆ ParallelVector() [4/4]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
ParallelVector::ParallelVector |
( |
ParallelVector< T, TSharedMutex, TAllocator > && |
other | ) |
|
Move constructor. Constructs the container with the contents of other using move semantics. After the move, other is invalid.
◆ at()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Access specified element.
- Returns
- A reference to the element wrapped in a write_guard.
◆ back()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Accesses the last element.
- Returns
- A reference to the element wrapped in a write_guard.
◆ begin()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
- Returns
- An iterator to the beginning of the current vector state.
◆ capacity()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
ParallelVector< T, TSharedMutex, TAllocator >::size_type ParallelVector::capacity |
( |
| ) |
const |
- Returns
- The total number of slots in the table.
◆ cat()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Access specified element.
- Returns
- A reference to the element wrapped in a read_guard.
◆ cback()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Accesses the last element.
- Returns
- A reference to the element wrapped in a read_guard.
◆ cbegin()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
- Returns
- An iterator to the beginning of the current vector state.
◆ cend()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
- Returns
- An iterator to the end of the current vector state.
◆ cfront()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Accesses the first element.
- Returns
- A reference to the element wrapped in a read_guard.
◆ clear()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void ParallelVector::clear |
( |
| ) |
|
Clears the data from the table. Leaves the capacity of the vector unchanged.
◆ emplace_back()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
template<typename... TArgs>
Removes the last element.
◆ empty()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
bool ParallelVector::empty |
( |
| ) |
const |
- Returns
- True if there are no element in the vector, false otherwise.
◆ end()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
- Returns
- An iterator to the end of the current vector state.
◆ front()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Accesses the first element.
- Returns
- A reference to the element wrapped in a write_guard.
◆ get_allocator()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
ParallelVector< T, TSharedMutex, TAllocator >::allocator_type ParallelVector::get_allocator |
( |
| ) |
const |
- Returns
- This vector's allocator.
◆ max_size()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
ParallelVector< T, TSharedMutex, TAllocator >::size_type ParallelVector::max_size |
( |
| ) |
const |
- Returns
- Maximum number of slots the container can grow to.
◆ operator=() [1/2]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Move assignment operator. Replaces the contents with those of other using move semantics. After the move, other is invalid.
◆ operator=() [2/2]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Copy assignment operator. Replaces the contents with a copy of the contents of 'other'.
◆ operator[]() [1/2]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Access specified element.
- Returns
- A reference to the element wrapped in a write_guard.
◆ operator[]() [2/2]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Access specified element.
- Returns
- A reference to the element wrapped in a read_guard.
◆ pop_back()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void ParallelVector::pop_back |
( |
| ) |
|
Removes the last element.
◆ pop_back_and_get()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Removes the last element and returns it. Basically packages back() and and pop_back() into a single thread-safe transaction.
◆ push_back() [1/2]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Moves the specified value into the back of the container.
◆ push_back() [2/2]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
Copies the specified value into the back of the container.
◆ reserve()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void ParallelVector::reserve |
( |
size_type |
size | ) |
|
Increases the capacity of the vector. Does nothing if 'size' < capacity.
◆ resize() [1/2]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void ParallelVector::resize |
( |
size_type |
size | ) |
|
Changes the number of elements in the vector to 'size'.
◆ resize() [2/2]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void ParallelVector::resize |
( |
size_type |
size, |
|
|
value_type const & |
fill |
|
) |
| |
Changes the number of elements in the vector to 'size'. New elements will have the value 'fill'.
◆ size()
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
ParallelVector< T, TSharedMutex, TAllocator >::size_type ParallelVector::size |
( |
| ) |
const |
- Returns
- The number of elements in the vector.
◆ swap_out() [1/2]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void ParallelVector::swap_out |
( |
iterator & |
iter | ) |
|
Removes the specified element and replaces it with the last element.
◆ swap_out() [2/2]
template<typename T , typename TSharedMutex = UnfairSharedSpinMutex<>, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void ParallelVector::swap_out |
( |
size_type |
index | ) |
|
Removes the specified element and replaces it with the last element.