On 09/08/12 16:45, Stefan Sayer wrote:
Hi,
o Szokovacs Robert on 08/08/2012 05:35 PM:
Hi,
While reading singleton.h, I noticed that instance() copies the
pointer before returning it.
I could not prove to myself that
static singleton<T>* instance()
{
_inst_m.lock();
if(!_instance) {
_instance = new singleton<T>();
}
_inst_m.unlock();
return _instance;
}
is wrong. What do I miss?
it's the same, especially as the instance is created only once, so
whether the function result is assigned inside or outside the
mutex-protected block does not matter.
So, why not save the extra assignment then?
br
Szo
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev