pub struct Progress<State>{ /* private fields */ }
Expand description
Implementations§
Source§impl<State> Progress<State>
impl<State> Progress<State>
Sourcepub fn wait(&self, state: State) -> Events<State>
pub fn wait(&self, state: State) -> Events<State>
Create an event stream that will only fire for the given state. This is a stream and if you call
set_state
several times with the given state, this will yield several events.
Note that events fired before you call this will not be delivered to the stream. It’s recommended to
set up all observers first and then start doing work that can call set_state
.
Note that this method uses block_on
to lock a mutex on the pharos object, so it might block the
thread. All operations on Progress
are really short, so this shouldn’t be a problem as long as you
haven’t set up an observer by calling Progress::observe
with a bounded channel with a low queue size.
If the sending of an event (in set_state
) returns pending, and this method is called, that will deadlock.
Sourcepub fn once(&self, state: State) -> impl Future + Send
pub fn once(&self, state: State) -> impl Future + Send
Create a future that will resolve when a certain state is next triggered.
Note that events fired before you call this will not be delivered to the stream. It’s recommended to
set up all observers first and then start doing work that can call set_state
.
Note that this method uses block_on
to lock a mutex on the pharos object, so it might block the
thread. All operations on Progress
are really short, so this shouldn’t be a problem as long as you
haven’t set up an observer by calling Progress::observe
with a bounded channel with a low queue size.
If the sending of an event (in set_state
) returns pending, and this method is called, that will deadlock.
Trait Implementations§
Source§impl<State> Observable<State> for Progress<State>
impl<State> Observable<State> for Progress<State>
Source§fn observe(
&mut self,
options: ObserveConfig<State>,
) -> Observe<'_, State, Self::Error>
fn observe( &mut self, options: ObserveConfig<State>, ) -> Observe<'_, State, Self::Error>
Avoid configuring pharos with a bounded channel of a low queue size. It is possible to create a
deadlock if the send in Progress::set_state
returns pending and you call another method on Progress
that uses block_on, notably Progress::current
.