Skip to content

Conversation

@grynspan
Copy link
Contributor

This PR adjusts the documentation for Mutex.withLockIfAvailable() to clarify that it is not subject to spurious failures. The C11 and C++11 specs for their respective tryLock() APIs allow for spurious failures, but our implementations and those of every other similar API I've found don't use weak cmpxchgs and don't spuriously fail.

I opened a forum thread here that discusses this change and went into way more detail than was practical explaining why I think we can make this guarantee. 🙂

This PR adjusts the documentation for `Mutex.withLockIfAvailable()` to clarify
that it is not subject to spurious failures. The C11 and C++11 specs for their
respective `tryLock()` APIs allow for spurious failures, but our implementations
and those of every other similar API I've found don't use weak `cmpxchg`s and
don't spuriously fail.
@grynspan grynspan self-assigned this Nov 13, 2025
@grynspan grynspan requested a review from a team as a code owner November 13, 2025 19:07
@grynspan grynspan added the Concurrencу Area → standard library: The `Concurrency` module under the standard library umbrella label Nov 13, 2025
@grynspan
Copy link
Contributor Author

@swift-ci test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Concurrencу Area → standard library: The `Concurrency` module under the standard library umbrella

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants