swift icon indicating copy to clipboard operation
swift copied to clipboard

Adjust the docs for `Mutex.withLockIfAvailable()` re: spurious failures.

Open grynspan opened this issue 4 months ago • 2 comments

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. 🙂

grynspan avatar Nov 13 '25 19:11 grynspan

@swift-ci test

grynspan avatar Nov 13 '25 19:11 grynspan

Holding for a check-in with the LSG.

grynspan avatar Jan 15 '26 18:01 grynspan