Can't create "shared" Mutex with "-preview=nosharedaccess"
Simen Kjærås
simen.kjaras at gmail.com
Mon Aug 29 12:04:12 UTC 2022
On Sunday, 28 August 2022 at 21:15:59 UTC, Gavin Ray wrote:
> ```
> class DiskManager
> {
> shared ReadWriteMutex dbIOMutex;
>
> this() shared
> {
> this.dbIOMutex = new shared ReadWriteMutex();
> }
> }
> ```
The solution for now is to cast away shared on the LHS (and not
use shared on the rhs):
```
this() shared
{
cast()this.dbIOMutex = new ReadWriteMutex();
}
```
However, the Child/Parent structs in your code, and
https://issues.dlang.org/show_bug.cgi?id=21793 seem to indicate
that the cast should not be necessary. I would guess it's a
detail about how classes are reference types that messes things
up.
--
Simen
More information about the Digitalmars-d
mailing list