Proposal to make "shared" (more) useful

Kagamin spam at here.lot
Fri Sep 14 07:32:42 UTC 2018


struct Unshared(T)
{
     private T value;
     this(T v) shared { opAssign(v); }
     T get() shared { return *cast(T*)&value; }
     alias get this;
     void opAssign(T v) shared { *cast(T*)&value=v; }
}

shared synchronized class A
{
     private Unshared!(int[]) a;
     private Unshared!SysTime t;
     this(){ t=Clock.currTime; }
     int[] f()
     {
         return a;
     }
}


More information about the Digitalmars-d mailing list