On Friday, 30 October 2015 at 21:29:22 UTC, BBasile wrote:
On Friday, 30 October 2015 at 20:58:37 UTC, anonymous wrote:
On 30.10.2015 21:23, TheFlyingFiddle wrote:
Is this intended to work?

struct A
{
    __gshared static this()
    {
       //Add some reflection info to some global stuff.
       addReflectionInfo!(typeof(this));
    }
}

I just noticed this works in 2.069, is this intended?

static constructors are supposed to work, yes.

The description is on the class page: http://dlang.org/class.html#static-constructor

__gshared doesn't do anything there, though. Use `shared static this` instead, if you want the constructor to run only once per process, and not once per thread.

__gshared is mostly usefull on fields (eg public uint a) because it prevents a data to be put on the TLS, which in certain case reduces the perfs up to 30%. The byte code using a global variable that's not __gshared can be incredibly slower !

Im' talking about DMD win32 BTW. Even if now I've switched to full time linux, I have a test on the hold HDD that demonstrates this :). That's really uncredible. Avoid TLS as possible on DMD with the switch "-vtls".

Reply via email to