pub struct ThreadHandle<K: Kernel> {
pub(crate) thread: NonNull<Thread<K>>,
kernel: K,
}Expand description
A reference counted reference to a Thread.
A ThreadHandle can has a limited set of APIs that are safe to call without
holding the scheduler lock.
Fields§
§thread: NonNull<Thread<K>>§kernel: KImplementations§
Source§impl<K: Kernel> ThreadHandle<K>
impl<K: Kernel> ThreadHandle<K>
Sourcepub fn join(self, kernel: K) -> Result<(ForeignBox<Thread<K>>, ExitStatus)>
pub fn join(self, kernel: K) -> Result<(ForeignBox<Thread<K>>, ExitStatus)>
Join the referenced thread.
Waits until the all other references to the thread are dropped and the
thread terminates. Returns a ForeignBox<Thread<K>> which can be used
to restart the thread.
pub fn try_join(self, kernel: K) -> TryJoinResult<K>
pub fn try_join_locked<'a>( self, kernel: K, sched: SpinLockGuard<'a, K, SchedulerState<K>>, ) -> (SpinLockGuard<'a, K, SchedulerState<K>>, TryJoinResult<K>)
Sourcepub fn join_until(self, kernel: K, deadline: Instant<K::Clock>) -> JoinResult<K>
pub fn join_until(self, kernel: K, deadline: Instant<K::Clock>) -> JoinResult<K>
Join the referenced thread with a deadline
Waits until the all other references to the thread are dropped and the thread terminates.
Returns:
Ok(thread): Success.threadcan be used to restart the thread.Err(Error::DeadlineExceeded: The thread did not enter a joinable state beforedeadline` was passed.
Sourcepub fn terminate(&mut self, kernel: K, status: ExitStatus) -> Result<()>
pub fn terminate(&mut self, kernel: K, status: ExitStatus) -> Result<()>
Request termination of the thread.
Asynchronously requests the referenced thread to terminate. While in the terminating state:
- The thread’s
terminatingfield will be set totrue. - Any active interruptible waits will be canceled with
Error::Cancelled. - Any new interruptible wait will immediately return
Error::Cancelled. - All non-interruptible waits will work as normal.
This is an ASYNCHRONOUS operation. The thread is marked as terminating, but it may not exit immediately.
To wait for the thread to terminate, call ThreadHandle::join() or
ThreadHandle::join_until().
Sourcepub fn is_terminating(&self, kernel: K) -> bool
pub fn is_terminating(&self, kernel: K) -> bool
Returns true if the thread is in the terminating state.
Note: This is a parallel state to the state returned by ThreadHandle::is_terminating().
Trait Implementations§
Source§impl<K: Kernel> Clone for ThreadHandle<K>
impl<K: Kernel> Clone for ThreadHandle<K>
Source§impl<K: Kernel> Drop for ThreadHandle<K>
impl<K: Kernel> Drop for ThreadHandle<K>
impl<K: Kernel> Send for ThreadHandle<K>
impl<K: Kernel> Sync for ThreadHandle<K>
Auto Trait Implementations§
impl<K> !RefUnwindSafe for ThreadHandle<K>
impl<K> !UnwindSafe for ThreadHandle<K>
impl<K> Forget for ThreadHandle<K>
impl<K> Freeze for ThreadHandle<K>where
NonNull<Thread<K>>: Freeze,
K: Freeze,
impl<K> Move for ThreadHandle<K>
impl<K> Unpin for ThreadHandle<K>where
NonNull<Thread<K>>: Unpin,
K: Unpin,
impl<K> UnsafeUnpin for ThreadHandle<K>where
NonNull<Thread<K>>: UnsafeUnpin,
K: UnsafeUnpin,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)