SE-0512: Document that Mutex.withLockIfAvailable(_:) cannot spuriously fail

Yes, I think that's another way to put my point above: I don't see a need for withLockIfAvailable to synchronize (i.e. to establish transitive ordering) with other threads when it fails, and from discussion, it seems like it would it have a very real performance overhead that we'd prefer to avoid.

Maybe, when we finally get around to nailing down the memory model, we'd benefit from another comprehensive audit of platform implementations to see which ones actually try to treat all mutex operations as sequentially consistent. But I don't think we need that for this proposal.

2 Likes

Yes, fully agree that it's a bad idea for a failed withLockIfAvailable to synchronize.

This strictly depends on the implementation and whether it was statically linked + LTO-ed, so I think that the premise still holds.

1 Like

SE-0512 has been accepted. I'd like thank everyone who participated in this thread for their thoughtful contributions.

John McCall
Review Manager