1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-16 11:04:01 +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 "functimeout.h"
#include "database/database.h" #include "database/database.h"
#define CONCURRENT_QUERIES 4 #define DEFAULT_CONCURRENT_QUERIES 4
using namespace Tomahawk; using namespace Tomahawk;
@@ -44,6 +44,9 @@ Pipeline::Pipeline( QObject* parent )
, m_running( false ) , m_running( false )
{ {
s_instance = this; s_instance = this;
m_maxConcurrentQueries = qMax( DEFAULT_CONCURRENT_QUERIES, QThread::idealThreadCount() * 2 );
qDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentQueries << "threads";
} }
@@ -244,7 +247,7 @@ Pipeline::shuntNext()
// qDebug() << Q_FUNC_INFO << m_qidsState.count(); // qDebug() << Q_FUNC_INFO << m_qidsState.count();
// Check if we are ready to dispatch more queries // Check if we are ready to dispatch more queries
if ( m_qidsState.count() >= CONCURRENT_QUERIES ) if ( m_qidsState.count() >= m_maxConcurrentQueries )
return; return;
/* /*

View File

@@ -104,6 +104,7 @@ private:
// store queries here until DB index is loaded, then shunt them all // store queries here until DB index is loaded, then shunt them all
QList< query_ptr > m_queries_pending; QList< query_ptr > m_queries_pending;
int m_maxConcurrentQueries;
bool m_running; bool m_running;
static Pipeline* s_instance; static Pipeline* s_instance;