Skip to content

[doc] Atomic.add, .subtract: Add note on atomic codegen #78799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions stdlib/public/Synchronization/Atomics/AtomicIntegers.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ extension Atomic where Value == ${intType} {
/// overflow does occur. In `-Ounchecked` builds, overflow checking is not
/// performed.
///
/// The need to check for overflow means that this operation is typically
/// compiled into a compare-exchange loop. For use cases that require a
/// direct atomic addition, see the `wrappingAdd` operation: it avoids the
/// loop, but in exchange it allows silent wraps on overflow.
///
/// - Parameter operand: An integer value.
/// - Parameter ordering: The memory ordering to apply on this operation.
/// - Returns: A tuple containing the original value before the operation and
Expand Down Expand Up @@ -202,6 +207,11 @@ extension Atomic where Value == ${intType} {
/// overflow does occur. In `-Ounchecked` builds, overflow checking is not
/// performed.
///
/// The need to check for overflow means that this operation is typically
/// compiled into a compare-exchange loop. For use cases that require a
/// direct atomic subtraction, see the `wrappingSubtract` operation: it
/// avoids the loop, but in exchange it allows silent wraps on overflow.
///
/// - Parameter operand: An integer value.
/// - Parameter ordering: The memory ordering to apply on this operation.
/// - Returns: A tuple containing the original value before the operation and
Expand Down