`shared Mutex`?
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Dec 28 12:35:57 PST 2014
On Sun, 28 Dec 2014 20:21:45 +0000
Aiden via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> wrote:
> 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!
you can turn that method to template. for now it is virtual method and
compiler is unable to inline it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141228/a10d0d2f/attachment.sig>
More information about the Digitalmars-d-learn
mailing list