pub struct KeyedMergeOrderedHook<K, V, B: Boundedness = Unbounded> { /* private fields */ }Expand description
A hook handle controlling a merge_ordered operator over keyed streams with keys K
and values V.
The operator preserves each input’s order within every key while interleaving the two
inputs non-deterministically (cross-key order is unconstrained). A top-level decision
releases the front entry of one key’s buffer in one input; inside a tick, a single
decision supplies the complete interleaving. See hydro_lang::sim::hooks for the
decisions offered.
Implementations§
Source§impl<K, V> KeyedMergeOrderedHook<K, V, Unbounded>
impl<K, V> KeyedMergeOrderedHook<K, V, Unbounded>
Sourcepub fn next_first(&self, key: K, value: V) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn next_first(&self, key: K, value: V) -> DecisionFuture ⓘ
sim only.Scripts a top-level keyed merge_ordered action to release the front entry of
key’s buffer in the first input, which must equal value (per-input
within-key order is preserved, so a mismatch panics). Exactly one entry is
released, preserving opportunities for ticks and feedback to interleave with the
remaining buffered input.
Sourcepub fn next_second(&self, key: K, value: V) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn next_second(&self, key: K, value: V) -> DecisionFuture ⓘ
sim only.Scripts a top-level keyed merge_ordered action to release the front entry of
key’s buffer in the second input, which must equal value; see
Self::next_first.
Sourcepub fn advance_first(&self, key: K) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn advance_first(&self, key: K) -> DecisionFuture ⓘ
sim only.Scripts a top-level keyed merge_ordered action to release the front entry of
key’s buffer in the first input, whatever its value (waiting for one to arrive
if that key’s buffer is empty). Unlike Self::next_first, this does not assert
the released value; use next_first(key, value) to name it exactly and fail
loudly on mis-synchronization.
Sourcepub fn advance_second(&self, key: K) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn advance_second(&self, key: K) -> DecisionFuture ⓘ
sim only.Scripts a top-level keyed merge_ordered action to release the front entry of
key’s buffer in the second input, whatever its value; see
Self::advance_first.
Sourcepub fn pause(&self)
Available on crate feature sim only.
pub fn pause(&self)
sim only.Declares that buffering at this operator is intended: while paused, the hook is exempt from the missing-decision error, never causes its tick to run, and — if its tick runs anyway because other hooks feed it — contributes its “nothing new” behavior each time. Scripting any decision implicitly resumes the hook.
A pause takes its place in the script like everything else: requested while a decision is still pending, the hold begins once that decision has been consumed.
Sourcepub fn resume(&self)
Available on crate feature sim only.
pub fn resume(&self)
sim only.Ends a Self::pause (and clears Self::auto_pause mode).
Sourcepub fn auto_pause(&self)
Available on crate feature sim only.
pub fn auto_pause(&self)
sim only.Sets a standing mode where this hook only ever acts when scripted: it holds immediately, and every scripted decision leaves a fresh hold in place behind it.
This deliberately opts out of the forgotten-hook protection: if the test
forgets a step, the operator silently holds its data instead of failing. The
one auto_pause() line at the top of a test is the reviewer-visible marker
that this hook’s timing is entirely script-driven, missed steps and all.
Sourcepub async fn pause_while<Fut: Future>(&self, body: Fut) -> Fut::Output
Available on crate feature sim only.
pub async fn pause_while<Fut: Future>(&self, body: Fut) -> Fut::Output
sim only.Pauses the hook exactly for the duration of body (resuming even on panic), so
a bracketed buffering phase cannot leak a paused hook.
Sourcepub fn pause_until(
&self,
predicate: impl Fn(&MergeStatus) -> bool + Unpin,
) -> PauseUntilFuture<MergeStatus, impl Fn(&MergeStatus) -> bool + Unpin> ⓘ
Available on crate feature sim only.
pub fn pause_until( &self, predicate: impl Fn(&MergeStatus) -> bool + Unpin, ) -> PauseUntilFuture<MergeStatus, impl Fn(&MergeStatus) -> bool + Unpin> ⓘ
sim only.Pauses the hook and returns a future that resolves once the hook’s
pending-input status satisfies predicate — a synchronization point for
scripts where the right decision is not knowable upfront. The status is read
on demand at every scheduling point. After the future resolves, the hook is
unpaused; the ordinary missing-decision error applies from there on.
Sourcepub fn pause_until_count(
&self,
n: usize,
) -> PauseUntilFuture<MergeStatus, impl Fn(&MergeStatus) -> bool + Unpin> ⓘ
Available on crate feature sim only.
pub fn pause_until_count( &self, n: usize, ) -> PauseUntilFuture<MergeStatus, impl Fn(&MergeStatus) -> bool + Unpin> ⓘ
sim only.Pauses a top-level keyed merge hook until at least n entries are buffered (in
total, across both inputs and all keys); see Self::pause_until.
Source§impl<K, V> KeyedMergeOrderedHook<K, V, Bounded>
impl<K, V> KeyedMergeOrderedHook<K, V, Bounded>
Sourcepub fn order(
&self,
entries: impl IntoIterator<Item = (bool, K, V)>,
) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn order( &self, entries: impl IntoIterator<Item = (bool, K, V)>, ) -> DecisionFuture ⓘ
sim only.Scripts an in-tick keyed merge_ordered observation to consume its complete input
in exactly this interleaving, with each (key, value) entry labeled by the input
it is drawn from (false = first/left, true = second/right). Each input’s
labeled entries must be exactly that input’s tick-local batch, with every key’s
values in order; the relative order of different keys is irrelevant (a keyed
stream carries no cross-key ordering).
Trait Implementations§
Source§impl<K, V, B: Boundedness> Clone for KeyedMergeOrderedHook<K, V, B>
impl<K, V, B: Boundedness> Clone for KeyedMergeOrderedHook<K, V, B>
impl<K, V, B: Boundedness> Copy for KeyedMergeOrderedHook<K, V, B>
Source§impl<K, V, B: Boundedness> Debug for KeyedMergeOrderedHook<K, V, B>
impl<K, V, B: Boundedness> Debug for KeyedMergeOrderedHook<K, V, B>
Source§impl<K, V, B: Boundedness> SimHook for KeyedMergeOrderedHook<K, V, B>where
K: Hash + Eq + Clone + Serialize + DeserializeOwned,
V: Serialize + DeserializeOwned + PartialEq,
impl<K, V, B: Boundedness> SimHook for KeyedMergeOrderedHook<K, V, B>where
K: Hash + Eq + Clone + Serialize + DeserializeOwned,
V: Serialize + DeserializeOwned + PartialEq,
Auto Trait Implementations§
impl<K, V, B> Freeze for KeyedMergeOrderedHook<K, V, B>
impl<K, V, B> RefUnwindSafe for KeyedMergeOrderedHook<K, V, B>
impl<K, V, B> Send for KeyedMergeOrderedHook<K, V, B>
impl<K, V, B> Sync for KeyedMergeOrderedHook<K, V, B>
impl<K, V, B> Unpin for KeyedMergeOrderedHook<K, V, B>
impl<K, V, B> UnsafeUnpin for KeyedMergeOrderedHook<K, V, B>
impl<K, V, B> UnwindSafe for KeyedMergeOrderedHook<K, V, B>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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