@@ -3326,23 +3326,24 @@ macro_rules! atomic_int {
33263326 unsafe { atomic_xor( self . v. get( ) , val, order) }
33273327 }
33283328
3329- /// Fetches the value, and applies a function to it that returns an optional
3330- /// new value. Returns a `Result` of `Ok(previous_value)` if the function returned `Some(_)`, else
3331- /// `Err(previous_value)`.
3329+ /// Loads the current value, applies a closure to it, and optionally tries to store a new value.
33323330 ///
3333- /// Note: This may call the function multiple times if the value has been changed from other threads in
3334- /// the meantime, as long as the function returns `Some(_)`, but the function will have been applied
3335- /// only once to the stored value.
3331+ /// If the closure ever returns `None`, this method immediately returns `Err(current value)`.
3332+ /// Whenever the closure returns `Some(new value)`, this method calls
3333+ #[ doc = concat!( "[`" , stringify!( $atomic_type) , "::compare_exchange_weak`]" ) ]
3334+ /// to try to store the new value.
33363335 ///
3337- /// `fetch_update` takes two [`Ordering`] arguments to describe the memory ordering of this operation.
3338- /// The first describes the required ordering for when the operation finally succeeds while the second
3339- /// describes the required ordering for loads. These correspond to the success and failure orderings of
3340- # [ doc = concat! ( "[`" , stringify! ( $atomic_type ) , "::compare_exchange`]" ) ]
3341- /// respectively .
3336+ /// If storing a new value fails (due to another thread changing the current value),
3337+ /// then the closure will be called again on the new current value
3338+ /// (returned by `compare_exchange_weak`).
3339+ /// This process repeats until either the closure returns None,
3340+ /// or `compare_exchange_weak` succeeds in storing a new value .
33423341 ///
3343- /// Using [`Acquire`] as success ordering makes the store part
3344- /// of this operation [`Relaxed`], and using [`Release`] makes the final successful load
3345- /// [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`].
3342+ /// Returns `Ok(previous value)` if it ever succeeds in storing a new value,
3343+ /// otherwise returns `Err(current value)`.
3344+ ///
3345+ /// Takes a `set_order` and a `fetch_order` [`Ordering`] to pass on to `compare_exchange_weak`.
3346+ /// Also uses the `fetch_order` for the initial load.
33463347 ///
33473348 /// **Note**: This method is only available on platforms that support atomic operations on
33483349 #[ doc = concat!( "[`" , $s_int_type, "`]." ) ]
0 commit comments