use std::sync::Arc;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CasDecision<T, R, E> {
Update {
next: Arc<T>,
output: R,
},
Finish {
output: R,
},
Retry(E),
Abort(E),
}
impl<T, R, E> CasDecision<T, R, E> {
#[inline]
pub fn update(next: T, output: R) -> Self {
Self::Update {
next: Arc::new(next),
output,
}
}
#[inline]
pub fn update_arc(next: Arc<T>, output: R) -> Self {
Self::Update { next, output }
}
#[inline]
pub fn finish(output: R) -> Self {
Self::Finish { output }
}
#[inline]
pub fn retry(error: E) -> Self {
Self::Retry(error)
}
#[inline]
pub fn abort(error: E) -> Self {
Self::Abort(error)
}
}