CMS 3D CMS Logo

CallNTimesNoWait.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_CallNTimesNoWait_h
2 #define FWCore_Utilities_CallNTimesNoWait_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Utilities
6 // Class : CallNTimesNoWait
7 //
26 //
27 // Original Author: Chris Jones
28 // Created: Fri, 15 Nov 2013 14:29:41 GMT
29 //
30 
31 // system include files
32 #include <atomic>
33 
34 // user include files
35 
36 // forward declarations
37 namespace edm {
39  public:
40  CallNTimesNoWait(unsigned short iNTimes) : m_ntimes(static_cast<int>(iNTimes) - 1), m_done(false) {}
41 
42  template <typename T>
43  void operator()(T iCall) {
44  if (not m_done.load(std::memory_order_acquire)) {
45  if (m_ntimes.fetch_sub(1, std::memory_order_acq_rel) < 0) {
46  m_done.store(true, std::memory_order_release);
47  return;
48  };
49  iCall();
50  }
51  }
52 
53  private:
54  std::atomic<int> m_ntimes;
55  std::atomic<bool> m_done;
56  };
57 } // namespace edm
58 
59 #endif
funct::false
false
Definition: Factorize.h:34
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::CallNTimesNoWait
Definition: CallNTimesNoWait.h:38
edm::CallNTimesNoWait::CallNTimesNoWait
CallNTimesNoWait(unsigned short iNTimes)
Definition: CallNTimesNoWait.h:40
edm::CallNTimesNoWait::operator()
void operator()(T iCall)
Definition: CallNTimesNoWait.h:43
edm::CallNTimesNoWait::m_ntimes
std::atomic< int > m_ntimes
Definition: CallNTimesNoWait.h:54
createfilelist.int
int
Definition: createfilelist.py:10
edm::CallNTimesNoWait::m_done
std::atomic< bool > m_done
Definition: CallNTimesNoWait.h:55
T
long double T
Definition: Basic3DVectorLD.h:48