test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 <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;
73 };
74 
79 class QualityMetricSource final : public QualityMetric {
80 
82 
83 public:
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
std::unique_ptr< QualityMetricSource > newSource(timespec now)
#define nullptr
QualityMetric(timespec now, int default_value=260)
QualityMetricUniqueSource & m_parent
Definition: QualityMetric.h:89
void finishWatch(timespec now, int ms)
QualityMetricSource(QualityMetricUniqueSource &parent, timespec now, int default_value)
tbb::concurrent_unordered_map< std::string, QualityMetricUniqueSource * > MetricMap
Definition: QualityMetric.h:71
susybsm::MuonSegment ms
Definition: classes.h:31
void startWatch(QualityMetricWatch &)
void swap(QualityMetricWatch &)
static const unsigned interval_length
Definition: QualityMetric.h:47
static QualityMetricFactory m_instance
Definition: QualityMetric.h:69
edm::propagate_const< QualityMetric * > m_parent1
Definition: QualityMetric.h:33