Skip to main content

Handle

Struct Handle 

Source
pub struct Handle { /* private fields */ }
Expand description

A thread-safe handle for submitting work to a Tokio-backed arbiter.

Clones share the same target arbiter; they do not create another runtime.

Implementations§

Source§

impl Handle

Source

pub fn current() -> Handle

Returns a handle to the current arbiter’s runtime.

§Panics

Panics if no arbiter is installed on the current thread. A Tokio runtime context alone is not sufficient.

Source

pub fn notify(&self)

Compatibility hook that does nothing on the Tokio backend.

Task submission and task wakers notify Tokio automatically.

Source

pub fn busy_duration(&self) -> Option<Duration>

Returns the total time the runtime has been busy.

Reports Tokio’s worker_total_busy_duration, which excludes time spent handling driver events. Returns None if the arbiter does not run on a current-thread Tokio runtime.

Source

pub fn current_turn(&self) -> Option<Duration>

Returns how long the current runtime turn has been running.

Tokio does not expose runtime turns; always returns None.

Source

pub fn poll_count(&self) -> Option<u64>

Returns the number of runtime polls, not available on Tokio.

Always returns None, the method exists for compatibility with the other runtime backends.

Source

pub fn poll_again_count(&self) -> Option<u64>

Returns the number of runtime polls that left scheduled tasks, not available on Tokio.

Always returns None, the method exists for compatibility with the other runtime backends.

Source

pub fn self_wake_count(&self) -> Option<u64>

Returns the number of times a task woke itself while it was polled, not available on Tokio.

Always returns None, the method exists for compatibility with the native runtime.

Source

pub fn current_task(&self) -> Option<&'static Location<'static>>

Returns the spawn location of the task the runtime is polling, not available on Tokio.

Always returns None, the method exists for compatibility with the native runtime.

Source

pub fn poll_histogram(&self) -> Option<Histogram>

Returns the histogram of runtime turn durations, not available on Tokio.

Always returns None, the method exists for compatibility with the other runtime backends.

Source

pub fn spawn<F>(&self, future: F) -> RemoteJoinHandle<<F as Future>::Output> ⓘ
where F: Future + Send + 'static, <F as Future>::Output: Send + 'static,

Spawns a task on the handle’s runtime and returns a RemoteJoinHandle.

There is no guarantee that a spawned task will execute to completion. Both the future and output must be Send, even when submitted on the runtime thread, which uses the local spawn fast path. Accepted futures are polled and dropped on the runtime thread, with the output transferred through the join handle. Rejected submissions are never polled and their futures may be dropped on the submitting thread.

The returned join handle is neither Send nor Sync; dropping it detaches the task.

§Panics

Panics on the owner thread if there is no Tokio context supporting local spawning. Submissions from other threads do not require one.

Source

pub fn spawn_detached<F>(&self, future: F)
where F: Future + Send + 'static,

Spawns a new asynchronous task without a join handle.

The output is dropped on the runtime thread when the task completes, so it does not have to be Send. The future must be Send, even on the owner thread. Rejected submissions are never polled and their futures may be dropped on the submitting thread.

§Panics

Panics on the owner thread if there is no Tokio context supporting local spawning. Submissions from other threads do not require one.

Trait Implementations§

Source§

impl Clone for Handle

Source§

fn clone(&self) -> Handle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Handle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V