CMS 3D CMS Logo

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 "tbb/concurrent_unordered_map.h"
10 #include <boost/utility.hpp>
11 
14 
15 namespace XrdAdaptor {
16 
17 class QualityMetric;
20 
21 class QualityMetricWatch : boost::noncopyable {
22 friend class QualityMetricSource;
23 
24 public:
28 
29  void swap(QualityMetricWatch &);
30 
31 private:
33  timespec m_start;
36 };
37 
38 class QualityMetric : boost::noncopyable {
39 friend class QualityMetricWatch;
40 
41 public:
42  QualityMetric(timespec now, int default_value=260);
43  unsigned get();
44 
45 private:
46  void finishWatch(timespec now, int ms);
47 
48  static const unsigned interval_length = 60;
49 
50  int m_value;
58 
60 };
61 
63 
64 friend class Source;
65 
66 private:
67  static
68  std::unique_ptr<QualityMetricSource> get(timespec now, const std::string &id);
69 
71 
72  typedef tbb::concurrent_unordered_map<std::string, QualityMetricUniqueSource*> MetricMap;
73  MetricMap m_sources;
74 };
75 
80 class QualityMetricSource final : public QualityMetric {
81 
83 
84 public:
85  void startWatch(QualityMetricWatch &);
86 
87 private:
88  QualityMetricSource(QualityMetricUniqueSource &parent, timespec now, int default_value);
89 
91 };
92 
93 /*
94  * This quality metric tracks all accesses to a given source ID.
95  */
97 
98 friend class QualityMetricFactory;
99 
100 private:
101  QualityMetricUniqueSource(timespec now);
102  std::unique_ptr<QualityMetricSource> newSource(timespec now);
103 };
104 
105 }
106 
107 #endif // Utilities_XrdAdaptor_QualityMetric_h
108 
static boost::mutex mutex
Definition: Proxy.cc:11
edm::propagate_const< QualityMetric * > m_parent2
Definition: QualityMetric.h:35
#define nullptr
QualityMetricUniqueSource & m_parent
Definition: QualityMetric.h:90
#define CMS_THREAD_SAFE
tbb::concurrent_unordered_map< std::string, QualityMetricUniqueSource * > MetricMap
Definition: QualityMetric.h:72
susybsm::MuonSegment ms
Definition: classes.h:31
void swap(QualityMetricWatch &)
static QualityMetricFactory m_instance
Definition: QualityMetric.h:70
edm::propagate_const< QualityMetric * > m_parent1
Definition: QualityMetric.h:34