summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@oath.com>2019-01-10 14:58:35 +0000
committerTor Brede Vekterli <vekterli@oath.com>2019-01-10 14:58:35 +0000
commitaa2701268df26145d8a58acc7603b4006d00e288 (patch)
tree0b57a726e15a621d96e6b264ccbdcc461b5a6178 /storage
parent7e25bca7899370ee5aeb7bc9f6a5877fe0c8d281 (diff)
Use atomics to ensure well-defined memory visibility in test
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/persistence/filestorage/filestormanagertest.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
index 61c55248370..f03d2fa3647 100644
--- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
+++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
@@ -20,6 +20,7 @@
#include <vespa/persistence/spi/test.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/fastos/file.h>
+#include <atomic>
#include <vespa/log/log.h>
LOG_SETUP(".filestormanagertest");
@@ -668,8 +669,8 @@ class MessagePusherThread : public document::Runnable
public:
FileStorHandler& _handler;
Document::SP _doc;
- bool _done;
- bool _threadDone;
+ std::atomic<bool> _done;
+ std::atomic<bool> _threadDone;
MessagePusherThread(FileStorHandler& handler, Document::SP doc);
~MessagePusherThread();
@@ -698,10 +699,10 @@ public:
const uint32_t _threadId;
FileStorHandler& _handler;
std::atomic<uint32_t> _config;
- uint32_t _fetchedCount;
- bool _done;
- bool _failed;
- bool _threadDone;
+ std::atomic<uint32_t> _fetchedCount;
+ std::atomic<bool> _done;
+ std::atomic<bool> _failed;
+ std::atomic<bool> _threadDone;
MessageFetchingThread(FileStorHandler& handler)
: _threadId(handler.getNextStripeId(0)), _handler(handler), _config(0), _fetchedCount(0), _done(false),
@@ -766,7 +767,7 @@ FileStorManagerTest::testHandlerPausedMultiThread()
ResumeGuard guard = filestorHandler.pause();
thread._config.fetch_add(1);
uint32_t count = thread._fetchedCount;
- CPPUNIT_ASSERT_EQUAL(count, thread._fetchedCount);
+ CPPUNIT_ASSERT_EQUAL(count, thread._fetchedCount.load());
}
pushthread._done = true;