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

View File

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

View File

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