pub struct SpawnedTask<R> { /* private fields */ }
Expand description
Helper that provides a simple API to spawn a single task and join it.
Provides guarantees of aborting on Drop
to keep it cancel-safe.
Technically, it’s just a wrapper of JoinSet
(with size=1).
Implementations§
Source§impl<R: 'static> SpawnedTask<R>
impl<R: 'static> SpawnedTask<R>
pub fn spawn<T>(task: T) -> Self
pub fn spawn_blocking<T>(task: T) -> Self
Sourcepub async fn join(self) -> Result<R, JoinError>
pub async fn join(self) -> Result<R, JoinError>
Joins the task, returning the result of join (Result<R, JoinError>
).
Sourcepub async fn join_unwind(self) -> Result<R, JoinError>
pub async fn join_unwind(self) -> Result<R, JoinError>
Joins the task and unwinds the panic if it happens.
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for SpawnedTask<R>
impl<R> RefUnwindSafe for SpawnedTask<R>
impl<R> Send for SpawnedTask<R>where
R: Send,
impl<R> Sync for SpawnedTask<R>where
R: Send,
impl<R> Unpin for SpawnedTask<R>
impl<R> UnwindSafe for SpawnedTask<R>
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