I want to add a Phobos module with template mixins for common idioms.
Idan Arye
GenericNPC at gmail.com
Sun May 19 16:11:56 PDT 2013
On Sunday, 19 May 2013 at 20:35:06 UTC, Diggory wrote:
> It's also less efficient as you have to read both the
> thread-local boolean and the __gshared instance. Since the
> thread-local boolean is likely going to use a word anyway you
> may as well store the instance in there instead.
This is a good point. I've changed the local indicator to a local
reference.
I've also added the local check under `instance()`. Until now, I
relayed on `singleton_tryInitInstance()` to do that check, but I
figured out that it's better to do an extra local check on first
call(in each thread) than to do an extra method call for every
call afterward. Also, when that check is inside another method,
the optimization you suggested won't work(unless the compiler
decides to inline it)
More information about the Digitalmars-d
mailing list