mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:57:59 +02:00
Avoid use of atomic copy ctor in RateCounter
This commit is contained in:
parent
1fe12e7029
commit
477d6f40e4
1 changed files with 3 additions and 1 deletions
|
@ -21,6 +21,8 @@
|
||||||
template <uint32_t INTERVAL = MSECS_PER_SECOND, uint8_t PRECISION = 2>
|
template <uint32_t INTERVAL = MSECS_PER_SECOND, uint8_t PRECISION = 2>
|
||||||
class RateCounter {
|
class RateCounter {
|
||||||
public:
|
public:
|
||||||
|
RateCounter() { _rate = 0; } // avoid use of std::atomic copy ctor
|
||||||
|
|
||||||
void increment(size_t count = 1) {
|
void increment(size_t count = 1) {
|
||||||
auto now = usecTimestampNow();
|
auto now = usecTimestampNow();
|
||||||
float currentIntervalMs = (now - _start) / (float) USECS_PER_MSEC;
|
float currentIntervalMs = (now - _start) / (float) USECS_PER_MSEC;
|
||||||
|
@ -43,8 +45,8 @@ public:
|
||||||
private:
|
private:
|
||||||
uint64_t _start { usecTimestampNow() };
|
uint64_t _start { usecTimestampNow() };
|
||||||
size_t _count { 0 };
|
size_t _count { 0 };
|
||||||
std::atomic<float> _rate { 0 };
|
|
||||||
const float _scale { powf(10, PRECISION) };
|
const float _scale { powf(10, PRECISION) };
|
||||||
|
std::atomic<float> _rate;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue