Trait atomic_cell::compare_update::CompareUpdate
source · [−]pub trait CompareUpdate<Current, T> {
type Error;
type Retry;
type Final;
fn initial(self) -> (Self::Retry, Current, T);
fn retry(
retry: Self::Retry,
current: Current,
val: T
) -> Result<(Self::Retry, T), Self::Error>;
fn finalize(retry: Self::Retry, val: T) -> Self::Final;
}
Expand description
How to treat data across retries of AtomicCell::compare_update_raw
Required Associated Types
sourcetype Error
type Error
The error type for CompareUpdate::retry
s
Required Methods
sourcefn initial(self) -> (Self::Retry, Current, T)
fn initial(self) -> (Self::Retry, Current, T)
Create the values for the first compare_exchange_weak
and some backup data for retries.
U
is the assumed current
value
sourcefn retry(
retry: Self::Retry,
current: Current,
val: T
) -> Result<(Self::Retry, T), Self::Error>
fn retry(
retry: Self::Retry,
current: Current,
val: T
) -> Result<(Self::Retry, T), Self::Error>
Try to create the data for the next iteration
current
is the value returned from the failed attempt to exchange
val
is the value which was failed to be stored by the previous iteration
sourcefn finalize(retry: Self::Retry, val: T) -> Self::Final
fn finalize(retry: Self::Retry, val: T) -> Self::Final
Combine the retry data and the swapped out value into the CompareUpdate::Final
data.