1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-04 21:27:58 +02:00

* Don't do separate thread pools per command anymore.

This commit is contained in:
Christian Muehlhaeuser
2011-06-22 10:07:19 +02:00
parent 8d1f0e1646
commit 8240b8379b
3 changed files with 8 additions and 10 deletions

View File

@@ -72,7 +72,6 @@ Database::enqueue( QSharedPointer<DatabaseCommand> lc )
{ {
if ( lc->doesMutates() ) if ( lc->doesMutates() )
{ {
//qDebug() << Q_FUNC_INFO << "RW" << lc->commandname();
qDebug() << "Enqueueing command to rw thread:" << lc->commandname(); qDebug() << "Enqueueing command to rw thread:" << lc->commandname();
m_workerRW->enqueue( lc ); m_workerRW->enqueue( lc );
} }
@@ -80,21 +79,20 @@ Database::enqueue( QSharedPointer<DatabaseCommand> lc )
{ {
// find existing amount of worker threads for commandname // find existing amount of worker threads for commandname
// create new thread if < WORKER_THREADS // create new thread if < WORKER_THREADS
if ( m_workers.count( lc->commandname() ) < m_maxConcurrentThreads ) if ( m_workers.count() < m_maxConcurrentThreads )
{ {
DatabaseWorker* worker = new DatabaseWorker( m_impl, this, false ); DatabaseWorker* worker = new DatabaseWorker( m_impl, this, false );
worker->start(); worker->start();
m_workers.insertMulti( lc->commandname(), worker ); m_workers << worker;
} }
// find thread for commandname with lowest amount of outstanding jobs and enqueue job // find thread for commandname with lowest amount of outstanding jobs and enqueue job
int busyThreads = 0; int busyThreads = 0;
DatabaseWorker* happyThread = 0; DatabaseWorker* happyThread = 0;
QList< DatabaseWorker* > workers = m_workers.values( lc->commandname() ); for ( int i = 0; i < m_workers.count(); i++ )
for ( int i = 0; i < workers.count(); i++ )
{ {
DatabaseWorker* worker = workers.at( i ); DatabaseWorker* worker = m_workers.at( i );
if ( !worker->busy() ) if ( !worker->busy() )
{ {

View File

@@ -72,7 +72,7 @@ private:
bool m_ready; bool m_ready;
DatabaseImpl* m_impl; DatabaseImpl* m_impl;
DatabaseWorker* m_workerRW; DatabaseWorker* m_workerRW;
QHash< QString, DatabaseWorker* > m_workers; QList<DatabaseWorker*> m_workers;
bool m_indexReady; bool m_indexReady;
int m_maxConcurrentThreads; int m_maxConcurrentThreads;

View File

@@ -46,10 +46,10 @@ DatabaseWorker::~DatabaseWorker()
qDebug() << Q_FUNC_INFO << m_outstanding; qDebug() << Q_FUNC_INFO << m_outstanding;
if ( m_commands.count() ) if ( m_commands.count() )
qDebug() << m_commands; qDebug() << "Outstanding db commands to finish:" << m_commands;
quit(); quit();
wait( 60000 ); wait();
} }