Skip to content

Conversation

@lorentey
Copy link
Member

Add this note to the doc string of Atomic.add and Atomic.subtract, highlighting a subtle aspect that tends to surprise folks who're porting code from C/C++:

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.

@lorentey lorentey requested a review from Azoy January 22, 2025 00:02
@lorentey lorentey requested a review from a team as a code owner January 22, 2025 00:02
@lorentey
Copy link
Member Author

@swift-ci test

@lorentey
Copy link
Member Author

@swift-ci smoke test linux platform

@lorentey lorentey marked this pull request as draft January 23, 2025 17:49
@lorentey lorentey marked this pull request as ready for review February 1, 2025 02:15
@lorentey
Copy link
Member Author

lorentey commented Feb 1, 2025

@swift-ci smoke test

@lorentey
Copy link
Member Author

@swift-ci test linux platform

@lorentey
Copy link
Member Author

@swift-ci test linux platform

@lorentey lorentey merged commit 02adf95 into swiftlang:main May 17, 2025
5 checks passed
@lorentey lorentey deleted the note-cas-loops branch May 17, 2025 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants