summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/querylimiter.h2
-rw-r--r--vespalib/src/tests/array/array_test.cpp13
-rw-r--r--vespalib/src/tests/stllike/hash_test.cpp11
3 files changed, 14 insertions, 12 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.h b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.h
index 45783959957..576c5921b61 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.h
@@ -37,7 +37,7 @@ private:
void releaseToken();
std::mutex _lock;
std::condition_variable _cond;
- volatile int _activeThreads;
+ int _activeThreads;
// These are updated asynchronously at reconfig.
volatile int _maxThreads;
diff --git a/vespalib/src/tests/array/array_test.cpp b/vespalib/src/tests/array/array_test.cpp
index c0189ad8ad6..a5dfd1472a6 100644
--- a/vespalib/src/tests/array/array_test.cpp
+++ b/vespalib/src/tests/array/array_test.cpp
@@ -4,6 +4,7 @@
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <deque>
+#include <atomic>
using namespace vespalib;
@@ -28,7 +29,7 @@ std::ostream & operator << (std::ostream & os, const Array<T> & a)
class Clever {
public:
Clever() : _counter(&_global) { (*_counter)++; }
- Clever(volatile size_t * counter) :
+ Clever(std::atomic<size_t> * counter) :
_counter(counter)
{
(*_counter)++;
@@ -54,8 +55,8 @@ public:
static size_t getGlobal() { return _global; }
bool operator == (const Clever & b) const { return _counter == b._counter; }
private:
- volatile size_t * _counter;
- static size_t _global;
+ std::atomic<size_t> * _counter;
+ static std::atomic<size_t> _global;
};
std::ostream & operator << (std::ostream & os, const Clever & clever)
@@ -114,7 +115,7 @@ TEST("test basic array functionality")
testArray(a, b);
EXPECT_TRUE(a == a);
EXPECT_FALSE(a == b);
- size_t counter(0);
+ std::atomic<size_t> counter(0);
testArray(Clever(&counter), Clever(&counter));
EXPECT_EQUAL(0ul, counter);
}
@@ -155,11 +156,11 @@ TEST("test that organic growth is by 2 in N and reserve resize are exact")
EXPECT_EQUAL(2048u, c.capacity());
}
-size_t Clever::_global = 0;
+std::atomic<size_t> Clever::_global = 0;
TEST("test complicated")
{
- volatile size_t counter(0);
+ std::atomic<size_t> counter(0);
{
EXPECT_EQUAL(0ul, Clever::getGlobal());
Clever c(&counter);
diff --git a/vespalib/src/tests/stllike/hash_test.cpp b/vespalib/src/tests/stllike/hash_test.cpp
index 8c017ef69b4..561c7b34035 100644
--- a/vespalib/src/tests/stllike/hash_test.cpp
+++ b/vespalib/src/tests/stllike/hash_test.cpp
@@ -7,6 +7,7 @@
#include <vespa/vespalib/stllike/allocator.h>
#include <cstddef>
#include <algorithm>
+#include <atomic>
using namespace vespalib;
using std::make_pair;
@@ -172,7 +173,7 @@ TEST("test hash map iterator stability")
class Clever {
public:
Clever() : _counter(&_global) { (*_counter)++; }
- Clever(volatile size_t * counter) :
+ Clever(std::atomic<size_t> * counter) :
_counter(counter)
{
(*_counter)++;
@@ -197,15 +198,15 @@ public:
~Clever() { (*_counter)--; }
static size_t getGlobal() { return _global; }
private:
- volatile size_t * _counter;
- static size_t _global;
+ std::atomic<size_t> * _counter;
+ static std::atomic<size_t> _global;
};
-size_t Clever::_global = 0;
+std::atomic<size_t> Clever::_global = 0;
TEST("test hash map resizing")
{
- volatile size_t counter(0);
+ std::atomic<size_t> counter(0);
{
EXPECT_EQUAL(0ul, Clever::getGlobal());
Clever c(&counter);