Boost logo

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

   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");
       log("passed barrier_one");
       static boost::barrier barrier_two(nThreads); // mutex needed for 'local
     static' ?
       log("waiting on barrier_two");
       log("passed barrier_two");

Boost list run by bdawes at, gregod at, cpdaniel at, john at