pub struct Handle { /* private fields */ }
Expand description
Handle to spawn a future on the corresponding CurrentThread
instance
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn spawn<F>(&self, future: F) -> Result<(), SpawnError>
pub fn spawn<F>(&self, future: F) -> Result<(), SpawnError>
Spawn a future onto the CurrentThread
instance corresponding to this handle
§Panics
This function panics if the spawn fails. Failure occurs if the CurrentThread
instance of the Handle
does not exist anymore.
Sourcepub fn status(&self) -> Result<(), SpawnError>
pub fn status(&self) -> Result<(), SpawnError>
Provides a best effort hint to whether or not spawn
will succeed.
This function may return both false positives and false negatives.
If status
returns Ok
, then a call to spawn
will probably
succeed, but may fail. If status
returns Err
, a call to spawn
will
probably fail, but may succeed.
This allows a caller to avoid creating the task if the call to spawn
has a high likelihood of failing.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Handle
impl !RefUnwindSafe for Handle
impl Send for Handle
impl !Sync for Handle
impl Unpin for Handle
impl !UnwindSafe for Handle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)