diff --git a/src/libtomahawk/pipeline.cpp b/src/libtomahawk/pipeline.cpp index ee6d12ff6..0d9d4a385 100644 --- a/src/libtomahawk/pipeline.cpp +++ b/src/libtomahawk/pipeline.cpp @@ -25,7 +25,7 @@ #include "functimeout.h" #include "database/database.h" -#define CONCURRENT_QUERIES 4 +#define DEFAULT_CONCURRENT_QUERIES 4 using namespace Tomahawk; @@ -44,6 +44,9 @@ Pipeline::Pipeline( QObject* parent ) , m_running( false ) { s_instance = this; + + m_maxConcurrentQueries = qMax( DEFAULT_CONCURRENT_QUERIES, QThread::idealThreadCount() * 2 ); + qDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentQueries << "threads"; } @@ -82,7 +85,7 @@ void Pipeline::removeResolver( Resolver* r ) { QMutexLocker lock( &m_mut ); - + m_resolvers.removeAll( r ); emit resolverRemoved( r ); } @@ -244,7 +247,7 @@ Pipeline::shuntNext() // qDebug() << Q_FUNC_INFO << m_qidsState.count(); // Check if we are ready to dispatch more queries - if ( m_qidsState.count() >= CONCURRENT_QUERIES ) + if ( m_qidsState.count() >= m_maxConcurrentQueries ) return; /* diff --git a/src/libtomahawk/pipeline.h b/src/libtomahawk/pipeline.h index faee4a018..ba438ad7e 100644 --- a/src/libtomahawk/pipeline.h +++ b/src/libtomahawk/pipeline.h @@ -79,7 +79,7 @@ public slots: signals: void idle(); void resolving( const Tomahawk::query_ptr& query ); - + void resolverAdded( Resolver* ); void resolverRemoved( Resolver* ); @@ -104,6 +104,7 @@ private: // store queries here until DB index is loaded, then shunt them all QList< query_ptr > m_queries_pending; + int m_maxConcurrentQueries; bool m_running; static Pipeline* s_instance;