Testing some singleton implementations

luka8088 luka8088 at owave.net
Sun Feb 9 16:08:09 PST 2014


On 9.2.2014. 19:51, Stanislav Blinov wrote:
> On Sunday, 9 February 2014 at 18:06:46 UTC, Martin Nowak wrote:
>> On 02/09/2014 01:20 PM, luka8088 wrote:
>>> class FunctionPointerSingleton {
>>>
>>>   private static __gshared typeof(this) instance_;
>>>
>>>   // tls
>>>   @property static typeof(this) function () get;
>> You don't even need to make this TLS, right?
> 
> I don't follow. get should be TLS, as a replacement for SyncSingleton's
> _instantiated TLS bool.

It is tls and it needs to be tls because one thread could be replacing
where get points to while another is trying to access it. It's either
tls or putting some synchronization above it which would break the whole
idea of executing synchronized block only once per thread.



More information about the Digitalmars-d mailing list