Low-Lock Singletons In D
Mehrdad
wfunction at hotmail.com
Mon May 6 03:01:33 PDT 2013
On Monday, 6 May 2013 at 09:30:24 UTC, Sergei Nosov wrote:
> On Monday, 6 May 2013 at 09:11:00 UTC, Mehrdad wrote:
>> On Monday, 6 May 2013 at 09:06:55 UTC, Mehrdad wrote:
>>> lock (this)
>>> {
>>> _static = new ActualValue<T>();
>>> }
>>
>> Oops I forgot the null check inside, don't forget that.
>
> All that double-checking stuff is trying to avoid calling
> "lock" for entire Get function body. Your solution does exactly
> that. So it's no good.
There are _two_ Get() functions. Only one of them calls lock();
once the field is initialized, that Get() is no longer called,
and the other one is called instead.
Unless I'm missing something?
More information about the Digitalmars-d
mailing list