1
Fork 0

Warn about safety of fetch_update

Specifically as it relates to the ABA problem.
This commit is contained in:
Keenan Gugeler 2022-09-14 13:25:14 -04:00
parent 1ce51982b8
commit 3d28a1ad76

View file

@ -955,6 +955,14 @@ impl AtomicBool {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`. /// operations on `u8`.
/// ///
/// # Considerations
///
/// This method is not magic; it is not provided by the hardware.
/// It is implemented in terms of [`AtomicBool::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 /// # Examples
/// ///
/// ```rust /// ```rust
@ -1422,6 +1430,14 @@ impl<T> AtomicPtr<T> {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on pointers. /// operations on pointers.
/// ///
/// # Considerations
///
/// This method is not magic; it is not provided by the hardware.
/// It is implemented in terms of [`AtomicPtr::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 /// # Examples
/// ///
/// ```rust /// ```rust
@ -2510,6 +2526,16 @@ macro_rules! atomic_int {
/// **Note**: This method is only available on platforms that support atomic operations on /// **Note**: This method is only available on platforms that support atomic operations on
#[doc = concat!("[`", $s_int_type, "`].")] #[doc = concat!("[`", $s_int_type, "`].")]
/// ///
/// # Considerations
///
/// This method is not magic; it is not provided by the hardware.
/// It is implemented in terms of
#[doc = concat!("[`", stringify!($atomic_type), "::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 /// # Examples
/// ///
/// ```rust /// ```rust