Testing some singleton implementations
Martin Nowak
code at dawg.eu
Sun Feb 9 10:06:46 PST 2014
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?
>
> static this () {
> get = {
> synchronized {
> if (instance_ is null)
> instance_ = new typeof(this)();
> get = { return instance_; };
> return instance_;
> }
> };
> }
>
> }
More information about the Digitalmars-d
mailing list