Problems with Mutex
Neven via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Oct 26 16:37:25 PDT 2014
@Damian
> You can use auto mutex = cast(shared)(new Mutex());
Not working; Error: constructor core.sync.mutex.Mutex.this
core.sync.mutex.Mutex cannot be constructed at compile time,
because the constructor has no available source code
>Mutex mutex;
>static this()
>{
> mutex = new Mutex();
>}
I have synchronization problems with this one. Even when I
prepend __gshared Mutex mutex in this case.
Changed code: http://pastebin.com/KmxCemn3
Output: http://pastebin.com/zFFLnCTD
As you can see beginning is not what I expect to get.
@ketmar
> having thread-locals instead of globals by default can be
> confusing if
you missed that in documentation. just use 'shared' or
'__gshared' to
get "real" globals.
Thank you for clearing this up. If I understand correctly,
__gshared is more of a hack to get C-like global variables,
whilst shared is typed shared variable and more preferred?
More information about the Digitalmars-d-learn
mailing list