-
Notifications
You must be signed in to change notification settings - Fork 124
Adopt Mutex
.
#1351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adopt Mutex
.
#1351
Conversation
f31a9b9
to
6e41940
Compare
This PR adopts `Mutex` on all platforms except Darwin (where we still need to back-deploy further than `Mutex` is available.) Resolves #538.
6e41940
to
39e2c37
Compare
lock.initialize(to: .init()) | ||
} | ||
#else | ||
nonisolated(unsafe) let rawValue = rawValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's necessary for us to write nonisolated(unsafe)
here and a few other places because T
isn't universally Sendable
. We have some types (pointers) that we need to guard with locks which are not sendable, and the compiler is concerned there may be data races. We know what we're doing (famous last words) but the compiler can't reason about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!! This is a huge simplification
This reverts commit 13319e1.
Reverts #1351, this is failing to build in CI (https://ci.swift.org/job/oss-swift-pr-test-ubuntu-22_04/9662/)
This PR adopts
Mutex
on all platforms except Darwin (where we still need to back-deploy further thanMutex
is available.)Resolves #538.
Checklist: