Struct zircon_object::task::CurrentThread [−][src]
A handle to current thread.
This is a wrapper of Thread
that provides additional methods for the thread runner.
It can only be obtained from the argument of thread_fn
in a new thread started by Thread::start
.
It will terminate current thread on drop.
Implementations
impl CurrentThread
[src]
pub fn exit(&self)
[src]
Exit the current thread.
The thread do not terminate immediately when exited. It is just made dying. It will terminate after some cleanups on this struct drop.
pub fn wait_for_run(&self) -> impl Future<Output = Box<UserContext>>
[src]
Wait until the thread is ready to run (not suspended), and then take away its context to run the thread.
pub fn end_running(&self, context: Box<UserContext>)
[src]
The thread ends running and takes back the context.
pub fn with_context<T, F>(&self, f: F) -> T where
F: FnOnce(&mut UserContext) -> T,
[src]
F: FnOnce(&mut UserContext) -> T,
Access saved context of current thread.
Will panic if the context is not availiable.
pub async fn blocking_run<F, T, FT>(
&self,
future: F,
state: ThreadState,
deadline: Duration,
cancel_token: Option<Receiver<()>>
) -> ZxResult<T> where
F: Future<Output = FT> + Unpin,
FT: IntoResult<T>,
[src]
&self,
future: F,
state: ThreadState,
deadline: Duration,
cancel_token: Option<Receiver<()>>
) -> ZxResult<T> where
F: Future<Output = FT> + Unpin,
FT: IntoResult<T>,
Run async future and change state while blocking.
pub async fn handle_exception(&self, type_: ExceptionType)
[src]
Create an exception on this thread and wait for the handling.
Methods from Deref<Target = Arc<Thread>>
Trait Implementations
impl Deref for CurrentThread
[src]
type Target = Arc<Thread>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl Drop for CurrentThread
[src]
Auto Trait Implementations
impl !RefUnwindSafe for CurrentThread
impl Send for CurrentThread
impl Sync for CurrentThread
impl Unpin for CurrentThread
impl !UnwindSafe for CurrentThread
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
[src]
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
pub fn as_any(&self) -> &(dyn Any + 'static)
[src]
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> DowncastSync for T where
T: Send + Sync + Any,
[src]
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,