23#include <StormByte/type_traits.hxx>
25#include <condition_variable>
52 template<Type::MoveConstructible T>
60 using Select = std::function<std::size_t(std::size_t)>;
114 void Push(
int key, T item) noexcept;
195 [[deprecated(
"use producer >> consumer")]]
208 [[deprecated(
"use producer.To(key) >> consumer")]]
226 void Notify(std::condition_variable& consumer) noexcept;
257 void Capacity(
int key, std::
size_t capacity) noexcept;
264 std::
size_t Size(
int key) const noexcept;
271 bool Full(
int key) const noexcept;
312 bool EoF() const noexcept;
329 class Implementation;
331 std::unique_ptr<Implementation> m_impl;
335#include <StormByte/buffer/sink.txx>
One-key redirect: from.To(key) >> dest.
Definition sink.hxx:140
Sink & operator>>(Sink &dest) noexcept
Wire this key onto dest.
Set of Hopper buckets keyed by an integer.
Definition sink.hxx:53
Sink & operator>>(Sink &dest) noexcept
Share every existing hopper with dest.
Lane To(int key) noexcept
Redirect of one hopper key.
void Unnotify() noexcept
Clears Notify on this Sink and on every hopper.
std::size_t Capacity(int key) const noexcept
Gets capacity ceiling of bucket key.
std::function< std::size_t(std::size_t)> Select
Index chooser for Pop selection across multiple buckets.
Definition sink.hxx:60
void Bind(int key, Sink &consumer)
Creates or retrieves the hopper for key and shares it with consumer.
void Drain() noexcept
Marks Sink as a terminal producer (un-wired Push calls drop instead of waiting).
void Bind(Sink &consumer)
Shares all existing hoppers on this Sink with the consumer Sink.
Sink() noexcept
Constructs an empty Sink with zero buckets.
bool Full(int key) const noexcept
Checks if bucket key is full.
bool Draining() const noexcept
Checks whether Drain was called.
void Notify(std::condition_variable &consumer) noexcept
Registers consumer condition variable to notify on all current and future hoppers.
void Push(int key, T item) noexcept
Pushes an item into the bucket specified by key.
Sink & operator<<(Sink &src) noexcept
Same as src >> *this (all hoppers).
bool EoF() const noexcept
Checks if the Sink is finished.
std::size_t Size(int key) const noexcept
Gets pending item count in bucket key.
bool Ready() const noexcept
Checks whether a Pop call can return immediately (item available or EoF).
Sink & operator<<(Lane lane) noexcept
Same as lane >> *this.
void Eof() noexcept
Closes the Sink and releases writer holds on its hoppers.
T Pop() noexcept
Pops one item from the Sink using default round-robin order.
Buffer module of the StormByte suite.