step 6
This commit is contained in:
@@ -72,6 +72,12 @@ bool PersistenceWriter::EnqueueSnapshot(const PersistenceSnapshot& snapshot, std
|
||||
}
|
||||
|
||||
void PersistenceWriter::StopAndFlush()
|
||||
{
|
||||
std::string error;
|
||||
StopAndFlush((std::chrono::milliseconds::max)(), error);
|
||||
}
|
||||
|
||||
bool PersistenceWriter::StopAndFlush(std::chrono::milliseconds timeout, std::string& error)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
@@ -83,8 +89,28 @@ void PersistenceWriter::StopAndFlush()
|
||||
}
|
||||
mCondition.notify_all();
|
||||
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
if (mWorkerRunning)
|
||||
{
|
||||
if (timeout == (std::chrono::milliseconds::max)())
|
||||
{
|
||||
mCondition.wait(lock, [this]() { return !mWorkerRunning; });
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto deadline = std::chrono::steady_clock::now() + timeout;
|
||||
if (!mCondition.wait_until(lock, deadline, [this]() { return !mWorkerRunning; }))
|
||||
{
|
||||
error = "Timed out while flushing persistence writer.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
lock.unlock();
|
||||
|
||||
if (mWorker.joinable())
|
||||
mWorker.join();
|
||||
return true;
|
||||
}
|
||||
|
||||
PersistenceWriterMetrics PersistenceWriter::GetMetrics() const
|
||||
@@ -221,6 +247,7 @@ void PersistenceWriter::WorkerMain()
|
||||
if (mStopping)
|
||||
{
|
||||
mWorkerRunning = false;
|
||||
mCondition.notify_all();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
void SetResultCallback(ResultCallback callback);
|
||||
bool WriteSnapshot(const PersistenceSnapshot& snapshot, std::string& error);
|
||||
bool EnqueueSnapshot(const PersistenceSnapshot& snapshot, std::string& error);
|
||||
bool StopAndFlush(std::chrono::milliseconds timeout, std::string& error);
|
||||
void StopAndFlush();
|
||||
PersistenceWriterMetrics GetMetrics() const;
|
||||
|
||||
|
||||
@@ -156,6 +156,21 @@ bool RuntimeStore::RequestPersistence(const PersistenceRequest& request, std::st
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RuntimeStore::FlushPersistenceForShutdown(std::chrono::milliseconds timeout, std::string& error)
|
||||
{
|
||||
if (mPersistenceWriter.StopAndFlush(timeout, error))
|
||||
return true;
|
||||
|
||||
mHealthTelemetry.RecordPersistenceWriteResult(
|
||||
false,
|
||||
PersistenceTargetKindName(PersistenceTargetKind::RuntimeState),
|
||||
std::string(),
|
||||
"shutdown-flush",
|
||||
error,
|
||||
true);
|
||||
return false;
|
||||
}
|
||||
|
||||
PersistenceSnapshot RuntimeStore::BuildRuntimeStatePersistenceSnapshotLocked(const PersistenceRequest& request) const
|
||||
{
|
||||
PersistenceSnapshot snapshot;
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
std::string BuildPersistentStateJson() const;
|
||||
PersistenceSnapshot BuildRuntimeStatePersistenceSnapshot(const PersistenceRequest& request) const;
|
||||
bool RequestPersistence(const PersistenceRequest& request, std::string& error);
|
||||
bool FlushPersistenceForShutdown(std::chrono::milliseconds timeout, std::string& error);
|
||||
bool PollStoredFileChanges(bool& registryChanged, bool& reloadRequested, std::string& error);
|
||||
|
||||
bool CreateStoredLayer(const std::string& shaderId, std::string& error);
|
||||
|
||||
Reference in New Issue
Block a user