Skip to main content

Fiber

Struct Fiber 

Source
pub struct Fiber { /* private fields */ }
Expand description

One carrier-local stackful execution context.

ⓘ
fn require_send<T: Send>() {}
require_send::<vthread_stack::Fiber>();

Implementations§

Source§

impl Fiber

Source

pub fn new<F>(stack: MappedStack, entry: F) -> Self
where F: FnOnce() + 'static,

Creates a fiber on an already allocated stack.

Source

pub fn resume(&mut self) -> FiberState

Mounts the fiber until it suspends or completes.

Panics if the fiber has already completed, without mounting its old control block.

Source

pub fn resume_with(&mut self, resume: Resume) -> FiberState

Mounts the fiber and delivers a decision to its last suspension point.

Source

pub fn is_complete(&self) -> bool

Returns whether the entry function has completed.

Source

pub fn into_stack(self) -> MappedStack

Reclaims the stack after completion so it can be reused.

Panics if incomplete; suspended frames unwind on their fiber, while an unstarted entry is reclaimed on the caller’s stack.

Trait Implementations§

Source§

impl Drop for Fiber

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Fiber

§

impl !Send for Fiber

§

impl !Sync for Fiber

§

impl !UnwindSafe for Fiber

§

impl Forget for Fiber

§

impl Freeze for Fiber

§

impl Unpin for Fiber

§

impl UnsafeUnpin for Fiber

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.