|
|
| | Hopper () noexcept |
| | Constructs an empty unbounded Hopper.
|
| |
| | Hopper (StormByte::Size capacity) noexcept |
| | Constructs an empty Hopper with a capacity ceiling.
|
| |
| | Hopper (const Hopper &)=delete |
| | Copy constructor is deleted (Hopper is non-copyable).
|
| |
| | Hopper (Hopper &&) noexcept=delete |
| | Move constructor is deleted (Hopper is non-movable).
|
| |
| | ~Hopper () noexcept |
| | Destructor.
|
| |
| Hopper & | operator= (const Hopper &)=delete |
| | Copy assignment operator is deleted (Hopper is non-copyable).
|
| |
| Hopper & | operator= (Hopper &&) noexcept=delete |
| | Move assignment operator is deleted (Hopper is non-movable).
|
| |
|
| StormByte::Size | Capacity () const noexcept |
| | Gets the current capacity ceiling.
|
| |
| void | Capacity (StormByte::Size capacity) noexcept |
| | Sets a new capacity ceiling.
|
| |
| StormByte::Size | Size () const noexcept |
| | Gets the number of items currently waiting in the bucket.
|
| |
| bool | Full () const noexcept |
| | Checks whether a bounded bucket cannot accept another Push without waiting.
|
| |
| unsigned | Writers () const noexcept |
| | Live writers attached to this hopper.
|
| |
|
| void | Push (T item) noexcept |
| | Enqueues one item and signals the consumer if Notify was configured.
|
| |
| Hopper & | operator<< (T item) noexcept |
| | Write: item flows into this Hopper.
|
| |
| void | Eof () noexcept |
| | Marks end of production and wakes waiters.
|
| |
|
| T | Pop () noexcept |
| | Pops one item from the bucket, or returns default-constructed T if dry.
|
| |
| T | Front () const noexcept |
| | Copy of the next item without dequeuing.
|
| |
| Hopper & | operator>> (T &item) noexcept |
| | Pop one unit from this Hopper into item.
|
| |
| bool | EoF () const noexcept |
| | Checks whether Eof was called by a producer.
|
| |
| bool | Empty () const noexcept |
| | Checks whether the queue has no pending items.
|
| |
| bool | Ready () const noexcept |
| | Whether Pop can return an item or production is finished.
|
| |
|
| void | Notify (std::condition_variable &wake) noexcept |
| | Registers the consumer condition variable to notify on Push or Eof.
|
| |
| void | Unnotify () noexcept |
| | Drops the pointer set by Notify.
|
| |
template<Type::MoveConstructible T>
class StormByte::Buffer::Hopper< T >
Single-producer single-consumer (SPSC) typed item queue.
Hopper is a typed bucket queue for passing items between a single producer and a single consumer. Unlike byte-oriented FIFOs, Hopper operates on discrete typed elements.
Key characteristics:
- Capacity ceiling: Optional capacity ceiling (0 = unbounded). Push waits when full.
- EoF handling: Marking Eof signals end of production; queued items can still be drained via Pop.
- Consumer notification: Points to a consumer condition variable via Notify to signal when items or EoF are available.
- Item flow:
hopper << item and item >> hopper enqueue; hopper >> item dequeues.
- Query: Size, Capacity, Full, Empty, EoF, Ready, Writers, Front (peek, copy).
- Non-copyable, non-movable: Shared via std::shared_ptr.
- Template Parameters
-
| T | Item type stored in the queue (must be MoveConstructible). |
template<Type::MoveConstructible T>
Enqueues one item and signals the consumer if Notify was configured.
- Parameters
-
| item | Item to push. Empty smart pointers are discarded. |
If Capacity > 0 and the bucket is full, waits until space becomes available, Eof is called, or the Hopper is destroyed. After Eof, Push does not enqueue.