mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 04:03: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>
|
||||
class RateCounter {
|
||||
public:
|
||||
RateCounter() { _rate = 0; } // avoid use of std::atomic copy ctor
|
||||
|
||||
void increment(size_t count = 1) {
|
||||
auto now = usecTimestampNow();
|
||||
float currentIntervalMs = (now - _start) / (float) USECS_PER_MSEC;
|
||||
|
@ -43,8 +45,8 @@ public:
|
|||
private:
|
||||
uint64_t _start { usecTimestampNow() };
|
||||
size_t _count { 0 };
|
||||
std::atomic<float> _rate { 0 };
|
||||
const float _scale { powf(10, PRECISION) };
|
||||
std::atomic<float> _rate;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue