Re: How to initialize a globle variable nicely and properly?

2018-12-15 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 15 Dec 2018 13:49:03 +, Heromyth wrote: > Yes, it's very dangerous to create a new thread in shared static this(). > For a big project, it sometimes hard to identify this problem. Maybe, > the compiler should do something for this, should it? The runtime, more likely. There are plenty

Re: How to initialize a globle variable nicely and properly?

2018-12-15 Thread Heromyth via Digitalmars-d-learn
On Saturday, 15 December 2018 at 03:48:15 UTC, Neia Neutuladh wrote: On Sat, 15 Dec 2018 02:54:55 +, Heromyth wrote: shared static this() { writeln("running A in shared static this(), sharedField=", sharedField); Thread th = new Thread(() { }); th.start();

Re: How to initialize a globle variable nicely and properly?

2018-12-14 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 15 Dec 2018 02:54:55 +, Heromyth wrote: > shared static this() { > writeln("running A in shared static this(), > sharedField=", sharedField); > > Thread th = new Thread(() { }); > th.start(); When you start a D thread, thread-local static constructors

Re: How to initialize a globle variable nicely and properly?

2018-12-14 Thread Rubn via Digitalmars-d-learn
On Saturday, 15 December 2018 at 02:54:55 UTC, Heromyth wrote: We have a module including many globle variables which are needed to be initialized firstly in "shared static this() {}", see here https://github.com/huntlabs/hunt/blob/master/source/hunt/time/Init.d. The problem is that these var

How to initialize a globle variable nicely and properly?

2018-12-14 Thread Heromyth via Digitalmars-d-learn
We have a module including many globle variables which are needed to be initialized firstly in "shared static this() {}", see here https://github.com/huntlabs/hunt/blob/master/source/hunt/time/Init.d. The problem is that these variables are not always initialized firstly when are referenced by