Oops, put the thread pool semaphore back in the main indexer.

This commit is contained in:
casey langen 2017-07-05 22:12:15 -07:00
parent 7418ba5b18
commit 2e3f62e225
2 changed files with 10 additions and 1 deletions

View File

@ -102,7 +102,8 @@ Indexer::Indexer(const std::string& libraryPath, const std::string& dbFilename)
, tracksScanned(0)
, exit(false)
, state(StateIdle)
, prefs(Preferences::ForComponent(prefs::components::Settings)) {
, prefs(Preferences::ForComponent(prefs::components::Settings))
, readSemaphore(prefs->GetInt(prefs::keys::MaxTagReadThreads, MAX_THREADS)) {
this->metadataReaders = PluginFactory::Instance()
.QueryInterface<IMetadataReader, MetadataDeleter>("GetMetadataReader");
@ -395,6 +396,10 @@ void Indexer::ReadMetadataFromFile(
}
this->IncrementTracksScanned();
#ifdef MULTI_THREADED_INDEXER
this->readSemaphore.post();
#endif
}
inline void Indexer::IncrementTracksScanned(size_t delta) {
@ -444,6 +449,8 @@ void Indexer::SyncDirectory(
}
else {
if (io) {
this->readSemaphore.wait();
io->post(boost::bind(
&Indexer::ReadMetadataFromFile,
this,

View File

@ -48,6 +48,7 @@
#include <boost/thread/condition.hpp>
#include <boost/filesystem.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
#include <deque>
#include <vector>
@ -156,6 +157,7 @@ namespace musik { namespace core {
std::shared_ptr<musik::core::db::ScopedTransaction> trackTransaction;
std::vector<std::string> paths;
std::shared_ptr<musik::core::sdk::IIndexerSource> currentSource;
boost::interprocess::interprocess_semaphore readSemaphore;
};
typedef std::shared_ptr<Indexer> IndexerPtr;