44#include <StormByte/type_traits/safe.hxx>
47#include <StormByte/safe/atomic.hxx>
48#include <StormByte/safe/condition_variable.hxx>
49#include <StormByte/safe/function.hxx>
50#include <StormByte/safe/pointers.hxx>
51#include <StormByte/safe/vector.hxx>
52#include <StormByte/size.hxx>
53#include <StormByte/type_traits.hxx>
96 template<Detail::HopperValue T>
155 void Push(
int key, T item) noexcept;
285 Lane(
Sink& from,
int key)
noexcept;
426 bool Full(
int key) const noexcept;
440 bool EoF(
int key) const noexcept;
458 T
Front(
int key) const noexcept requires
Type::CopyConstructible<T> &&
std::is_nothrow_copy_constructible_v<T>;
500 template<typename Selector>
501 requires (!
Type::SameAs<
std::remove_cvref_t<Selector>,
Select>) &&
505 T
Pop(Selector&& select)
noexcept;
533 bool EoF() const noexcept;
550 class Implementation;
555 Implementation* m_io;
564#include <StormByte/buffer/sink.txx>
581 template<Buffer::Detail::HopperValue T>
Shared charge that can explicitly follow one payload across queues or work.
Definition byte_budget.hxx:261
Shared logical byte accounting for queues and concurrent work.
Definition byte_budget.hxx:256
Independent local bounds; absent means unlimited, engaged zero means zero capacity.
Definition byte_budget.hxx:125
One-key redirect: from.To(key) >> dest.
Definition sink.hxx:262
friend class Sink
Grants the enclosing Sink access to the borrowed lane.
Definition sink.hxx:279
Sink & operator>>(Sink &dest) noexcept
Wire this key onto dest.
bool EoF(int key) const noexcept
Whether producers marked Eof on bucket key.
QueueSnapshot Snapshot(int key) const noexcept
Read shared-hopper counters without waiting for capacity or doing I/O.
void Notify(Safe::ConditionVariable &consumer) noexcept
Registers consumer condition variable to notify on all current and future hoppers.
Sink & operator>>(Sink &dest) noexcept
Share every existing hopper with dest.
StormByte::Size Buckets() const noexcept
Number of hoppers wired on this Sink.
Lane To(int key) noexcept
Redirect of one hopper key.
bool Contains(int key) const noexcept
Whether hopper key exists on this Sink.
void Unnotify() noexcept
Removes only this Sink's matching borrowed registrations.
void Drain() noexcept
Marks Sink as a terminal producer (un-wired Push calls drop instead of waiting).
StormByte::Size Size(int key) const noexcept
Gets pending item count in bucket key.
QueueStatus PushFor(int key, T &item, const ByteBudget::Lease &lease, std::chrono::milliseconds timeout, AdmissionWaitObserver observer={}) noexcept
Shared-charge admission with a bounded wait.
StormByte::Size Capacity(int key) const noexcept
Gets capacity ceiling of bucket key.
Sink(const Sink &)=delete
T Front(int key) const noexcept
Copy of the next item in bucket key without dequeuing.
StormByte::Safe::Vector< int > Keys() const noexcept
Keys of hoppers currently wired on this Sink.
bool Full(int key) const noexcept
Checks if bucket key is full.
bool Draining() const noexcept
Checks whether Drain was called.
QueueStatus Configure(int key, QueueLimits limits, const ByteBudget &budget) noexcept
Attach local limits and aggregate accounting to an empty, idle bucket.
void Push(int key, T item) noexcept
Pushes an item into the bucket specified by key.
QueueStatus Limits(int key, QueueLimits limits) noexcept
Configure independent local limits on an existing shared hopper.
bool Empty(int key) const noexcept
Whether bucket key has no pending items.
Sink(Sink &&) noexcept=delete
Sink & operator<<(Sink &src) noexcept
Same as src >> *this (all hoppers).
void CancelPending(int key) noexcept
Cancel weighted admissions currently waiting on a shared hopper.
T Pop(int key) noexcept
Pops one item from bucket key only.
StormByte::Safe::Function< StormByte::Size(StormByte::Size)> Select
Index chooser for Pop selection across multiple buckets.
Definition sink.hxx:110
bool EoF() const noexcept
Checks if the Sink is finished.
QueueStatus PushFor(int key, T &item, StormByte::ByteSize bytes, std::chrono::milliseconds timeout, AdmissionWaitObserver observer={}) noexcept
Weighted admission with a bounded wait, cancellable by this Sink's closure.
bool Ready(int key) const noexcept
Whether Pop(int) on key can return an item or that hopper is finished.
T Pop(Selector &&select) noexcept
Pops using a synchronously borrowed callable without copying its captures.
Sink()
Constructs an empty Sink with zero buckets.
Sink & operator<<(Lane lane) noexcept
Same as lane >> *this.
void Eof() noexcept
Closes the Sink and releases writer holds on its hoppers.
QueueStatus TryPush(int key, T &item, StormByte::ByteSize bytes) noexcept
Attempt a weighted admission to an existing bucket.
T Pop() noexcept
Pops one item from the Sink using default round-robin order.
void Abort() noexcept
Closes every connected hopper and discards queued items.
Buffer module of the StormByte suite.
QueueStatus
Admission outcomes.
Definition byte_budget.hxx:80
Root namespace of the StormByte C++ suite.
Borrowed, allocation-free observer for one synchronous PushFor call.
Definition byte_budget.hxx:117
Coherent queue accounting; bytes are caller-supplied weights, never RSS.
Definition byte_budget.hxx:222