summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-21 17:50:17 +0100
committerGitHub <noreply@github.com>2022-02-21 17:50:17 +0100
commita7e8bb9dcf3c674a3756e0f0383384593856415a (patch)
tree3944389e6b3d0e5b0ef7992808a3ca1ff24ff260 /searchcore/src/tests
parentf67ad6e4bdb5cf4b834428c61bc18953d9efd761 (diff)
parenteddc91fb205d4bc8e68aa72be86ed39a199728b5 (diff)
Merge pull request #21285 from vespa-engine/vekterli/more-threading-fixes
More miscellaneous threading fixes [run-systemtest]
Diffstat (limited to 'searchcore/src/tests')
-rw-r--r--searchcore/src/tests/proton/flushengine/flushengine_test.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
index 3bff3649634..7e4980277e7 100644
--- a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
+++ b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
@@ -118,7 +118,7 @@ public:
search::SerialNum _currentSerial;
uint32_t _pendingDone;
uint32_t _taskDone;
- std::mutex _lock;
+ mutable std::mutex _lock;
vespalib::CountDownLatch _done;
FlushDoneHistory _flushDoneHistory;
@@ -146,7 +146,7 @@ public:
std::vector<IFlushTarget::SP>
getFlushTargets() override {
{
- std::lock_guard<std::mutex> guard(_lock);
+ std::lock_guard guard(_lock);
_pendingDone += _taskDone;
_taskDone = 0;
}
@@ -160,7 +160,7 @@ public:
// Called once by flush engine thread for each task done
void taskDone() {
- std::lock_guard<std::mutex> guard(_lock);
+ std::lock_guard guard(_lock);
++_taskDone;
}
@@ -168,7 +168,7 @@ public:
// added to flush engine and when one or more flush tasks related
// to flush handler have completed.
void flushDone(search::SerialNum oldestSerial) override {
- std::lock_guard<std::mutex> guard(_lock);
+ std::lock_guard guard(_lock);
LOG(info, "SimpleHandler(%s)::flushDone(%" PRIu64 ")", getName().c_str(), oldestSerial);
_oldestSerial = std::max(_oldestSerial, oldestSerial);
_flushDoneHistory.push_back(oldestSerial);
@@ -179,9 +179,14 @@ public:
}
FlushDoneHistory getFlushDoneHistory() {
- std::lock_guard<std::mutex> guard(_lock);
+ std::lock_guard guard(_lock);
return _flushDoneHistory;
}
+
+ [[nodiscard]] search::SerialNum oldest_serial() const noexcept {
+ std::lock_guard guard(_lock);
+ return _oldestSerial;
+ }
};
void WrappedFlushTask::run()
@@ -440,11 +445,11 @@ struct Fixture
using namespace std::chrono_literals;
for (int pass = 0; pass < 600; ++pass) {
std::this_thread::sleep_for(100ms);
- if (handler._oldestSerial == expOldestSerial) {
+ if (handler.oldest_serial() == expOldestSerial) {
break;
}
}
- EXPECT_EQUAL(expOldestSerial, handler._oldestSerial);
+ EXPECT_EQUAL(expOldestSerial, handler.oldest_serial());
}
};