15 #ifndef LIBSTATISTICS_COLLECTOR__MOVING_AVERAGE_STATISTICS__MOVING_AVERAGE_HPP_
16 #define LIBSTATISTICS_COLLECTOR__MOVING_AVERAGE_STATISTICS__MOVING_AVERAGE_HPP_
24 #include <type_traits>
28 #include "libstatistics_collector/visibility_control.hpp"
30 #include "rcpputils/thread_safety_annotations.hpp"
32 namespace libstatistics_collector
34 namespace moving_average_statistics
52 LIBSTATISTICS_COLLECTOR_PUBLIC
55 LIBSTATISTICS_COLLECTOR_PUBLIC
63 LIBSTATISTICS_COLLECTOR_PUBLIC
64 double Average()
const RCPPUTILS_TSA_REQUIRES(mutex_);
71 LIBSTATISTICS_COLLECTOR_PUBLIC
72 double Max()
const RCPPUTILS_TSA_REQUIRES(mutex_);
79 LIBSTATISTICS_COLLECTOR_PUBLIC
80 double Min()
const RCPPUTILS_TSA_REQUIRES(mutex_);
90 LIBSTATISTICS_COLLECTOR_PUBLIC
101 LIBSTATISTICS_COLLECTOR_PUBLIC
107 LIBSTATISTICS_COLLECTOR_PUBLIC
116 LIBSTATISTICS_COLLECTOR_PUBLIC
124 LIBSTATISTICS_COLLECTOR_PUBLIC
128 mutable std::mutex mutex_;
129 double average_ RCPPUTILS_TSA_GUARDED_BY(mutex_) = 0;
130 double min_ RCPPUTILS_TSA_GUARDED_BY(mutex_) = std::numeric_limits<double>::max();
131 double max_ RCPPUTILS_TSA_GUARDED_BY(mutex_) = std::numeric_limits<double>::min();
132 double sum_of_square_diff_from_mean_ RCPPUTILS_TSA_GUARDED_BY(mutex_) = 0;
133 uint64_t count_ RCPPUTILS_TSA_GUARDED_BY(mutex_) = 0;
139 #endif // LIBSTATISTICS_COLLECTOR__MOVING_AVERAGE_STATISTICS__MOVING_AVERAGE_HPP_