mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-18 00:50:05 +02:00
AUP3: Adjust checkpoint thread controls
To better reflect how they are used...simple flags
This commit is contained in:
parent
38d13ebdc0
commit
f3293fd102
@ -72,8 +72,8 @@ bool DBConnection::Open(const char *fileName)
|
|||||||
|
|
||||||
// Kick off the checkpoint thread
|
// Kick off the checkpoint thread
|
||||||
mCheckpointStop = false;
|
mCheckpointStop = false;
|
||||||
mCheckpointWaitingPages = 0;
|
mCheckpointPending = false;
|
||||||
mCheckpointCurrentPages = 0;
|
mCheckpointActive = false;
|
||||||
mCheckpointThread = std::thread([this]{ CheckpointThread(); });
|
mCheckpointThread = std::thread([this]{ CheckpointThread(); });
|
||||||
|
|
||||||
// Install our checkpoint hook
|
// Install our checkpoint hook
|
||||||
@ -98,7 +98,7 @@ bool DBConnection::Close()
|
|||||||
sqlite3_wal_hook(mDB, nullptr, nullptr);
|
sqlite3_wal_hook(mDB, nullptr, nullptr);
|
||||||
|
|
||||||
// Display a progress dialog if there's active or pending checkpoints
|
// Display a progress dialog if there's active or pending checkpoints
|
||||||
if (mCheckpointWaitingPages || mCheckpointCurrentPages)
|
if (mCheckpointPending || mCheckpointActive)
|
||||||
{
|
{
|
||||||
TranslatableString title = XO("Checkpointing project");
|
TranslatableString title = XO("Checkpointing project");
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ bool DBConnection::Close()
|
|||||||
wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_SMOOTH);
|
wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_SMOOTH);
|
||||||
|
|
||||||
// Wait for the checkpoints to end
|
// Wait for the checkpoints to end
|
||||||
while (mCheckpointWaitingPages || mCheckpointCurrentPages)
|
while (mCheckpointPending || mCheckpointActive)
|
||||||
{
|
{
|
||||||
wxMilliSleep(50);
|
wxMilliSleep(50);
|
||||||
pd.Pulse();
|
pd.Pulse();
|
||||||
@ -256,7 +256,7 @@ void DBConnection::CheckpointThread()
|
|||||||
mCheckpointCondition.wait(lock,
|
mCheckpointCondition.wait(lock,
|
||||||
[&]
|
[&]
|
||||||
{
|
{
|
||||||
return mCheckpointWaitingPages || mCheckpointStop;
|
return mCheckpointPending || mCheckpointStop;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Requested to stop, so bail
|
// Requested to stop, so bail
|
||||||
@ -266,8 +266,8 @@ void DBConnection::CheckpointThread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Capture the number of pages that need checkpointing and reset
|
// Capture the number of pages that need checkpointing and reset
|
||||||
mCheckpointCurrentPages.store( mCheckpointWaitingPages );
|
mCheckpointActive = true;
|
||||||
mCheckpointWaitingPages = 0;
|
mCheckpointPending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// And kick off the checkpoint. This may not checkpoint ALL frames
|
// And kick off the checkpoint. This may not checkpoint ALL frames
|
||||||
@ -275,7 +275,7 @@ void DBConnection::CheckpointThread()
|
|||||||
sqlite3_wal_checkpoint_v2(db, nullptr, SQLITE_CHECKPOINT_PASSIVE, nullptr, nullptr);
|
sqlite3_wal_checkpoint_v2(db, nullptr, SQLITE_CHECKPOINT_PASSIVE, nullptr, nullptr);
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
mCheckpointCurrentPages = 0;
|
mCheckpointActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ int DBConnection::CheckpointHook(void *data, sqlite3 *db, const char *schema, in
|
|||||||
|
|
||||||
// Queue the database pointer for our checkpoint thread to process
|
// Queue the database pointer for our checkpoint thread to process
|
||||||
std::lock_guard<std::mutex> guard(that->mCheckpointMutex);
|
std::lock_guard<std::mutex> guard(that->mCheckpointMutex);
|
||||||
that->mCheckpointWaitingPages = pages;
|
that->mCheckpointPending = true;
|
||||||
that->mCheckpointCondition.notify_one();
|
that->mCheckpointCondition.notify_one();
|
||||||
|
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
|
@ -75,8 +75,8 @@ private:
|
|||||||
std::condition_variable mCheckpointCondition;
|
std::condition_variable mCheckpointCondition;
|
||||||
std::mutex mCheckpointMutex;
|
std::mutex mCheckpointMutex;
|
||||||
std::atomic_bool mCheckpointStop{ false };
|
std::atomic_bool mCheckpointStop{ false };
|
||||||
std::atomic_int mCheckpointWaitingPages{ 0 };
|
std::atomic_bool mCheckpointPending{ false };
|
||||||
std::atomic_int mCheckpointCurrentPages{ 0 };
|
std::atomic_bool mCheckpointActive{ false };
|
||||||
|
|
||||||
std::map<enum StatementID, sqlite3_stmt *> mStatements;
|
std::map<enum StatementID, sqlite3_stmt *> mStatements;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user