-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Tracking issue for reentrant mutexes #27738
Comments
I’m still a bit uncomfortable by the fact that we do not allow inner mutability in this particular Mutex. You’d usually won’t want to Mutex-guard immutable data because it is, well, immutable and in most cases is already MT-safe, and mutable ReentrantMutex ready to share and use looks a little bit odd/redundant: |
The idea of |
@nagisa |
This type isn't actually exposed from the standard library, I believe I just mistakenly read the |
Can we reopen this? We are going to need this in Servo for exactly the reason @Diggsey mentioned. Cc @asajeffrey. |
I ended up reimplementing the interface on top of regular mutexes https://github.com/servo/servo/blob/master/components/util/remutex.rs. The main use case is data structures that are reentrant but not thread-safe, and use interior mutability. In our case that was IPC channels, but you can do similar examples with cells. |
Note that this was never an exported interface of the standard library, so we'd probably require an RFC to add this feature to the standard library |
Given that reentrant mutexes can be implemented on top of stdlib's mutexes, should they be in std or a crate? One argument for putting them in std would be if there's an efficiency gain from using native reentrant mutexes. |
Given the stdlib's reentrant mutexes AFAIK aren't implemented on top of |
Well, it's been about 4.5 years, can we look at this again? |
This thread can be informative for historical context but it is marked as closed, let’s discuss in #58612. |
This is a tracking issue for the unstable
reentrant_mutex
feature in the standard library. Currently this flavor of mutex is not exposed at all in the standard library (it's private in thesys
module), but it's an often-useful form of a mutex.We should decide whether or not the standard library will expose this flavor of mutex and then ensure that the API is audited for conventions, naming, and performance.
cc @nagisa
The text was updated successfully, but these errors were encountered: