diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2020-12-03 19:01:04 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2020-12-03 19:01:04 +0100 |
commit | 54e2f0d40cad9ee1d442963e4dc765796fbac96b (patch) | |
tree | 5441d96c0c4d34256bdee50c2ae5c122a4914f90 | |
parent | fd7e517902ef54db9c60c8bad2b9d091130402ba (diff) |
Don't increment or decrement volatile variables. It is deprecated
when using C++20.
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp | 4 | ||||
-rw-r--r-- | vespalib/src/tests/array/array_test.cpp | 8 | ||||
-rw-r--r-- | vespalib/src/tests/stllike/hash_test.cpp | 8 |
3 files changed, 10 insertions, 10 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp index 37ab0054851..ba5466700c8 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp @@ -25,14 +25,14 @@ QueryLimiter::grabToken(const Doom & doom) _cond.wait_for(guard, left); } } - _activeThreads++; + _activeThreads = _activeThreads + 1; } void QueryLimiter::releaseToken() { std::lock_guard<std::mutex> guard(_lock); - _activeThreads--; + _activeThreads = _activeThreads - 1; _cond.notify_one(); } diff --git a/vespalib/src/tests/array/array_test.cpp b/vespalib/src/tests/array/array_test.cpp index c0189ad8ad6..ee8263183ca 100644 --- a/vespalib/src/tests/array/array_test.cpp +++ b/vespalib/src/tests/array/array_test.cpp @@ -27,16 +27,16 @@ std::ostream & operator << (std::ostream & os, const Array<T> & a) class Clever { public: - Clever() : _counter(&_global) { (*_counter)++; } + Clever() : _counter(&_global) { *_counter = *_counter + 1; } Clever(volatile size_t * counter) : _counter(counter) { - (*_counter)++; + *_counter = *_counter + 1; } Clever(const Clever & rhs) : _counter(rhs._counter) { - (*_counter)++; + *_counter = *_counter + 1; } Clever & operator = (const Clever & rhs) { @@ -50,7 +50,7 @@ public: { std::swap(_counter, rhs._counter); } - ~Clever() { (*_counter)--; } + ~Clever() { *_counter = *_counter - 1; } static size_t getGlobal() { return _global; } bool operator == (const Clever & b) const { return _counter == b._counter; } private: diff --git a/vespalib/src/tests/stllike/hash_test.cpp b/vespalib/src/tests/stllike/hash_test.cpp index 8c017ef69b4..f26f75664df 100644 --- a/vespalib/src/tests/stllike/hash_test.cpp +++ b/vespalib/src/tests/stllike/hash_test.cpp @@ -171,16 +171,16 @@ TEST("test hash map iterator stability") class Clever { public: - Clever() : _counter(&_global) { (*_counter)++; } + Clever() : _counter(&_global) { *_counter = *_counter + 1; } Clever(volatile size_t * counter) : _counter(counter) { - (*_counter)++; + *_counter = *_counter + 1; } Clever(const Clever & rhs) : _counter(rhs._counter) { - (*_counter)++; + *_counter = *_counter + 1; } Clever & operator = (const Clever & rhs) { @@ -194,7 +194,7 @@ public: { std::swap(_counter, rhs._counter); } - ~Clever() { (*_counter)--; } + ~Clever() { *_counter = *_counter - 1; } static size_t getGlobal() { return _global; } private: volatile size_t * _counter; |