<div dir="ltr">This could be useful, it allow to easily implement safe static initialization and is a generalization of what has been done in VTK. See <a href="https://github.com/commontk/CTK/blob/master/Libs/Core/ctkSingleton.h">https://github.com/commontk/CTK/blob/master/Libs/Core/ctkSingleton.h</a><div>

<br></div><div style>The idea would be to add a "vtkSingleton.h" class to VTK  ... </div><div style><br></div><div style>Hth</div><div style>Jc</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">

On Mon, Aug 26, 2013 at 1:36 PM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div><div>C++ makes my head spin (and hurt!).<br><br></div>Thanks Brad<br><br></div>Not for the hurting head, but for the solution...<br></div><div class="gmail_extra"><div class="im"><br><br><div class="gmail_quote">

On Mon, Aug 26, 2013 at 1:29 PM, Brad King <span dir="ltr"><<a href="mailto:brad.king@kitware.com" target="_blank">brad.king@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 08/26/2013 12:05 PM, Berk Geveci wrote:<br>
> Can you try this?<br>
<br>
</div>From the patch:<br>
<br>
+  if (!vtkTimeStamp::GlobalTimeStamp)<br>
+    {<br>
+#if VTK_SIZEOF_VOID_P == 8<br>
+    vtkTimeStamp::GlobalTimeStamp = new vtkAtomicInt64;<br>
<br>
This runtime initialization is not thread-safe, which IIUC<br>
is the entire point of using an atomic integer.  We can<br>
achieve proper static initialization and finalization using<br>
the same Schwarz Counter idiom:<br>
<br>
 <a href="http://en.wikibooks.org/wiki/More_C++_Idioms/Nifty_Counter" target="_blank">http://en.wikibooks.org/wiki/More_C++_Idioms/Nifty_Counter</a><br>
<br>
that we already use in several places.  It provides a way<br>
to order things across translation units.<br>
<span><font color="#888888"><br>
-Brad<br>
</font></span></blockquote></div><br><br clear="all"><br></div><div class="im">-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>+1 919 869 8849<br>
</div>