Boost logo

Boost :

Subject: Re: [boost] static boost::barrier - do I need a mutex here ?
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2010-12-14 06:58:45


Vokuba wrote:
> Just a short question: Do you think I need a mutex for the 'static
> boost::barrier(nThreads)' lines in the sample code snippet below ?
> I always thought that static data in a function has to be protected by a
> mutex.

For some years gcc has been protecting function-scope statics with a
mutex by default. You can change this with -fno-threadsafe-statics.
I'm unsure what other compilers do and what the standards require
(though I did know at one time!).

Regards, Phil.


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