22#include <StormByte/type_traits.hxx>
24#include <condition_variable>
30 template<Type::MoveConstructible T>
class Sink;
50 template<Type::MoveConstructible T>
67 explicit
Hopper(std::
size_t capacity) noexcept;
122 std::
size_t Size() const noexcept;
191 bool EoF() const noexcept;
216 void Notify(std::condition_variable& wake) noexcept;
241 hopper << std::move(item);
252 hopper << std::move(item);
257 friend class Sink<T>;
259 void AddWriter() noexcept;
260 void CloseWriter() noexcept;
266 class Implementation;
268 std::unique_ptr<Implementation> m_impl;
272#include <StormByte/buffer/hopper.txx>
Single-producer single-consumer (SPSC) typed item queue.
Definition hopper.hxx:51
void Notify(std::condition_variable &wake) noexcept
Registers the consumer condition variable to notify on Push or Eof.
bool Empty() const noexcept
Checks whether the queue has no pending items.
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.
std::size_t Size() const noexcept
Gets the number of items currently waiting in the bucket.
std::size_t Capacity() const noexcept
Gets the current capacity ceiling.
void Unnotify() noexcept
Drops the pointer set by Notify.
Hopper() noexcept
Constructs an empty unbounded Hopper.
bool EoF() const noexcept
Checks whether Eof was called by a producer.
friend Hopper & operator>>(T &&item, Hopper &hopper) noexcept
Write: rvalue item flows into hopper.
Definition hopper.hxx:251
bool Full() const noexcept
Checks whether a bounded bucket cannot accept another Push without waiting.
void Push(T item) noexcept
Enqueues one item and signals the consumer if Notify was configured.
Set of Hopper buckets keyed by an integer.
Definition sink.hxx:53
Buffer module of the StormByte suite.