Skip to main content

try_update_usize

Function try_update_usize 

Source
pub fn try_update_usize(
    counter: &AtomicUsize,
    set_order: Ordering,
    fetch_order: Ordering,
    update: impl FnMut(usize) -> Option<usize>,
) -> Result<usize, usize>
Expand description

Apply a checked update, returning the previous value on success or rejection.

The callback can run again after contention or a spurious CAS failure. None rejects without writing. The orderings are the successful CAS ordering and the load/failed CAS ordering, respectively.