Boost logo

Boost :

Subject: Re: [boost] [Boost.utility]
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-01-27 14:11:30


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk