static MySingleton get() {
if (instance_ is null) {
synchronized {
if (instance_ is null) {
atomicStore(instance_, new MySingleton);
}
}
}
return instance_;
}
This should work fine and faster.
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*.
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
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 (
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