On Sun, 26 Oct 2014 22:53:07 +0000 Neven via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:
> Why cannot I globally have auto mutex = new Mutex? And why it > works now when I put __gshared? this is because 'auto mutex = new Mutex' is not a global declaration, it's thread-local declaration. all D variables are thread-locals by default. i.e. you have one indepented Mutex for each thread. and you initialized it only in one thread, all other threads got unitialized Mutex objects. 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.
signature.asc
Description: PGP signature