mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 20:13:36 +00:00
Reduce number of UI updates when running indexer at startup.
This commit is contained in:
parent
7aa27a231c
commit
e3281d5506
@ -293,6 +293,7 @@ void Indexer::ReadMetadataFromFile(
|
||||
if (saveToDb) {
|
||||
track.SetValue("path_id", pathId.c_str());
|
||||
track.Save(this->dbConnection, this->libraryPath);
|
||||
this->filesSaved++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,23 +301,21 @@ static inline void joinAndNotify(
|
||||
std::vector<Thread>& threads,
|
||||
std::shared_ptr<musik::core::db::ScopedTransaction> transaction,
|
||||
sigslot::signal0<>& event,
|
||||
size_t& total)
|
||||
std::atomic<size_t>& saved)
|
||||
{
|
||||
total += threads.size();
|
||||
|
||||
for (size_t i = 0; i < threads.size(); i++) {
|
||||
threads.at(i)->join();
|
||||
}
|
||||
|
||||
threads.clear();
|
||||
|
||||
if (total > 200) {
|
||||
if (saved.load() > 200) {
|
||||
if (transaction) {
|
||||
transaction->CommitAndRestart();
|
||||
}
|
||||
|
||||
event();
|
||||
total = 0;
|
||||
saved.store(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
|
||||
#define INDEXER_PREFS_COMPONENT "indexer"
|
||||
#define INDEXER_PREFS_SYNC_ON_STARTUP "SyncOnStartup"
|
||||
@ -105,7 +106,7 @@ namespace musik { namespace core {
|
||||
boost::mutex progressMutex;
|
||||
|
||||
size_t filesIndexed;
|
||||
size_t filesSaved;
|
||||
std::atomic<size_t> filesSaved;
|
||||
|
||||
struct AddRemoveContext {
|
||||
bool add;
|
||||
@ -124,7 +125,7 @@ namespace musik { namespace core {
|
||||
DecoderList audioDecoders;
|
||||
std::shared_ptr<musik::core::Preferences> prefs;
|
||||
std::shared_ptr<musik::core::db::ScopedTransaction> trackTransaction;
|
||||
int maxReadThreads;
|
||||
size_t maxReadThreads;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Indexer> IndexerPtr;
|
||||
|
Loading…
Reference in New Issue
Block a user