Simple thread-safe vector with mutex-lock.
More...
#include <concurrent_vector.hpp>
|
|
| ConcurrentVector (const DataStorePolicy &policy=DataStorePolicy::UNLIMITED()) |
| |
|
void | submit_end_of_data () |
| |
|
bool | empty () const |
| |
|
int | size () const |
| |
|
void | reserve (int n) |
| |
|
void | push_back (const T &value) |
| |
|
void | clear () |
| |
|
T | front () const |
| |
|
T | back () const |
| |
| template<typename Container > |
| void | insert (const Container &new_values) |
| | Insert new_values at the end of the container.
|
| |
| std::optional< T > | pop () |
| | Get the first element in the queue.
|
| |
| std::optional< T > | pop_wait () |
| | Get the first element in the queue. If the queue is empty, this method waits until a new data arrives or EOD is submitted.
|
| |
| std::vector< T, Alloc > | get_all_and_clear_wait () |
| | Get all the data and clear the container. If the queue is empty, this method waits until a new data arrives or EOD is submitted.
|
| |
| std::vector< T, Alloc > | get_all_and_clear () |
| | Get all the data and clear the container.
|
| |
| std::vector< T, Alloc > | get_and_clear (int num_max) |
| | Get up to N data and erase them from the container.
|
| |
template<typename T, typename Alloc = std::allocator<T>>
class glim::ConcurrentVector< T, Alloc >
Simple thread-safe vector with mutex-lock.
- Note
- This class is performant in the single-thread-input single-thread-output situation. In the multi-thread-input multi-thread-output situation, consider using concurrent containers in TBB.
- Template Parameters
-
| T | Data type |
| Alloc | Allocator |
◆ get_all_and_clear()
template<typename T , typename Alloc = std::allocator<T>>
Get all the data and clear the container.
- Returns
- std::vector<T, Alloc> All data
◆ get_all_and_clear_wait()
template<typename T , typename Alloc = std::allocator<T>>
Get all the data and clear the container. If the queue is empty, this method waits until a new data arrives or EOD is submitted.
- Returns
- std::vector<T, Alloc> All data or empty if EOD is submitted.
◆ get_and_clear()
template<typename T , typename Alloc = std::allocator<T>>
Get up to N data and erase them from the container.
- Parameters
-
| num_max | Maximum number of data |
- Returns
- std::vector<T, Alloc> Up to num_max data
◆ insert()
template<typename T , typename Alloc = std::allocator<T>>
template<typename Container >
Insert new_values at the end of the container.
- Parameters
-
| new_values | Values to be inserted |
◆ pop()
template<typename T , typename Alloc = std::allocator<T>>
Get the first element in the queue.
- Returns
- nullopt if the queue is empty
◆ pop_wait()
template<typename T , typename Alloc = std::allocator<T>>
Get the first element in the queue. If the queue is empty, this method waits until a new data arrives or EOD is submitted.
- Returns
- nullopt if the queue is empty and EOD is submitted.
The documentation for this class was generated from the following file: