Struct tarantool::fiber::JoinHandle

source ·
pub struct JoinHandle<'f, T> { /* private fields */ }
Expand description

An owned permission to join a fiber (block on its termination).

NOTE: if JoinHandle is dropped before JoinHandle::join is called on it a panic will happen. Moreover some of the memory needed for passing the result from the fiber to the caller will be leaked in case the panic is caught. Note also that panics within tarantool are in general not recoverable.

Implementations§

source§

impl<'f, T> JoinHandle<'f, T>

source

pub fn join(self) -> T

Block until the fiber’s termination and return it’s result value.

source

pub fn id(&self) -> FiberId

Returns the underlying fiber id.

The fiber id can be used for example with wakeup, cancel, exists, csw_of, etc.

Panicking

This will panic if the current tarantool executable doesn’t support the required api (i.e. has_fiber_id returns false). Consider using Self::id_checked if you want to handle this error.

source

pub fn id_checked(&self) -> Option<FiberId>

Returns the underlying fiber id or None if the current tarantool executable doesn’t support the required api (i.e. has_fiber_id returns false).

The fiber id can be used for example with wakeup, cancel, exists, csw_of, etc.

source

pub fn cancel(&self)

Cancel the underlying fiber.

Does NOT yield.

NOTE: tarantool does not guarantee that the cancelled fiber stops executing. It’s the responsibility of the fiber’s author to check if it was cancelled by checking is_cancelled or similar after any yielding calls and explicitly returning.

source

pub fn wakeup(&self)

Wakeup the underlying fiber.

Does NOT yield.

Trait Implementations§

source§

impl<'f, T> Debug for JoinHandle<'f, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'f, T> Drop for JoinHandle<'f, T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'f, T: Hash> Hash for JoinHandle<'f, T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'f, T: PartialEq> PartialEq for JoinHandle<'f, T>

source§

fn eq(&self, other: &JoinHandle<'f, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'f, T: Eq> Eq for JoinHandle<'f, T>

source§

impl<'f, T> StructuralEq for JoinHandle<'f, T>

source§

impl<'f, T> StructuralPartialEq for JoinHandle<'f, T>

Auto Trait Implementations§

§

impl<'f, T> !RefUnwindSafe for JoinHandle<'f, T>

§

impl<'f, T> !Send for JoinHandle<'f, T>

§

impl<'f, T> !Sync for JoinHandle<'f, T>

§

impl<'f, T> Unpin for JoinHandle<'f, T>

§

impl<'f, T> UnwindSafe for JoinHandle<'f, T>
where T: UnwindSafe,

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.