LinuxProcMgr.h
Go to the documentation of this file.
1 #ifndef art_Utilities_LinuxProcMgr_h
2 #define art_Utilities_LinuxProcMgr_h
3 
4 // ================================================================
5 // LinuxProcMgr
6 //
7 // Responsible for retrieving procfs information.
8 //
9 // A different implementation may be necessary to guarantee that we do
10 // not open too many file descriptors.
11 // ================================================================
12 
14 
15 #include <sys/types.h>
16 
17 #include <cstdio>
18 #include <string>
19 
20 namespace art {
21 
22  class LinuxProcMgr {
23  public:
24  LinuxProcMgr() noexcept(false);
25  ~LinuxProcMgr() noexcept;
26 
27  LinuxProcData::proc_tuple getCurrentData() const noexcept(false);
28  double
29  getVmPeak() const noexcept(false)
30  {
31  return getStatusData_("VmPeak");
32  }
33  double
34  getVmHWM() const noexcept(false)
35  {
36  return getStatusData_("VmHWM");
37  }
38 
39  LinuxProcMgr(LinuxProcMgr const&) = delete;
40  LinuxProcMgr(LinuxProcMgr&&) = delete;
41  LinuxProcMgr& operator=(LinuxProcMgr const&) = delete;
42  LinuxProcMgr& operator=(LinuxProcMgr&&) = delete;
43 
44  private:
45  double getStatusData_(std::string const& field) const noexcept(false);
46 
47  pid_t const pid_;
48  long const pgSize_;
49  FILE* const file_;
50  };
51 
52 } // namespace art
53 
54 #endif /* art_Utilities_LinuxProcMgr_h */
55 
56 // Local variables:
57 // mode:c++
58 // End:
double getVmHWM() const noexcept(false)
Definition: LinuxProcMgr.h:34
double getVmPeak() const noexcept(false)
Definition: LinuxProcMgr.h:29
std::string string
Definition: nybbler.cc:12
LinuxProcMgr() noexcept(false)
Definition: LinuxProcMgr.cc:59
LinuxProcData::proc_tuple getCurrentData() const noexcept(false)
Definition: LinuxProcMgr.cc:69
double getStatusData_(std::string const &field) const noexcept(false)
~LinuxProcMgr() noexcept
Definition: LinuxProcMgr.cc:65
LinuxProcMgr & operator=(LinuxProcMgr const &)=delete
pid_t const pid_
Definition: LinuxProcMgr.h:47
long const pgSize_
Definition: LinuxProcMgr.h:48
FILE *const file_
Definition: LinuxProcMgr.h:49
std::tuple< vsize_t, rss_t > proc_tuple
Definition: LinuxProcData.h:90