`shared Mutex`?

Aiden via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 28 12:21:45 PST 2014


Thanks for the information. At least I've discovered a reasonably 
tidy way of wrapping Mutex up so that it's not quite as painful 
casting everything:

shared class SharedMutex {
   private Mutex mutex;

   private @property Mutex unsharedMutex() {
     return cast(Mutex)mutex;
   }

   this() {
     mutex = cast(shared)new Mutex();
   }

   alias unsharedMutex this;
}

SharedMutex can just be used like a normal Mutex, which is pretty 
neat. `alias this` is awesome!


More information about the Digitalmars-d-learn mailing list