ROSE  0.11.131.0
WorkerStatus.h
1 #ifndef ROSE_BinaryAnalysis_ModelChecker_WorkerStatus_H
2 #define ROSE_BinaryAnalysis_ModelChecker_WorkerStatus_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_MODEL_CHECKER
5 
6 #include <Rose/BinaryAnalysis/ModelChecker/Types.h>
7 
8 #include <Rose/Progress.h>
9 #include <boost/filesystem.hpp>
10 
11 namespace Rose {
12 namespace BinaryAnalysis {
13 namespace ModelChecker {
14 
16 class WorkerStatus {
17 public:
19  using Ptr = WorkerStatusPtr;
20 
21 private:
22  boost::filesystem::path fileName_;
23  int fd_ = -1;
24 
25  struct Status {
26  WorkerState state = WorkerState::STARTING; // current state
27  time_t stateChange = 0; // time of last state change
28  Progress::Ptr progress; // progress reports
29  };
30 
31  std::vector<Status> workers_;
32  time_t lastFileUpdate_ = 0; // last time that file was updated
33 
34  static constexpr time_t fileUpdatePeriod_ = 1; // update the file every so many seconds
35  static constexpr size_t workersPerLine_ = 4; // number of worker information per line
36  static constexpr size_t barWidth_ = 20; // width of the bar that says how long since a state change
37 
38 protected:
39  WorkerStatus(const boost::filesystem::path &fileName);
40 
41 public:
42  ~WorkerStatus();
43 
44 public:
46  static Ptr instance(const boost::filesystem::path &fileName);
47 
51  void insert(size_t workerIdx, const Progress::Ptr&);
52 
54  void setState(size_t workerIdx, WorkerState);
55 
57  const boost::filesystem::path& fileName() const;
58 
60  void updateFile();
61 
63  void updateFileNow();
64 };
65 
66 } // namespace
67 } // namespace
68 } // namespace
69 
70 #endif
71 #endif
Main namespace for the ROSE library.
const char * WorkerState(int64_t)
Convert Rose::BinaryAnalysis::ModelChecker::WorkerState enum constant to a string.
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
ProgressPtr Ptr
Progress objects are reference counted.
Definition: Progress.h:169