Open ktoso opened 3 months ago
I agree. If using new new Mutex
most types don't even have to use @unchecked Sendable
since Mutex
is unconditionally Sendable
. @unchecked Sendable
is required with atomics though.
I think this would be excellent content, and might have a nice home in some kind of "Design Guidelines" article. That's come up many times.
And we can mention I think we mention OSAllocatedUnfairLock as well
We have developed some patterns to limit the "just sprinkle @unchecked Sendable on it" on codebases.
We should showcase some of our recent locks:
Maybe we should take the chance to show good lock patterns here.
Like for example https://github.com/apple/swift-nio/blob/main/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift which is just:
Or also the new
Mutex
type -- we can ask https://github.com/swiftlang/swift-evolution/blob/main/proposals/0433-mutex.md @Azoy to provide a small snippet