pub struct Fiber<'a, Resume, Yield, Return> { /* private fields */ }
Implementations§
Source§impl<'a, Resume, Yield, Return> Fiber<'a, Resume, Yield, Return>
impl<'a, Resume, Yield, Return> Fiber<'a, Resume, Yield, Return>
Sourcepub fn new(
stack: FiberStack,
func: impl FnOnce(Resume, &mut Suspend<Resume, Yield, Return>) -> Return + 'a,
) -> Result<Self>
pub fn new( stack: FiberStack, func: impl FnOnce(Resume, &mut Suspend<Resume, Yield, Return>) -> Return + 'a, ) -> Result<Self>
Creates a new fiber which will execute func
on the given stack.
This function returns a Fiber
which, when resumed, will execute func
to completion. When desired the func
can suspend itself via
Fiber::suspend
.
Sourcepub fn resume(&self, val: Resume) -> Result<Return, Yield>
pub fn resume(&self, val: Resume) -> Result<Return, Yield>
Resumes execution of this fiber.
This function will transfer execution to the fiber and resume from where it last left off.
Returns true
if the fiber finished or false
if the fiber was
suspended in the middle of execution.
§Panics
Panics if the current thread is already executing a fiber or if this fiber has already finished.
Note that if the fiber itself panics during execution then the panic will be propagated to this caller.
Sourcepub fn stack(&self) -> &FiberStack
pub fn stack(&self) -> &FiberStack
Gets the stack associated with this fiber.
Sourcepub fn into_stack(self) -> FiberStack
pub fn into_stack(self) -> FiberStack
When this fiber has finished executing, reclaim its stack.
Trait Implementations§
Auto Trait Implementations§
impl<'a, Resume, Yield, Return> !Freeze for Fiber<'a, Resume, Yield, Return>
impl<'a, Resume, Yield, Return> !RefUnwindSafe for Fiber<'a, Resume, Yield, Return>
impl<'a, Resume, Yield, Return> !Send for Fiber<'a, Resume, Yield, Return>
impl<'a, Resume, Yield, Return> !Sync for Fiber<'a, Resume, Yield, Return>
impl<'a, Resume, Yield, Return> Unpin for Fiber<'a, Resume, Yield, Return>
impl<'a, Resume, Yield, Return> !UnwindSafe for Fiber<'a, Resume, Yield, Return>
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
Mutably borrows from an owned value. Read more