Is this a good singleton?
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Feb 13 11:32:33 PST 2016
On 02/13/2016 10:58 AM, Vladde Nordholm wrote:
> Hello. I have this singleton,
>
> ------------------------------------------------------
> class Singleton
> {
> private this() {}
> static __gshared typeof(this) instance = new this;
> }
> ------------------------------------------------------
>
> and I wonder if it has any weaknesses. Or is there a better way to make
> a Singleton?
>
> ,vladde,
David Simcha's DConf 2013 presentation has a singleton implementation at
27:55:
https://www.youtube.com/watch?v=yMNMV9JlkcQ
Ali
More information about the Digitalmars-d-learn
mailing list