|
|
| collector (std::size_t n) |
| |
|
| collector (std::size_t n, const T &value) |
| |
|
| collector (const collector &o) |
| |
|
collector & | operator= (const collector &o) |
| |
| void | push_back (const T &v) |
| | Push an element to the end of the collector. This function is thread-safe.
|
| |
|
void | push_back (T &&v) |
| |
| template<typename... Args> |
| void | emplace_back (Args &&... args) |
| | Emplace an element at the end of the collector. This function is thread-safe.
|
| |
| void | append (const std::vector< T > &v) |
| | Append a vector of elements to the end of the collector. This function is thread-safe.
|
| |
| void | resize (std::size_t n) |
| | Resize the collector to contain n elements. This function is thread-safe.
|
| |
|
void | resize (std::size_t n, const T &value) |
| |
|
void | clear () |
| | Clear the collector. This function is thread-safe.
|
| |
| void | reserve (std::size_t n) |
| | Reserve space in the collector. This function is thread-safe.
|
| |
| const std::vector< T > & | data () const |
| | Get the underlying data vector. This function is NOT thread-safe.
|
| |
| const_reference | operator[] (std::size_t i) const |
| | operator[] is not thread-safe for concurrent writes, but is safe for concurrent reads after all writes are done. Only const reference is provided to prevent accidental writes.
|
| |
| std::size_t | size () const |
| | Get the number of elements in the collector. This function is NOT thread-safe.
|
| |
| bool | empty () const |
| | Check if the collector is empty. This function is NOT thread-safe.
|
| |
|
const_iterator | begin () const |
| |
|
const_iterator | end () const |
| |
template<typename T>
class wmtk::threading::collector< T >
collector replaces tbb::concurrent_vector for the "append from a parallel loop, read
afterwards" use cases. Writes with push_back and emplace_back are thread-safe, but reads with operator[] are not thread-safe! Reads should only be done after all writes are complete.