shared attrribute

Jack Applegame japplegame at gmail.com
Thu Mar 14 03:39:10 PDT 2013


What does mean attribute shared exactly for non global variables? 
Is it safe to cast to/from shared?

For example, let us assume all data are synchronized properly. Is 
following code safe?

import core.atomic;

class A {
   int value;
}

struct B {
   A node;
}

void main() {
   shared B data;
   A node = new A;
   atomicStore(data, shared B(cast(shared) node));
   ...
   node = atomicLoad(data).node;
}



More information about the Digitalmars-d-learn mailing list