#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct FastCasSuccess<R> {
previous: usize,
current: usize,
output: R,
attempts: u32,
}
impl<R> FastCasSuccess<R> {
#[inline]
pub(crate) const fn new(previous: usize, current: usize, output: R, attempts: u32) -> Self {
Self {
previous,
current,
output,
attempts,
}
}
#[inline]
pub const fn previous(&self) -> usize {
self.previous
}
#[inline]
pub const fn current(&self) -> usize {
self.current
}
#[inline]
pub const fn output(&self) -> &R {
&self.output
}
#[inline]
pub fn into_output(self) -> R {
self.output
}
#[inline]
pub const fn attempts(&self) -> u32 {
self.attempts
}
#[inline]
pub const fn is_updated(&self) -> bool {
self.previous != self.current
}
#[inline]
pub const fn is_finished(&self) -> bool {
self.previous == self.current
}
}