mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-31 17:08:45 +01:00
AUP3: Put checkpointing in a separate thread
This is highly experimental. It's defers most checkpointing to a separate thread to see if we get better throughput and less choppiness when applying effects.
This commit is contained in:
@@ -11,8 +11,14 @@ Paul Licameli split from AudacityProject.h
|
||||
#ifndef __AUDACITY_PROJECT_FILE_IO__
|
||||
#define __AUDACITY_PROJECT_FILE_IO__
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <set>
|
||||
|
||||
#include "ClientData.h" // to inherit
|
||||
#include "Prefs.h" // to inherit
|
||||
#include "xml/XMLTagHandler.h" // to inherit
|
||||
@@ -110,6 +116,10 @@ public:
|
||||
// The last vacuum check found unused blocks in the project file
|
||||
bool HadUnused();
|
||||
|
||||
bool TransactionStart(const wxString &name);
|
||||
bool TransactionCommit(const wxString &name);
|
||||
bool TransactionRollback(const wxString &name);
|
||||
|
||||
private:
|
||||
void WriteXMLHeader(XMLWriter &xmlFile) const;
|
||||
void WriteXML(XMLWriter &xmlFile, bool recording = false, const std::shared_ptr<TrackList> &tracks = nullptr) /* not override */;
|
||||
@@ -155,10 +165,6 @@ private:
|
||||
bool CloseDB();
|
||||
bool DeleteDB();
|
||||
|
||||
bool TransactionStart(const wxString &name);
|
||||
bool TransactionCommit(const wxString &name);
|
||||
bool TransactionRollback(const wxString &name);
|
||||
|
||||
bool Query(const char *sql, ExecResult &result);
|
||||
|
||||
bool GetValue(const char *sql, wxString &value);
|
||||
@@ -189,6 +195,9 @@ private:
|
||||
|
||||
bool ShouldVacuum(const std::shared_ptr<TrackList> &tracks);
|
||||
|
||||
void CheckpointThread();
|
||||
static int CheckpointHook(void *that, sqlite3 *db, const char *schema, int pages);
|
||||
|
||||
private:
|
||||
// non-static data members
|
||||
std::weak_ptr<AudacityProject> mpProject;
|
||||
@@ -221,8 +230,12 @@ private:
|
||||
TranslatableString mLastError;
|
||||
TranslatableString mLibraryError;
|
||||
|
||||
// Track the highest blockid while loading a project
|
||||
int64_t mHighestBlockID;
|
||||
std::deque<sqlite3 *> mCheckpointWork;
|
||||
std::condition_variable mCheckpointCondition;
|
||||
std::mutex mCheckpointMutex;
|
||||
std::thread mCheckpointThread;
|
||||
std::atomic_bool mCheckpointStop;
|
||||
std::mutex mCheckpointActive;
|
||||
|
||||
friend SqliteSampleBlock;
|
||||
friend AutoCommitTransaction;
|
||||
|
||||
Reference in New Issue
Block a user