|
Boost : |
Subject: [boost] static boost::barrier - do I need a mutex here ?
From: Vokuba (ka5427-536_at_[hidden])
Date: 2010-12-13 15:30:27
Hi,
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. But even with 16 running threads in parallel everything seems to be
fine (it's a machine with 8 hardware cores, no HT).
Thanks in advance - Hans
int nThreads; // initialized later in main()
void testing() {
static boost::barrier barrier_one(nThreads); // mutex needed for 'local
static' ?
log("waiting on barrier_one");
barrier_one.wait();
do_complicated_stuff_simulaneously();
log("passed barrier_one");
static boost::barrier barrier_two(nThreads); // mutex needed for 'local
static' ?
log("waiting on barrier_two");
barrier_two.wait();
do_more_complicated_stuff_simulaneously();
log("passed barrier_two");
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk