CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
WorkerMonitorThread.h
Go to the documentation of this file.
1 #ifndef FWCore_SharedMemory_WorkerMonitorThread_h
2 #define FWCore_SharedMemory_WorkerMonitorThread_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/SharedMemory
6 // Class : WorkerMonitorThread
7 //
15 //
16 // Original Author: Chris Jones
17 // Created: 21/01/2020
18 //
19 
20 // system include files
21 #include <atomic>
22 #include <csignal>
23 #include <functional>
24 #include <thread>
25 
26 // user include files
28 
29 // forward declarations
30 
31 namespace edm::shared_memory {
33  public:
36  if (not stopRequested_.load()) {
37  stop();
38  }
39  }
41  const WorkerMonitorThread& operator=(const WorkerMonitorThread&) = delete;
44 
45  // ---------- const member functions ---------------------
46 
47  // ---------- member functions ---------------------------
48  void setAction(std::function<void()> iFunc) {
49  action_ = std::move(iFunc);
50  actionSet_.store(true);
51  }
52 
53  void startThread();
54 
56  void setupSignalHandling();
57 
58  void stop();
59 
60  private:
61  static void sig_handler(int sig, siginfo_t*, void*);
62  void run();
63  // ---------- member data --------------------------------
64  std::atomic<bool> stopRequested_ = false;
65  std::atomic<bool> helperReady_ = false;
66  std::atomic<bool> actionSet_ = false;
68 
69  static std::atomic<int> s_pipeReadEnd;
70  static std::atomic<int> s_pipeWriteEnd;
71  static std::atomic<bool> s_helperThreadDone;
72 
73  std::thread helperThread_;
74  };
75 } // namespace edm::shared_memory
76 
77 #endif
static std::atomic< bool > s_helperThreadDone
void setupSignalHandling()
Sets the unix signal handler which communicates with the thread.
void setAction(std::function< void()> iFunc)
static void sig_handler(int sig, siginfo_t *, void *)
string function
Definition: callgraph.py:50
def move
Definition: eostools.py:511
#define CMS_THREAD_GUARD(_var_)
const WorkerMonitorThread & operator=(const WorkerMonitorThread &)=delete