Slightly simplistic, but definitiely correct, method
for ensuring singleton creation is threadsafe. Can
be optimised if lock contention is ever an issue.
{
// Force initialization of cerr.
static std::ios_base::Init initializer;
+
+ // http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf
+ // in the absence of portable memory barrier ops in Simgear,
+ // let's keep this correct & safe
+ static SGMutex m;
+ SGGuard<SGMutex> g(m);
+
if( !global_logstream )
global_logstream = new logstream();
return *global_logstream;