pub struct LifecycleController { /* private fields */ }Expand description
The lifecycle controller embedded in every DatabaseCore (spec §10.1,
S1A-004). It owns the state machine plus the in-flight operation counter
that shutdown() drains against.
The controller is shared through an Arc so OperationGuards can be
'static and cross threads freely (a query worker may hold a guard long
after the initiating handle returned).
Implementations§
Source§impl LifecycleController
impl LifecycleController
Sourcepub fn new() -> Self
pub fn new() -> Self
A controller in the Opening state: the core admits no operations
until Self::mark_open completes initialization.
Sourcepub fn state(&self) -> LifecycleState
pub fn state(&self) -> LifecycleState
The current lifecycle state.
Sourcepub fn mark_open(&self)
pub fn mark_open(&self)
Opening → Open. Called exactly once when core initialization
finishes (recovery, WAL opening, open-generation advancement, and
table mounting are done).
Sourcepub fn begin_shutdown(&self) -> bool
pub fn begin_shutdown(&self) -> bool
Open → Draining: the first shutdown() step. Returns true when
this call initiated the drain; false when the core was already past
Open (a concurrent or repeated shutdown), in which case the caller
must not drive the remaining shutdown steps.
Sourcepub fn wait_drained(&self, deadline: Duration) -> Result<()>
pub fn wait_drained(&self, deadline: Duration) -> Result<()>
Wait until every in-flight operation has drained or deadline
elapses. The core stays in Draining either way; a timeout leaves the
shutdown to the caller to retry or abandon.
Sourcepub fn mark_closing(&self)
pub fn mark_closing(&self)
Draining → Closing: operations have drained; durable sync, worker
stop, and file-lock release happen in this state.
Sourcepub fn mark_closed(&self)
pub fn mark_closed(&self)
Closing → Closed: the final shutdown step.
Sourcepub fn poison(&self)
pub fn poison(&self)
Any state → Poisoned: an unrecoverable internal error. Poison is
terminal and sticky — a poisoned core never returns to Open.
Sourcepub fn begin_operation(self: &Arc<Self>) -> Result<OperationGuard>
pub fn begin_operation(self: &Arc<Self>) -> Result<OperationGuard>
Admit one operation (S1A-004: “every operation holds an
OperationGuard”). New operations are rejected unless the core is
Open; the returned guard releases its slot on drop.
Sourcepub fn active_operations(&self) -> u64
pub fn active_operations(&self) -> u64
Number of operations currently holding a guard.
Trait Implementations§
Source§impl Debug for LifecycleController
impl Debug for LifecycleController
Auto Trait Implementations§
impl !Freeze for LifecycleController
impl !RefUnwindSafe for LifecycleController
impl Send for LifecycleController
impl Sync for LifecycleController
impl Unpin for LifecycleController
impl UnsafeUnpin for LifecycleController
impl UnwindSafe for LifecycleController
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> 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