Skip to main content

CasExecutor

Struct CasExecutor 

Source
pub struct CasExecutor<T, E = BoxError> { /* private fields */ }
Expand description

Executor for retry-aware compare-and-swap workflows.

Implementations§

Source§

impl<T, E> CasExecutor<T, E>

Source

pub fn builder() -> CasBuilder<T, E>

Creates a CAS builder.

§Returns

A builder configured with default retry settings.

Source

pub fn from_options(options: RetryOptions) -> Result<Self, RetryConfigError>

Creates an executor from retry options.

§Parameters
  • options: Retry options to validate and install.
§Returns

A configured executor using the default timeout policy.

§Errors

Returns the retry-layer validation error when options are invalid.

Source

pub fn latency_first() -> Self

Creates an executor tuned for low-latency workloads.

§Returns

A configured executor. The built-in strategy is always valid.

Source

pub fn contention_adaptive() -> Self

Creates an executor tuned for hot-contention workloads.

§Returns

A configured executor. The built-in strategy is always valid.

Source

pub fn reliability_first() -> Self

Creates an executor tuned for reliability-first workloads.

§Returns

A configured executor. The built-in strategy is always valid.

Source

pub fn with_strategy(strategy: CasStrategy) -> Self

Creates an executor from a built-in strategy.

§Parameters
  • strategy: Strategy to install.
§Returns

A configured executor. Built-in strategies are always valid.

Source

pub fn options(&self) -> &RetryOptions

Returns the immutable retry options used by this executor.

§Returns

Shared retry options.

Source

pub fn attempt_timeout(&self) -> Option<Duration>

Returns the configured async attempt timeout.

§Returns

Some(Duration) when async attempts have a timeout.

Source

pub fn timeout_policy(&self) -> CasTimeoutPolicy

Returns the timeout policy.

§Returns

Policy used when an async attempt exceeds the timeout.

Source

pub fn observability(&self) -> &CasObservabilityConfig

Returns observability settings used by this executor.

§Returns

Shared observability configuration.

Source

pub fn execute<R, O>( &self, state: &AtomicRef<T>, operation: O, ) -> CasOutcome<T, R, E>
where T: 'static, E: 'static, O: Function<T, CasDecision<T, R, E>>,

Executes one synchronous CAS operation.

§Parameters
  • state: Shared atomic state container.
  • operation: Pure operation that inspects the current state and returns a CAS decision.
§Returns

A terminal result together with the execution report.

Source

pub fn execute_with_hooks<R, O>( &self, state: &AtomicRef<T>, operation: O, hooks: CasHooks, ) -> CasOutcome<T, R, E>
where T: 'static, E: 'static, O: Function<T, CasDecision<T, R, E>>,

Executes one synchronous CAS operation with lifecycle hooks.

§Parameters
  • state: Shared atomic state container.
  • operation: Pure operation that inspects the current state and returns a CAS decision.
  • hooks: Per-execution hook registrations.
§Returns

A terminal result together with the execution report.

Source

pub async fn execute_async<R, O, Fut>( &self, state: &AtomicRef<T>, operation: O, ) -> CasOutcome<T, R, E>
where T: 'static, E: 'static, O: Fn(Arc<T>) -> Fut, Fut: Future<Output = CasDecision<T, R, E>>,

Executes one asynchronous CAS operation.

§Parameters
  • state: Shared atomic state container.
  • operation: Async operation factory receiving one state snapshot.
§Returns

A terminal result together with the execution report.

Source

pub async fn execute_async_with_hooks<R, O, Fut>( &self, state: &AtomicRef<T>, operation: O, hooks: CasHooks, ) -> CasOutcome<T, R, E>
where T: 'static, E: 'static, O: Fn(Arc<T>) -> Fut, Fut: Future<Output = CasDecision<T, R, E>>,

Executes one asynchronous CAS operation with lifecycle hooks.

§Parameters
  • state: Shared atomic state container.
  • operation: Async operation factory receiving one state snapshot.
  • hooks: Per-execution hook registrations.
§Returns

A terminal result together with the execution report.

Trait Implementations§

Source§

impl<T: Clone, E: Clone> Clone for CasExecutor<T, E>

Source§

fn clone(&self) -> CasExecutor<T, E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, E: Debug> Debug for CasExecutor<T, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, E> Freeze for CasExecutor<T, E>

§

impl<T, E> RefUnwindSafe for CasExecutor<T, E>

§

impl<T, E> Send for CasExecutor<T, E>

§

impl<T, E> Sync for CasExecutor<T, E>

§

impl<T, E> Unpin for CasExecutor<T, E>

§

impl<T, E> UnsafeUnpin for CasExecutor<T, E>

§

impl<T, E> UnwindSafe for CasExecutor<T, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoResult<T> for T

Source§

impl<T> IntoResult<T> for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.