1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 17:43:59 +02:00

* Made the pipeline cleverer when it comes to using threads.

This commit is contained in:
Christian Muehlhaeuser
2011-06-15 04:08:32 +02:00
parent f5d61a60f8
commit 78e064e1c5
2 changed files with 8 additions and 4 deletions

View File

@@ -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;
/*

View File

@@ -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;