use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CasStrategyProfile {
max_attempts: u32,
max_operation_elapsed: Duration,
max_total_elapsed: Option<Duration>,
target_conflict_ratio: f64,
uses_backoff: bool,
}
impl CasStrategyProfile {
#[inline]
pub(crate) const fn new(
max_attempts: u32,
max_operation_elapsed: Duration,
max_total_elapsed: Option<Duration>,
target_conflict_ratio: f64,
uses_backoff: bool,
) -> Self {
Self {
max_attempts,
max_operation_elapsed,
max_total_elapsed,
target_conflict_ratio,
uses_backoff,
}
}
#[inline]
pub fn max_attempts(&self) -> u32 {
self.max_attempts
}
#[inline]
pub fn max_operation_elapsed(&self) -> Duration {
self.max_operation_elapsed
}
#[inline]
pub fn max_total_elapsed(&self) -> Option<Duration> {
self.max_total_elapsed
}
#[inline]
pub fn target_conflict_ratio(&self) -> f64 {
self.target_conflict_ratio
}
#[inline]
pub fn uses_backoff(&self) -> bool {
self.uses_backoff
}
}