Struct zircon_object::task::CurrentThread[][src]

pub struct CurrentThread(_);

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]

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]

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.

impl Drop for CurrentThread[src]

fn drop(&mut self)[src]

Terminate the current running thread.

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.