Skip to main content

ElapsedComputeFuture

Struct ElapsedComputeFuture 

Source
pub struct ElapsedComputeFuture<T> { /* private fields */ }
Expand description

Wraps any Future and accumulates the wall-clock time spent inside each Future::poll call into elapsed_compute. Everything that executes synchronously within a poll() scope is measured — including CPU-bound work, memory copies, and any blocking the future performs before returning. Time between polls (when the runtime has suspended the future waiting for I/O, a channel, or a waker) is not measured.

For futures that mix synchronous CPU work with async I/O this gives a good approximation of CPU time: async I/O causes the future to yield (Poll::Pending), so the I/O latency is excluded automatically.

Note: uses pin-project rather than pin-project-lite in order to support PinnedDrop, which ensures accumulated time is flushed even if the future is cancelled (dropped before completion).

Trait Implementations§

Source§

impl<T> Drop for ElapsedComputeFuture<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<O, F: Future<Output = O>> Future for ElapsedComputeFuture<F>

Source§

type Output = O

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
Source§

impl<'pin, T> Unpin for ElapsedComputeFuture<T>
where PinnedFieldsOf<__ElapsedComputeFuture<'pin, T>>: Unpin,

Auto Trait Implementations§

§

impl<T> Freeze for ElapsedComputeFuture<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ElapsedComputeFuture<T>
where T: RefUnwindSafe,

§

impl<T> Send for ElapsedComputeFuture<T>
where T: Send,

§

impl<T> Sync for ElapsedComputeFuture<T>
where T: Sync,

§

impl<T> UnsafeUnpin for ElapsedComputeFuture<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for ElapsedComputeFuture<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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
Source§

impl<O, F> ElapsedComputeFutureExt for F
where F: Future<Output = O>,

Source§

fn with_elapsed_compute(self, elapsed_compute: Time) -> ElapsedComputeFuture<F>

Wraps this future so that the time spent inside each Future::poll call is accumulated into elapsed_compute. See ElapsedComputeFuture for a full description of what is and is not measured.
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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.