Allow the user to customize the number of tag read threads.

This commit is contained in:
casey 2016-07-04 15:53:35 -07:00
parent d918c4e028
commit a5d95de7ac
2 changed files with 7 additions and 3 deletions

View File

@ -52,7 +52,7 @@
#include <boost/bind.hpp>
static const std::string TAG = "Indexer";
static const int MAX_THREADS = 8;
static const int MAX_THREADS = 10;
using namespace musik::core;
using namespace musik::core::metadata;
@ -80,11 +80,13 @@ Indexer::Indexer(const std::string& libraryPath, const std::string& dbFilename)
, status(0)
, restart(false)
, filesIndexed(0)
, filesSaved(0) {
, filesSaved(0)
, maxReadThreads(MAX_THREADS) {
this->dbFilename = dbFilename;
this->libraryPath = libraryPath;
this->prefs = Preferences::ForComponent(INDEXER_PREFS_COMPONENT);
this->thread = new boost::thread(boost::bind(&Indexer::ThreadLoop, this));
this->maxReadThreads = this->prefs->GetInt(INDEXER_PREFS_MAX_TAG_READ_THREADS, MAX_THREADS);
}
Indexer::~Indexer() {
@ -354,7 +356,7 @@ void Indexer::SyncDirectory(
for( ; file != end && !this->Exited() && !this->Restarted(); file++) {
/* we do things in batches of 5. wait for this batch to
finish, then we'll spin up some more... */
if (threads.size() >= MAX_THREADS) {
if (threads.size() >= this->maxReadThreads) {
WAIT_FOR_ACTIVE();
}

View File

@ -54,6 +54,7 @@
#define INDEXER_PREFS_SYNC_ON_STARTUP "SyncOnStartup"
#define INDEXER_PREFS_SYNC_TIMEOUT "SyncTimeout"
#define INDEXER_PREFS_REMOVE_MISSING_FILES "RemoveMissingFiles"
#define INDEXER_PREFS_MAX_TAG_READ_THREADS "MaxTagReadThreads"
namespace musik { namespace core {
@ -123,6 +124,7 @@ namespace musik { namespace core {
DecoderList audioDecoders;
std::shared_ptr<musik::core::Preferences> prefs;
std::shared_ptr<musik::core::db::ScopedTransaction> trackTransaction;
int maxReadThreads;
};
typedef std::shared_ptr<Indexer> IndexerPtr;