pub struct Job<T: Send + 'static> { /* private fields */ }Expand description
A single closure running on its own thread. Create with Job::spawn, reap
with Job::join. Dropping a Job without joining detaches the thread (the
closure runs to completion but its result and any panic are lost) — the
overlap pattern always joins, so prefer explicit Job::join.
Implementations§
Source§impl<T: Send + 'static> Job<T>
impl<T: Send + 'static> Job<T>
Sourcepub fn spawn<F>(f: F) -> Self
pub fn spawn<F>(f: F) -> Self
Spawn f on a fresh background thread and return immediately. The caller
keeps working; call Job::join later to block for the result.
Sourcepub fn join(self) -> Result<T>
pub fn join(self) -> Result<T>
Block until the job finishes and return its value. A panic inside the job
is surfaced as Err (identical semantics to JoinHandle::join) rather
than aborting the caller.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Job<T>
impl<T> !UnwindSafe for Job<T>
impl<T> Freeze for Job<T>
impl<T> Send for Job<T>
impl<T> Sync for Job<T>
impl<T> Unpin for Job<T>
impl<T> UnsafeUnpin for Job<T>
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