Skip to main content

FastCasPolicy

Enum FastCasPolicy 

Source
pub enum FastCasPolicy {
    Once,
    Spin {
        max_attempts: u32,
    },
    SpinYield {
        spin_attempts: u32,
        max_attempts: u32,
    },
}
Expand description

Retry policy used by crate::FastCas when compare-and-swap loses a race.

Variants§

§

Once

Try the operation once and return conflict on the first failed CAS.

§

Spin

Retry immediately until CAS succeeds, the operation aborts, or the attempt budget is exhausted.

Fields

§max_attempts: u32

Maximum number of CAS attempts, including the first attempt.

§

SpinYield

Spin for a short prefix, then yield between retries until the attempt budget is exhausted.

Fields

§spin_attempts: u32

Number of attempts to run without yielding.

§max_attempts: u32

Maximum number of CAS attempts, including the first attempt.

Implementations§

Source§

impl FastCasPolicy

Source

pub const fn once() -> FastCasPolicy

Creates a policy that performs one CAS attempt.

§Returns

A single-attempt policy.

Source

pub const fn spin(max_attempts: u32) -> FastCasPolicy

Creates an immediate-spin retry policy.

§Parameters
  • max_attempts: Maximum number of CAS attempts. Zero is normalized to one attempt.
§Returns

A spin policy with a non-zero attempt budget.

Source

pub const fn spin_yield(spin_attempts: u32, max_attempts: u32) -> FastCasPolicy

Creates a spin-then-yield retry policy.

§Parameters
  • spin_attempts: Number of attempts to run before yielding.
  • max_attempts: Maximum number of CAS attempts. Zero is normalized to one attempt.
§Returns

A spin-yield policy with a non-zero attempt budget.

Source

pub const fn max_attempts(self) -> u32

Returns the maximum number of attempts allowed by this policy.

§Returns

A non-zero attempt count.

Source

pub const fn should_yield_before(self, next_attempt: u32) -> bool

Returns whether the caller should yield before the next attempt.

§Parameters
  • next_attempt: One-based number of the next attempt to execute.
§Returns

true when this policy should yield before next_attempt.

Trait Implementations§

Source§

impl Clone for FastCasPolicy

Source§

fn clone(&self) -> FastCasPolicy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FastCasPolicy

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for FastCasPolicy

Source§

fn eq(&self, other: &FastCasPolicy) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for FastCasPolicy

Source§

impl Eq for FastCasPolicy

Source§

impl StructuralPartialEq for FastCasPolicy

Auto Trait Implementations§

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> 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.