CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QualityMetric.h
Go to the documentation of this file.
1 #ifndef Utilities_XrdAdaptor_QualityMetric_h
2 #define Utilities_XrdAdaptor_QualityMetric_h
3 
4 #include <ctime>
5 
6 #include <mutex>
7 #include <memory>
8 
9 #include "oneapi/tbb/concurrent_unordered_map.h"
10 
13 
14 namespace XrdAdaptor {
15 
16  class QualityMetric;
17  class QualityMetricSource;
19 
21  friend class QualityMetricSource;
22 
23  public:
24  QualityMetricWatch() : m_parent1(nullptr), m_parent2(nullptr) {}
27 
28  QualityMetricWatch(const QualityMetricWatch &) = delete;
30 
31  void swap(QualityMetricWatch &);
32 
33  private:
35  timespec m_start;
38  };
39 
40  class QualityMetric {
41  friend class QualityMetricWatch;
42 
43  public:
44  QualityMetric(timespec now, int default_value = 260);
45  unsigned get();
46 
47  QualityMetric(const QualityMetric &) = delete;
48  QualityMetric &operator=(const QualityMetric &) = delete;
49 
50  private:
51  void finishWatch(timespec now, int ms);
52 
53  static const unsigned interval_length = 60;
54 
55  int m_value;
63 
65  };
66 
68  friend class Source;
69 
70  private:
71  static std::unique_ptr<QualityMetricSource> get(timespec now, const std::string &id);
72 
74 
75  typedef oneapi::tbb::concurrent_unordered_map<std::string, QualityMetricUniqueSource *> MetricMap;
77  };
78 
83  class QualityMetricSource final : public QualityMetric {
85 
86  public:
88 
89  private:
90  QualityMetricSource(QualityMetricUniqueSource &parent, timespec now, int default_value);
91 
93  };
94 
95  /*
96  * This quality metric tracks all accesses to a given source ID.
97  */
99  friend class QualityMetricFactory;
100 
101  private:
102  QualityMetricUniqueSource(timespec now);
103  std::unique_ptr<QualityMetricSource> newSource(timespec now);
104  };
105 
106 } // namespace XrdAdaptor
107 
108 #endif // Utilities_XrdAdaptor_QualityMetric_h
oneapi::tbb::concurrent_unordered_map< std::string, QualityMetricUniqueSource * > MetricMap
Definition: QualityMetric.h:75
uint16_t *__restrict__ id
static std::mutex mutex
Definition: Proxy.cc:8
std::unique_ptr< QualityMetricSource > newSource(timespec now)
QualityMetric(timespec now, int default_value=260)
edm::propagate_const< QualityMetric * > m_parent1
Definition: QualityMetric.h:36
QualityMetricUniqueSource & m_parent
Definition: QualityMetric.h:92
void finishWatch(timespec now, int ms)
QualityMetricSource(QualityMetricUniqueSource &parent, timespec now, int default_value)
#define CMS_THREAD_SAFE
QualityMetric & operator=(const QualityMetric &)=delete
void startWatch(QualityMetricWatch &)
QualityMetricWatch & operator=(const QualityMetricWatch &)=delete
void swap(QualityMetricWatch &)
edm::propagate_const< QualityMetric * > m_parent2
Definition: QualityMetric.h:37
static const unsigned interval_length
Definition: QualityMetric.h:53
static QualityMetricFactory m_instance
Definition: QualityMetric.h:73