Struct LivelinessMonitor

Source
#[non_exhaustive]
pub struct LivelinessMonitor { pub latest_report: AtomicInstant, }
Expand description

A liveliness monitor for asynchronous runtimes.

Its only constructor (LivelinessMonitor::start()) returns it wrapped in an Arc with strong count 1. Should that strong count reach 0 (due to dropping all the clones you may have made of that Arc, or by using Arc::try_unwrap()), the associated task spawned in your runtime will end next time upon its next scheduling.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§latest_report: AtomicInstant

The instant of the latest liveliness report.

Implementations§

Source§

impl LivelinessMonitor

Source

pub fn start<T, SpawnFunction: Fn(LivelinessMonitorFuture) -> T>( spawn: SpawnFunction, ) -> (T, Arc<LivelinessMonitor>)

Starts a liveliness monitor on your asynchronous runtime (of which you must pass the spawn method), returning both the handle the runtime may have returned, as well as a reference counted LivelinessMonitor.

Please refer to the examples to learn more about its usage.

Source

pub fn latest_report(&self) -> Instant

The instant of the latest liveliness report, as an std::time::Instant.

Keep in mind its resolution is limited to that of crate::support::AtomicDuration, and that a busy executor may provide updates at rather low frequencies.

You can probably expect that if the report hasn’t been updated in the last 5 seconds, your executor is indeed stalled.

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
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<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, 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.