struct Channel<T> {
buffer: BinaryHeap<Reverse<DelayedData<T>>>,
waker: Option<Waker>,
cfg: MixerConfig,
}Expand description
Mixing and delaying channel using random delay function.
Mixing is performed by assigning random delays to the ingress timestamp of data, then storing the values inside a binary heap with reversed ordering (max heap). This effectively creates a min heap behavior, which is required to ensure that data is released in order of their delay expiration.
When data arrives:
- A random delay is assigned
- Data is stored in the heap with its release timestamp
- The heap maintains ordering so items with earliest release time are at the top
This channel is unbounded by nature using the capacity in the configuration
to solely pre-allocate the buffer.
The timer used by the receiver to wait for the next release deadline is not stored
behind this mutex — it lives on the Receiver itself. Keeping it out of the shared
state is what lets the receiver poll the timer without blocking senders.
Fields§
§buffer: BinaryHeap<Reverse<DelayedData<T>>>Buffer holding the data with a timestamp ordering to ensure the min heap behavior.
waker: Option<Waker>§cfg: MixerConfigAuto Trait Implementations§
impl<T> Freeze for Channel<T>
impl<T> RefUnwindSafe for Channel<T>where
T: RefUnwindSafe,
impl<T> Send for Channel<T>where
T: Send,
impl<T> Sync for Channel<T>where
T: Sync,
impl<T> Unpin for Channel<T>where
T: Unpin,
impl<T> UnwindSafe for Channel<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more