 
  
 
 Fill histogram in parallel with a multithreaded approach using TThreadedObject and TThreadedObject::SnapshotMerge. 
The difference with the multiprocessing case, see mp_parallelHistoFill, is that we cannot count on the copy-on-write mechanism here. Instead, we need to protect the histogram resource with a TThreadedObject class. The result of the filling is monitored with the SnapshotMerge method. This method is not thread safe: in the presence of ROOT histograms, the system will not crash but the result is not uniquely defined.
 
 
  
 
{
 
   
   
 
   
      
      
      
      
      
      
      for (
auto i : 
ROOT::TSeqI(1000000)) {
 
      }
   };
 
   
 
   std::vector<std::thread> 
pool;
 
   
   
   
   
         std::this_thread::sleep_for(std::chrono::duration<double, std::nano>(500));
         auto h = 
ts_h.SnapshotMerge();
 
         std::cout << 
"Entries for the snapshot " << 
h->GetEntries() << std::endl;
      }
   };
 
   
   }
 
   
      t.join();
 
   
 
   std::cout << 
"Entries for the total sum " << 
sumRandomHisto->GetEntries() << std::endl;
 
   return 0;
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
A wrapper to make object instances thread private, lazily.
Random number generator class based on M.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
void EnableThreadSafety()
Enable support for multi-threading within the ROOT code in particular, enables the global mutex to ma...
- Date
- January 2016 
- Author
- Danilo Piparo 
Definition in file mt_parallelHistoFill.C.