Skip to main content

TestSequencer

Struct TestSequencer 

Source
pub struct TestSequencer { /* private fields */ }
Expand description

Two participants of a test that wait for each other phase by phase: each calls advance_phase_async at the end of its part of a phase, and the phase completes when both have (TestSequencer, a Barrier of two participants).

Deviation (DEVIATIONS.md, ReactiveUI): the observables are single-threaded, so the two participants are two tasks of the current thread instead of two threads: the task of the first participant to arrive ends when the second one arrives, and the task of the second one has ended when advance_phase_async returns. The continuations of a task run when it ends, so upstream’s Task.Yield() after the barrier has no counterpart.

Implementations§

Source§

impl TestSequencer

Source

pub fn new() -> Self

A sequencer before its first phase.

Source

pub fn completed_phases(&self) -> i64

The number of phases both participants completed (CompletedPhases).

Source

pub fn current_phase(&self) -> i64

The phase the participants are in, set when the first of them arrives (CurrentPhase).

Source

pub fn advance_phase_async(&self) -> Task<()> ⓘ

Ends the part of the current phase of the calling participant; the task ends when the other participant has ended its part too (AdvancePhaseAsync()).

Source

pub fn advance_phase_async_with(&self, comment: &str) -> Task<()> ⓘ

advance_phase_async, with a comment that names the phase for the reader of the test (AdvancePhaseAsync(string)).

§Panics

When the sequencer is disposed, where upstream’s barrier throws ObjectDisposedException.

Trait Implementations§

Source§

impl Debug for TestSequencer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

{CompletedPhases}, {CurrentPhase} (DebuggerDisplay).

Source§

impl Default for TestSequencer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl IDisposable for TestSequencer

Source§

fn dispose(&self)

Disposes the sequencer (Dispose); a participant still waiting has its task cancelled.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.