CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CallOnceNoWait.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_CallOnceNoWait_h
2 #define FWCore_Utilities_CallOnceNoWait_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Utilities
6 // Class : CallOnceNoWait
7 //
27 //
28 // Original Author: Chris Jones
29 // Created: Fri, 15 Nov 2013 14:29:51 GMT
30 //
31 
32 // system include files
33 #include <atomic>
34 
35 // user include files
36 
37 // forward declarations
38 
39 namespace edm {
41  {
42  public:
44 
45  template <typename T>
46  void operator()(T iCall) {
47  bool expected = false;
48  if(m_called.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
49  iCall();
50  }
51  }
52 
53  private:
54  std::atomic<bool> m_called;
55  };
56 }
57 
58 
59 #endif
std::atomic< bool > m_called
void operator()(T iCall)
volatile std::atomic< bool > shutdown_flag false
long double T