Struct corosensei::Yielder
source · #[repr(transparent)]pub struct Yielder<Input, Yield> { /* private fields */ }
Expand description
Yielder
is an interface provided to a coroutine which allows it to suspend
itself and pass values in and out of the coroutine.
Yielder
can be freely copied to create multiple references to the same
underlying object. However a Yielder
cannot be moved to another thread.
Implementations§
source§impl<Input, Yield> Yielder<Input, Yield>
impl<Input, Yield> Yielder<Input, Yield>
sourcepub fn suspend(&self, val: Yield) -> Input
pub fn suspend(&self, val: Yield) -> Input
Suspends the execution of a currently running coroutine.
This function will switch control back to the original caller of
Coroutine::resume
. This function will then return once the
Coroutine::resume
function is called again.
sourcepub fn on_parent_stack<F, R>(&self, f: F) -> Rwhere
F: FnOnce() -> R + Send,
pub fn on_parent_stack<F, R>(&self, f: F) -> Rwhere F: FnOnce() -> R + Send,
Executes some code on the stack of the parent context (the one who last resumed the current coroutine).
This is particularly useful when executing on a coroutine with limited stack space: stack-heavy operations can be performed in a way that avoids stack overflows on the coroutine stack.
Panics
Any panics in the provided closure are automatically propagated back up to the caller of this function.