atomic-circuit-breaker 11.2.0

Zero-dependency, lock-free atomic sliding-window circuit breaker with CAS probe gating, monotonic clock support, and RAII guards.
Documentation
/// Number of fixed ring buckets in the lock-free sliding window (`2^4 = 16`).
pub(crate) const SLIDING_WINDOW_BUCKETS: usize = 16;

/// Bitmask mapping a bucket epoch to a ring slot in `0..16`.
pub(crate) const SLIDING_WINDOW_MASK: usize = SLIDING_WINDOW_BUCKETS - 1;

/// Right-shift converting a bucket epoch into its ring wrap cycle (`epoch >> 4`).
pub(crate) const SLIDING_WINDOW_SHIFT: u32 = 4;

/// Bit width reserved for the per-bucket saturating counter (`67,108,863` per bucket).
pub(crate) const BUCKET_COUNT_BITS: u32 = 26;

/// Bitmask extracting the 26-bit counter from a packed bucket word.
pub(crate) const BUCKET_COUNT_MASK: u64 = (1u64 << BUCKET_COUNT_BITS) - 1;

/// Bit width reserved for the sliding-window wrap cycle inside the bucket tag.
pub(crate) const BUCKET_CYCLE_BITS: u32 = 28;

/// Bitmask extracting the 28-bit cycle from a bucket tag.
pub(crate) const BUCKET_CYCLE_MASK: u64 = (1u64 << BUCKET_CYCLE_BITS) - 1;

/// Half-ring threshold for monotonic modular cycle comparison.
pub(crate) const BUCKET_CYCLE_HALF: u64 = 1u64 << (BUCKET_CYCLE_BITS - 1);

/// Bit width reserved for the breaker generation inside the bucket tag.
pub(crate) const BUCKET_GEN_BITS: u32 = 10;

/// Bitmask extracting the 10-bit generation tag.
pub(crate) const BUCKET_GEN_MASK: u64 = (1u64 << BUCKET_GEN_BITS) - 1;

/// Highest ring-bucket index (`15`) used to detect full-window saturation.
pub(crate) const SLIDING_WINDOW_LAST_SLOT: u64 = (SLIDING_WINDOW_BUCKETS - 1) as u64;

/// Half-ring threshold for monotonic modular generation comparison.
pub(crate) const BUCKET_GEN_HALF: u64 = 1u64 << (BUCKET_GEN_BITS - 1);

/// Number of cache-line-isolated success stripes eliminating atomic RMW address stalls.
pub(crate) const SUCCESS_STRIPE_COUNT: usize = 4;

/// Mask selecting one of the four cache-line-isolated success stripes (`0..4`).
pub(crate) const SUCCESS_STRIPE_MASK: usize = SUCCESS_STRIPE_COUNT - 1;

/// Headroom below `BUCKET_COUNT_MASK` allowing wait-free `fetch_add` without tag overflow.
pub(crate) const BUCKET_COUNT_SAFE_MAX: u64 = BUCKET_COUNT_MASK - 65_535;