<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Singletons In D</title>
	<atom:link href="http://dblog.aldacron.net/2007/03/03/singletons-in-d/feed/" rel="self" type="application/rss+xml" />
	<link>http://dblog.aldacron.net/2007/03/03/singletons-in-d/</link>
	<description>News and Opinions Regarding the D Programming Language</description>
	<lastBuildDate>Fri, 20 Jan 2012 13:36:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Aldacron</title>
		<link>http://dblog.aldacron.net/2007/03/03/singletons-in-d/comment-page-1/#comment-4498</link>
		<dc:creator>Aldacron</dc:creator>
		<pubDate>Sat, 07 Jul 2007 08:34:47 +0000</pubDate>
		<guid isPermaLink="false">http://dblog.aldacron.net/2007/03/03/singletons-in-d/#comment-4498</guid>
		<description>@Matthias:

&lt;i&gt;The Problem i found with the Template versions is, that you can t add the Singleton Template from another Module. So you have to have the Singleton Template in every Module you want to have a SingletonClass (I think) :)&lt;/i&gt;

That shouldn&#039;t be happening. I&#039;ve not been able to reproduce it myself. As long as you import the module that declares the singleton instance, you should be able to use it anywhere. It might break on Windows when compiled into a static library (a known template problem on that platform) but other than that it should work fine.

@Stephane:

&lt;i&gt;can I have the same problem with a multithreaded environment ? about the Double-Checked Locking ?&lt;/i&gt;

The version that uses a static constructor should be thread-safe, as far as accessing the singleton instance is concerned. No need for any locking or other synchronization measures.</description>
		<content:encoded><![CDATA[<p>@Matthias:</p>
<p><i>The Problem i found with the Template versions is, that you can t add the Singleton Template from another Module. So you have to have the Singleton Template in every Module you want to have a SingletonClass (I think) <img src='http://dblog.aldacron.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </i></p>
<p>That shouldn&#8217;t be happening. I&#8217;ve not been able to reproduce it myself. As long as you import the module that declares the singleton instance, you should be able to use it anywhere. It might break on Windows when compiled into a static library (a known template problem on that platform) but other than that it should work fine.</p>
<p>@Stephane:</p>
<p><i>can I have the same problem with a multithreaded environment ? about the Double-Checked Locking ?</i></p>
<p>The version that uses a static constructor should be thread-safe, as far as accessing the singleton instance is concerned. No need for any locking or other synchronization measures.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephane Wirtel</title>
		<link>http://dblog.aldacron.net/2007/03/03/singletons-in-d/comment-page-1/#comment-4497</link>
		<dc:creator>Stephane Wirtel</dc:creator>
		<pubDate>Sat, 07 Jul 2007 07:11:07 +0000</pubDate>
		<guid isPermaLink="false">http://dblog.aldacron.net/2007/03/03/singletons-in-d/#comment-4497</guid>
		<description>Hi all, 

Thanks for this tutorial about the Singleton pattern, but can I have the same problem with a multithreaded environment ? about the Double-Checked Locking ?

bye</description>
		<content:encoded><![CDATA[<p>Hi all, </p>
<p>Thanks for this tutorial about the Singleton pattern, but can I have the same problem with a multithreaded environment ? about the Double-Checked Locking ?</p>
<p>bye</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthias Thurau</title>
		<link>http://dblog.aldacron.net/2007/03/03/singletons-in-d/comment-page-1/#comment-4395</link>
		<dc:creator>Matthias Thurau</dc:creator>
		<pubDate>Sat, 30 Jun 2007 17:08:06 +0000</pubDate>
		<guid isPermaLink="false">http://dblog.aldacron.net/2007/03/03/singletons-in-d/#comment-4395</guid>
		<description>Hi, nice Tutorials. The Problem i found with the Template versions is, that you can t add the Singleton Template from another Module. So you have to have the Singleton Template in every Module you want to have a SingletonClass (I think) :)

I made something with Mixins today:
template Singleton() {
public:
    static typeof(this) getInstance() {
        if (_instance is null)  _instance   =   new typeof(this)();
        return _instance;
    };
private:
    this() { writefln(&quot;Singleton Constructor&quot;); };
    static typeof(this) _instance;
};




class ResourceLoader {
    mixin Singleton!();

    int some_more_stuff;

private:
    this() { writefln(&quot;ResourceLoader Constructor&quot;); };
}

bye</description>
		<content:encoded><![CDATA[<p>Hi, nice Tutorials. The Problem i found with the Template versions is, that you can t add the Singleton Template from another Module. So you have to have the Singleton Template in every Module you want to have a SingletonClass (I think) <img src='http://dblog.aldacron.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I made something with Mixins today:<br />
template Singleton() {<br />
public:<br />
    static typeof(this) getInstance() {<br />
        if (_instance is null)  _instance   =   new typeof(this)();<br />
        return _instance;<br />
    };<br />
private:<br />
    this() { writefln(&#8220;Singleton Constructor&#8221;); };<br />
    static typeof(this) _instance;<br />
};</p>
<p>class ResourceLoader {<br />
    mixin Singleton!();</p>
<p>    int some_more_stuff;</p>
<p>private:<br />
    this() { writefln(&#8220;ResourceLoader Constructor&#8221;); };<br />
}</p>
<p>bye</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The One With D &#187; Blog Archive &#187; DLang Group</title>
		<link>http://dblog.aldacron.net/2007/03/03/singletons-in-d/comment-page-1/#comment-2620</link>
		<dc:creator>The One With D &#187; Blog Archive &#187; DLang Group</dc:creator>
		<pubDate>Wed, 14 Mar 2007 11:58:14 +0000</pubDate>
		<guid isPermaLink="false">http://dblog.aldacron.net/2007/03/03/singletons-in-d/#comment-2620</guid>
		<description>[...] I should also mention ideage, from the same domain, which looks to be a blog about D. Again, it&#8217;s all in Japanese. Lots of good stuff to look at there, though, even if you don&#8217;t understand it all. Such as the code from a post on D Singletons, which covers a great more bases than what I posted recently. [...]</description>
		<content:encoded><![CDATA[<p>[...] I should also mention ideage, from the same domain, which looks to be a blog about D. Again, it&#8217;s all in Japanese. Lots of good stuff to look at there, though, even if you don&#8217;t understand it all. Such as the code from a post on D Singletons, which covers a great more bases than what I posted recently. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henning Hasemann</title>
		<link>http://dblog.aldacron.net/2007/03/03/singletons-in-d/comment-page-1/#comment-2603</link>
		<dc:creator>Henning Hasemann</dc:creator>
		<pubDate>Fri, 09 Mar 2007 16:01:37 +0000</pubDate>
		<guid isPermaLink="false">http://dblog.aldacron.net/2007/03/03/singletons-in-d/#comment-2603</guid>
		<description>Thanks :-)</description>
		<content:encoded><![CDATA[<p>Thanks <img src='http://dblog.aldacron.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

