aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zenutil/cache/rpcrecording.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/zenutil/cache/rpcrecording.cpp b/src/zenutil/cache/rpcrecording.cpp
index 380c182b2..46e80f6b7 100644
--- a/src/zenutil/cache/rpcrecording.cpp
+++ b/src/zenutil/cache/rpcrecording.cpp
@@ -366,6 +366,7 @@ private:
};
std::unique_ptr<std::thread> m_WriterThread;
+ std::atomic_bool m_IsWriterReady{false};
std::atomic_bool m_IsActive{false};
std::atomic_int64_t m_PendingRequests{0};
RwLock m_RequestQueueLock;
@@ -658,6 +659,8 @@ RecordedRequestsWriter::BeginWrite(const std::filesystem::path& BasePath)
m_IsActive = true;
m_WriterThread.reset(new std::thread(&RecordedRequestsWriter::WriterThreadMain, this));
+
+ m_IsWriterReady.wait(false);
}
void
@@ -707,6 +710,9 @@ RecordedRequestsWriter::WriterThreadMain()
SetCurrentThreadName("rpc_writer");
EnsureCurrentSegment();
+ m_IsWriterReady.store(true);
+ m_IsWriterReady.notify_all();
+
while (m_IsActive)
{
m_PendingRequests.wait(0);