pub struct Stage<T: Flows> { /* private fields */ }
Expand description
Group of data processors sharing a FlowSubscriber
.
Implementations§
Source§impl<T: Flows> Stage<T>
impl<T: Flows> Stage<T>
Sourcepub fn add_proc<D>(&mut self, proc: impl Procs<D>)where
T: TryAsFormat<D>,
pub fn add_proc<D>(&mut self, proc: impl Procs<D>)where
T: TryAsFormat<D>,
Adds a new processor to the stage.
proc
may accept any data type T
which the flow’s
data D
can be “tried as”.
proc
will only be invoked for data in the flow which
is successfully interperable as D
.
Sourcepub fn proc(&mut self) -> Result<u64, Error>
pub fn proc(&mut self) -> Result<u64, Error>
Invokes each processor at least once if the flow is active and data is available, returning the number of data processed.
Sourcepub async fn proc_loop(self)
pub async fn proc_loop(self)
Runs Self::proc
in an infinite loop.
When the flow is idle, async_support::yield_now
will be invoked to temporarily yield execution back
to the async runtime. Invoke Self::proc_loop_with_waiter
instead of this function to use a different waiter.
Sourcepub async fn proc_loop_with_waiter<W, Fut>(self, waiter: W)
pub async fn proc_loop_with_waiter<W, Fut>(self, waiter: W)
Runs Self::proc
in an infinite loop, calling
waiter
when the flow is idle.
Calling this function with an async runtime’s
“native” yield function can improve throughput
by ~50% or more (as compared to Self::proc_loop
).
On Tokio runtimes, it’s highly recommended to
call this function with tokio::task::yield_now
.
Trait Implementations§
Source§impl<T: Flows> From<FlowSubscriber<T>> for Stage<T>
impl<T: Flows> From<FlowSubscriber<T>> for Stage<T>
Source§fn from(value: FlowSubscriber<T>) -> Self
fn from(value: FlowSubscriber<T>) -> Self
Auto Trait Implementations§
impl<T> Freeze for Stage<T>
impl<T> !RefUnwindSafe for Stage<T>
impl<T> Send for Stage<T>
impl<T> !Sync for Stage<T>
impl<T> Unpin for Stage<T>
impl<T> !UnwindSafe for Stage<T>
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> TryAsFormat<T> for T
impl<T> TryAsFormat<T> for T
Source§type Error = Infallible
type Error = Infallible
Source§fn try_as_format(&self) -> Result<&T, <T as TryAsFormat<T>>::Error>
fn try_as_format(&self) -> Result<&T, <T as TryAsFormat<T>>::Error>
D
-formatted reference to the data.