mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
* Don't do separate thread pools per command anymore.
This commit is contained in:
@@ -70,9 +70,8 @@ Database::loadIndex()
|
|||||||
void
|
void
|
||||||
Database::enqueue( QSharedPointer<DatabaseCommand> lc )
|
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() )
|
||||||
{
|
{
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user