Bug 20936 – core.sync.rwmutex should have shared overloads (and make it usable in @safe code)

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-06-16T09:49:36Z
Last change time
2021-09-28T10:28:00Z
Keywords
pull
Assigned to
No Owner
Creator
er.krali

Comments

Comment #0 by er.krali — 2020-06-16T09:49:36Z
In the same way core.sync.mutex has. Currently a ReadWriteMutex that is an internal member of a shared class / struct has to cast away shared to be usable. This leads to the following ugliness: ``` import core.sync.rwmutex; class C { public: shared this() { rwmutex = cast(shared) new ReadWriteMutex(); // This is bad, but... } shared int readData() { synchronized((cast ()rwmutex).reader) { // ... this is ugly as hell // Let's get some data here return 42; } } shared void setData(int data) { synchronized((cast ()rwmutex).writer) { // ditto // Store data here } } private: ReadWriteMutex rwmutex; } void main() { shared C c = new shared C(); } ``` It probably should get the same kind of `shared` overloads that the normal Mutex did. Also, it prevents it from being used in @safe code (although the class is not @safe at all, it probably could be with little effort).
Comment #1 by dlang-bot — 2021-08-24T12:36:34Z
@jpiles updated dlang/druntime pull request #3137 "Fix Issue 20936 - core.sync.rwmutex should have shared overloads (and make it usable in @safe code)" fixing this issue: - Fix Issue 20936 - core.sync.rwmutex should have shared overloads (and make it usable in @safe code) https://github.com/dlang/druntime/pull/3137
Comment #2 by dlang-bot — 2021-09-28T10:28:00Z
dlang/druntime pull request #3137 "Fix Issue 20936 - core.sync.rwmutex should have shared overloads (and make it usable in @safe code)" was merged into master: - 80f0360ce770e6e26d328c681b34d870bee38000 by Joan Piles: Fix Issue 20936 - core.sync.rwmutex should have shared overloads (and make it usable in @safe code) https://github.com/dlang/druntime/pull/3137