
27 Jan
2010
27 Jan
'10
7:11 p.m.
AMDG Andrew Chinkoff wrote:
Frank Mori Hess wrote:
You should use boost::once to initialize the singleton object.
Does boost::once ensure that called function will be performed atomically?
That is what I mean:
A* pa = NULL; void foo(){ pa = new A(); } boost::call_once(foo, flag);
Question: Is it true that "pa" will be allocated atomically?
When call_once returns it is guaranteed that foo has run to completion exactly once. If two thread run it in parallel one of them will block while the other runs foo. In Christ, Steven Watanabe