Skip to main content

JoinHandle

Struct JoinHandle 

Source
pub struct JoinHandle<T> { /* private fields */ }
Expand description

A spawned task (Bot::spawn): await it for its result, or JoinHandle::abort it. Dropping the handle does not stop the task.

Implementations§

Source§

impl<T> JoinHandle<T>

Source

pub fn abort(&self)

Stops the task at the next tick (it is dropped, which cancels what it awaits).

let h = bot.spawn(async {});
h.abort();
Source

pub fn is_finished(&self) -> bool

Whether the task finished (or was cancelled).

let h = bot.spawn(async {});
bot.next_tick().await;
assert!(h.is_finished());

Trait Implementations§

Source§

impl<T> Debug for JoinHandle<T>

Source§

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

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

impl<T> Future for JoinHandle<T>

Source§

type Output = Result<T, Error>

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more

Auto Trait Implementations§

§

impl<T> Forget for JoinHandle<T>

§

impl<T> Freeze for JoinHandle<T>
where *const ArcInner<Mutex<Shared>> is !null: Freeze, PhantomData<ArcInner<Mutex<Shared>>>: Freeze, *const ArcInner<Mutex<JoinSlot<T>>> is !null: Freeze, PhantomData<ArcInner<Mutex<JoinSlot<T>>>>: Freeze,

§

impl<T> Move for JoinHandle<T>

§

impl<T> RefUnwindSafe for JoinHandle<T>
where Atomic<usize>: RefUnwindSafe, Mutex<Shared>: RefUnwindSafe, Mutex<JoinSlot<T>>: RefUnwindSafe,

§

impl<T> Send for JoinHandle<T>
where Arc<Mutex<Shared>>: Send, Arc<Mutex<JoinSlot<T>>>: Send,

§

impl<T> Sync for JoinHandle<T>
where Arc<Mutex<Shared>>: Sync, Arc<Mutex<JoinSlot<T>>>: Sync,

§

impl<T> Unpin for JoinHandle<T>
where Arc<Mutex<Shared>>: Unpin, Arc<Mutex<JoinSlot<T>>>: Unpin,

§

impl<T> UnsafeUnpin for JoinHandle<T>
where *const ArcInner<Mutex<Shared>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<Shared>>>: UnsafeUnpin, *const ArcInner<Mutex<JoinSlot<T>>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<JoinSlot<T>>>>: UnsafeUnpin,

§

impl<T> UnwindSafe for JoinHandle<T>
where Arc<Mutex<Shared>>: UnwindSafe, Arc<Mutex<JoinSlot<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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V