Re: an extremely naive question regarding synchronized...

2016-11-16 Thread Kagamin via Digitalmars-d-learn
static MySingleton get() { if (instance_ is null) { synchronized { if (instance_ is null) { atomicStore(instance_, new MySingleton); } } } return instance_; } This should work fine and faster.

Re: an extremely naive question regarding synchronized...

2016-11-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/15/16 3:05 PM, Kapps wrote: Keep in mind, this is only slow for such a large amount of calls. If you're calling this only a hundred times a second, then who cares if it's slower. After all, with GDC we were looking at 1 billion calls in 21 seconds. That's 47,000 calls per *millisecond*.

Re: an extremely naive question regarding synchronized...

2016-11-15 Thread Kapps via Digitalmars-d-learn
On Monday, 14 November 2016 at 17:43:37 UTC, WhatMeWorry wrote: I was reading this fasciniating article: https://davesdprogramming.wordpress.com/2013/05/06/low-lock-singletons/ And to quote a section of it: - static MySingleton get() { sy

Re: an extremely naive question regarding synchronized...

2016-11-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/14/16 12:43 PM, WhatMeWorry wrote: I was reading this fasciniating article: https://davesdprogramming.wordpress.com/2013/05/06/low-lock-singletons/ And to quote a section of it: - static MySingleton get() { synchronized { if (

an extremely naive question regarding synchronized...

2016-11-14 Thread WhatMeWorry via Digitalmars-d-learn
I was reading this fasciniating article: https://davesdprogramming.wordpress.com/2013/05/06/low-lock-singletons/ And to quote a section of it: - static MySingleton get() { synchronized { if (instance_ is null) { instance_ = n