update` takes two [`Ordering`] arguments to describe the memory ordering of this operation. The first describes the required ordering for when the operation finally succeeds while the second describes the required ordering for loads. These correspond to the success and failure orderings of [`compare_exchange`](Self::compare_exchange) respectively. Using [`Acquire`] as success ordering makes the store part of this operation [`Relaxed`], and using [`Release`] makes the final successful load [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]. # Panics Panics if `fetch_order` is [`Release`], [`AcqRel`]. # Considerations This method is not magic; it is not provided by the hardware. It is implemented in terms of [`compare_exchange_weak`](Self::compare_exchange_weak), and suffers from the same drawbacks. In particular, this method will not circumvent the [ABA Problem]. [ABA Problem]: https://en.wikipedia.org/wiki/ABA_problem # Examples ``` use portable_atomic::{AtomicI32, Ordering}; let x = AtomicI32::new(7); assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |_| None), Err(7)); assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(x + 1)), Ok(7)); assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(x + 1)), Ok(8)); assert_eq!(x.load(Ordering::SeqCst), 9); ```