1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

* Don't create WelcomeWidget twice.

* Don't place duplicate queries in the resolve-queue.
* Made Pipeline's prioritization system actually work.
This commit is contained in:
Christian Muehlhaeuser
2011-02-08 07:53:09 +01:00
parent 901a40a814
commit f292673622
3 changed files with 55 additions and 28 deletions

View File

@@ -7,6 +7,8 @@
#include "functimeout.h"
#include "database/database.h"
#define CONCURRENT_QUERIES 8
using namespace Tomahawk;
Pipeline* Pipeline::s_instance = 0;
@@ -85,6 +87,11 @@ Pipeline::resolve( const QList<query_ptr>& qlist, bool prioritized )
{
m_qids.insert( q->id(), q );
}
else
{
qDebug() << "Already queued for resolving:" << q->toString();
return;
}
}
if ( prioritized )
@@ -98,7 +105,6 @@ Pipeline::resolve( const QList<query_ptr>& qlist, bool prioritized )
}
}
if ( m_index_ready && m_queries_pending.count() )
shuntNext();
}
@@ -124,17 +130,31 @@ Pipeline::resolve( QID qid, bool prioritized )
void
Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
{
unsigned int state = 0;
{
QMutexLocker lock( &m_mut );
if ( !m_qids.contains( qid ) )
{
qDebug() << "reportResults called for unknown QID";
Q_ASSERT( false );
return;
}
unsigned int state = m_qidsState.value( qid ) - 1;
if ( !m_qidsState.contains( qid ) )
{
qDebug() << "reportResults called for unknown QID-state";
Q_ASSERT( false );
return;
}
state = m_qidsState.value( qid ) - 1;
if ( state )
m_qidsState.insert( qid, state );
else
m_qidsState.remove( qid );
if ( !results.isEmpty() )
{
@@ -149,22 +169,27 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
m_rids.insert( r->id(), r );
}
}
}
if ( state == 0 )
{
// All resolvers have reported back their results for this query now
const query_ptr& q = m_qids.value( qid );
qDebug() << "Finished resolving:" << q->toString();
q->onResolvingFinished();
}
shuntNext();
}
}
void
Pipeline::shuntNext()
{
query_ptr q;
if ( !m_index_ready )
return;
query_ptr q;
{
QMutexLocker lock( &m_mut );
@@ -174,6 +199,10 @@ Pipeline::shuntNext()
return;
}
// Check if we are ready to dispatch more queries
if ( m_qidsState.count() >= CONCURRENT_QUERIES )
return;
/*
Since resolvers are async, we now dispatch to the highest weighted ones
and after timeout, dispatch to next highest etc, aborting when solved

View File

@@ -46,9 +46,9 @@ public:
}
public slots:
void resolve( const query_ptr& q, bool prioritized = true );
void resolve( const QList<query_ptr>& qlist, bool prioritized = true );
void resolve( QID qid, bool prioritized = true );
void resolve( const query_ptr& q, bool prioritized = false );
void resolve( const QList<query_ptr>& qlist, bool prioritized = false );
void resolve( QID qid, bool prioritized = false );
void databaseReady();
signals:

View File

@@ -89,8 +89,6 @@ PlaylistManager::PlaylistManager( QObject* parent )
m_stack->addWidget( m_playlistView );
m_playlistModel = new PlaylistModel();
show( new WelcomeWidget() );
m_stack->setContentsMargins( 0, 0, 0, 0 );
m_widget->setContentsMargins( 0, 0, 0, 0 );
m_widget->layout()->setContentsMargins( 0, 0, 0, 0 );