Example below:
The following error is thrown, which I am not sure I understand since it's part of the initialization/ctor code for the shared resource:
<source>(27): Error: direct access to shared `new shared(ReadWriteMutex)(Policy.PREFER_WRITERS)` is not allowed, see `core.atomic`
import core.sync.rwmutex : ReadWriteMutex;
// The below works:
//
// https://github.com/dlang/dmd/commit/63cb064d3f62317159f999477c9dc15a5ca7d632#diff-652a0df83aadb85a63bc618ed724c49f6b7d4ea45d679ace8c7c90ea9c032537
struct Child
{
this(int) shared {}
}
struct Parent
{
shared Child ch;
this(int i) shared
{
ch = shared Child(i);
}
}
// But this doesn't?
class DiskManager
{
shared ReadWriteMutex dbIOMutex;
this() shared
{
this.dbIOMutex = new shared ReadWriteMutex();
}
}