|
Wildmeshing Toolkit
|
#include <indexed_collector.hpp>
Public Member Functions | |
| indexed_collector (std::size_t n) | |
| Construct an indexed_collector with n slots. | |
| void | set (std::size_t i, const T &v) |
Set the value at index i to v. This function can be called concurrently as long as callers pass distinct i. | |
| std::vector< T > | compact () const |
| Get a compacted vector of all filled slots. This function is not thread-safe and should only be called after all writes are complete. | |
Private Attributes | |
| std::vector< T > | m_slots |
| std::vector< char > | m_filled |
A collector that is not thread-safe for concurrent writes to the same index, but is thread-safe for concurrent writes to distinct indices. This is useful when each thread knows a unique slot for its result, allowing for lock-free writes.
|
inlineexplicit |
Construct an indexed_collector with n slots.
| n | The number of slots to allocate. |
|
inline |
Get a compacted vector of all filled slots. This function is not thread-safe and should only be called after all writes are complete.
|
inline |
Set the value at index i to v. This function can be called concurrently as long as callers pass distinct i.
| i | The index to set. |
| v | The value to set. |