pub struct Lifecycle { /* private fields */ }Expand description
Process/engine lifecycle with atomic admission and active-op accounting.
Admission and op registration happen in one synchronized path so shutdown cannot race a half-admitted operation.
Implementations§
Source§impl Lifecycle
impl Lifecycle
pub fn new() -> Self
pub fn state(&self) -> LifecycleState
pub fn active_ops(&self) -> usize
Sourcepub fn try_begin_op(&self) -> Result<OpAdmission<'_>, AdmissionError>
pub fn try_begin_op(&self) -> Result<OpAdmission<'_>, AdmissionError>
Atomically admit one operation if still Running.
On success, active count is incremented; caller MUST drop the returned
OpAdmission (or call Self::end_op) when the op finishes.
Sourcepub fn shutdown(&self, timeout: Duration) -> Result<(), ShutdownError>
pub fn shutdown(&self, timeout: Duration) -> Result<(), ShutdownError>
Close admission and wait for active ops to reach zero.
On success transitions to Stopped. On timeout leaves ShuttingDown and
returns ShutdownError::Busy — does not claim completion and does
not authorize cache clears.
Idempotent: calling while already Stopped succeeds. Calling while ShuttingDown continues waiting for the remaining active count.
Sourcepub fn mark_stopped_if_idle(&self) -> bool
pub fn mark_stopped_if_idle(&self) -> bool
Force Stopped only when active is zero (test helper / finalizer).
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Whether new work may be admitted.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Lifecycle
impl RefUnwindSafe for Lifecycle
impl Send for Lifecycle
impl Sync for Lifecycle
impl Unpin for Lifecycle
impl UnsafeUnpin for Lifecycle
impl UnwindSafe for Lifecycle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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