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