Struct wasmtime_fiber::Fiber
source · 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, &Suspend<Resume, Yield, Return>) -> Return + 'a
) -> Result<Self>
pub fn new( stack: FiberStack, func: impl FnOnce(Resume, &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.
Trait Implementations§
Auto Trait Implementations§
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>where Resume: RefUnwindSafe, Return: RefUnwindSafe, Yield: RefUnwindSafe,
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