#[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
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
impl LivelinessMonitor
Sourcepub fn start<T, SpawnFunction: Fn(LivelinessMonitorFuture) -> T>(
spawn: SpawnFunction,
) -> (T, Arc<LivelinessMonitor>)
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.
Sourcepub fn latest_report(&self) -> Instant
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.