pub struct BusyHandlerState { /* private fields */ }Expand description
Tracks the state of busy handler invocations for a statement.
This implements a yield-based busy handling mechanism that integrates with
the async event loop. Instead of blocking with thread::sleep, the statement
yields back to the caller with StepResult::IO and a timeout. When step()
is called again after the timeout has passed, it retries the operation.
Uses increasing delays. After 12 iterations, continues with 100ms delays until max duration is reached.
Implementations§
Source§impl BusyHandlerState
impl BusyHandlerState
Sourcepub fn new(now: MonotonicInstant) -> Self
pub fn new(now: MonotonicInstant) -> Self
Create a new busy handler state
Sourcepub fn reset(&mut self, now: MonotonicInstant)
pub fn reset(&mut self, now: MonotonicInstant)
Reset the state for a new locking event
Sourcepub fn timeout(&self) -> MonotonicInstant
pub fn timeout(&self) -> MonotonicInstant
Get the current timeout instant
Sourcepub fn invoke(&mut self, handler: &BusyHandler, now: MonotonicInstant) -> bool
pub fn invoke(&mut self, handler: &BusyHandler, now: MonotonicInstant) -> bool
Invoke the busy handler and determine whether to retry.
Returns true if the operation should be retried, false if SQLITE_BUSY
should be returned to the application.
For timeout-based handlers, this also updates the internal timeout instant. For custom handlers, this invokes the callback and respects its return value.
Sourcepub fn get_delay(&self, now: MonotonicInstant) -> Duration
pub fn get_delay(&self, now: MonotonicInstant) -> Duration
Get the delay duration that should be waited before the next retry.
This returns the duration between now and the timeout instant.
Returns Duration::ZERO if the timeout has already passed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BusyHandlerState
impl RefUnwindSafe for BusyHandlerState
impl Send for BusyHandlerState
impl Sync for BusyHandlerState
impl Unpin for BusyHandlerState
impl UnsafeUnpin for BusyHandlerState
impl UnwindSafe for BusyHandlerState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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