|
Vince's CSV Parser
|
A std::deque wrapper which allows multiple read and write threads to concurrently access it along with providing read threads the ability to wait for the deque to become populated. More...
#include <thread_safe_deque.hpp>
Public Member Functions | |
| ThreadSafeDeque (size_t notify_size=100) | |
| ThreadSafeDeque (const ThreadSafeDeque &other) | |
| ThreadSafeDeque (const std::deque< T > &source) | |
| bool | empty () const noexcept |
| void | push_back (T &&item) |
| void | append_rows (std::vector< T > &&rows) |
| T | pop_front () noexcept |
| bool | try_copy_front (T &item) const |
| Copy the front item without removing it. | |
| size_t | drain_front (std::vector< T > &out, size_t max_items) |
Move up to max_items rows into a caller-owned batch buffer under one lock. | |
| template<typename Callback > | |
| void | inspect (Callback &&callback) const |
Invoke callback with a synchronized copy of queued rows. | |
| bool | is_waitable () const noexcept |
| Returns true if a thread is actively pushing items to this deque. | |
| void | wait () |
| size_t | size () const noexcept |
| void | notify_all () |
| Tell listeners that this deque is actively being pushed to. | |
| void | kill_all () |
A std::deque wrapper which allows multiple read and write threads to concurrently access it along with providing read threads the ability to wait for the deque to become populated.
Concurrency strategy: writer-side mutations (push_back/pop_front) are locked; hot-path flags (empty/is_waitable) are atomic; inspect() is the synchronized observation path for tests and diagnostics. Keep inspect() as a local ThreadSafeDeque affordance instead of promoting a generic queue-view type into the parser queue concept.
Definition at line 35 of file thread_safe_deque.hpp.
|
inline |
Definition at line 37 of file thread_safe_deque.hpp.
|
inline |
Definition at line 39 of file thread_safe_deque.hpp.
|
inline |
Definition at line 49 of file thread_safe_deque.hpp.
|
inline |
Definition at line 79 of file thread_safe_deque.hpp.
|
inline |
Move up to max_items rows into a caller-owned batch buffer under one lock.
This is the preferred consumer path for chunked reads: it preserves queue semantics while amortizing mutex traffic across many rows. Complete queued batches are moved as contiguous spans; per-row moves only remain when the requested limit splits a batch.
Definition at line 131 of file thread_safe_deque.hpp.
|
inlinenoexcept |
Definition at line 62 of file thread_safe_deque.hpp.
|
inline |
Invoke callback with a synchronized copy of queued rows.
Intended for tests and diagnostics that need stable indexed observation without exposing unsynchronized random access. The plain vector snapshot is deliberate: callers do not need to know whether the underlying queue is batch-backed, and RowDequeLike should not grow a custom inspection-view abstraction.
Definition at line 157 of file thread_safe_deque.hpp.
|
inlinenoexcept |
Returns true if a thread is actively pushing items to this deque.
Definition at line 178 of file thread_safe_deque.hpp.
|
inline |
Definition at line 204 of file thread_safe_deque.hpp.
|
inline |
Tell listeners that this deque is actively being pushed to.
Definition at line 198 of file thread_safe_deque.hpp.
|
inlinenoexcept |
Definition at line 94 of file thread_safe_deque.hpp.
Definition at line 66 of file thread_safe_deque.hpp.
|
inlinenoexcept |
Definition at line 192 of file thread_safe_deque.hpp.
|
inline |
Copy the front item without removing it.
Returns false when the queue is empty. The copy and emptiness check share one critical section so the consumer observes a coherent front item while the producer appends rows.
Definition at line 114 of file thread_safe_deque.hpp.
|
inline |
Definition at line 182 of file thread_safe_deque.hpp.