Public Member Functions | Private Attributes | List of all members
cet::SimultaneousFunctionSpawner Class Reference

#include <SimultaneousFunctionSpawner.h>

Public Member Functions

template<typename FunctionToSpawn >
 SimultaneousFunctionSpawner (std::vector< FunctionToSpawn > const &fs)
 

Private Attributes

std::atomic< std::size_t > counter_
 

Detailed Description

Definition at line 47 of file SimultaneousFunctionSpawner.h.

Constructor & Destructor Documentation

template<typename FunctionToSpawn >
cet::SimultaneousFunctionSpawner::SimultaneousFunctionSpawner ( std::vector< FunctionToSpawn > const &  fs)
inline

Definition at line 50 of file SimultaneousFunctionSpawner.h.

51  : counter_{fs.size()}
52  {
53  auto execute = [this](auto f) {
54  --counter_;
55  while (counter_ != 0)
56  ;
57  f();
58  };
59 
60  std::vector<std::thread> threads;
61  for (auto f : fs) {
62  threads.emplace_back(execute, f);
63  }
64 
65  for (auto& thread : threads)
66  thread.join();
67  }

Member Data Documentation

std::atomic<std::size_t> cet::SimultaneousFunctionSpawner::counter_
private

Definition at line 70 of file SimultaneousFunctionSpawner.h.


The documentation for this class was generated from the following file: