|
From: | Edward Rosten |
Subject: | Re: [libcvd-members] gvars3 Makefile.in configure configure.ac gvars... |
Date: | Wed, 20 Feb 2008 16:13:12 -0700 (MST) |
On Wed, 20 Feb 2008, Georg Klein wrote:
foo& foo::getinstance() { static foo f; return f; }but the page where I read about this said something along the lines of ``use only when single-threaded.'' Why might that be?
Race conditions on instantiation? eg in: if(!inst) inst = new fooclass(); return inst the first two lines aren't atomic.If it's being used for global constructors, then you don't have to worry about threads unless you do something really awesome like pthread_create in a global constructer so you get threads before main starts...
-Ed
[Prev in Thread] | Current Thread | [Next in Thread] |