pub struct Lifecycle {
pub cancel: CancellationToken,
pub finalize_done: Arc<AtomicBool>,
pub ledger: Arc<Mutex<ResourceLedger>>,
}Expand description
Runtime token for cooperative cancel and FINALIZE.
§Ownership
Clones share the same Arc ledger and cancel token. Dropping any clone that
wins the finalize CAS performs residual cleanup — treat as a resource owner
(#[must_use]).
Fields§
§cancel: CancellationTokenCancellation token shared with async tasks.
finalize_done: Arc<AtomicBool>Whether FINALIZE already completed.
Updated with Ordering::SeqCst so a single total order is visible to
Drop, signal handlers, and async tasks racing on idempotent finalize.
ledger: Arc<Mutex<ResourceLedger>>Owned resources for residual cleanup.
std::sync::Mutex (not tokio::sync::Mutex): critical sections are short
and never held across .await. Poison is always recovered via
Self::with_ledger_mut so residual FINALIZE cannot sticky-fail.
Implementations§
Source§impl Lifecycle
impl Lifecycle
Sourcepub fn with_ledger_mut<R>(&self, f: impl FnOnce(&mut ResourceLedger) -> R) -> R
pub fn with_ledger_mut<R>(&self, f: impl FnOnce(&mut ResourceLedger) -> R) -> R
Mutate the resource ledger under the mutex.
§Poison policy
Recovers via PoisonError::into_inner so a prior panic cannot prevent
residual kill/wipe (rules: treat PoisonError, never silent-skip FINALIZE).
Sourcepub fn record_chrome(&self, pid: Option<u32>)
pub fn record_chrome(&self, pid: Option<u32>)
Record that this invocation launched Chrome (residual kill target).
Sourcepub fn clear_chrome(&self)
pub fn clear_chrome(&self)
Clear residual Chrome ownership after primary close reaped the child.
Sourcepub fn clear_chrome_and_profile(&self)
pub fn clear_chrome_and_profile(&self)
Clear Chrome + profile ledger after primary session shutdown.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Whether cooperative cancel was requested (signal or finalize).
Trait Implementations§
Source§impl Drop for Lifecycle
Safety net: if the call site forgets explicit Lifecycle::finalize, Drop still
runs residual cleanup (sync only: kill/wipe; no async I/O).
impl Drop for Lifecycle
Safety net: if the call site forgets explicit Lifecycle::finalize, Drop still
runs residual cleanup (sync only: kill/wipe; no async I/O).
§Drop contract
- Idempotent via
finalize_done(SeqCstCAS). - Bounded: residual Unix path may sleep up to
FINALIZE_CHILD_GRACE(not indefinite; rules forbid unbounded block in Drop). - No panic: kill/wipe errors are ignored (best-effort).
- Clones share the same Arcs; the first Drop that wins the CAS performs work.
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().