mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
* Fixed pipeline. Speeds it up, allows for parallel execution of multiple same-weighted resolvers.
This commit is contained in:
@@ -188,9 +188,6 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
|
||||
|
||||
if ( decQIDState( q ) == 0 )
|
||||
{
|
||||
// All resolvers have reported back their results for this query now
|
||||
qDebug() << "Finished resolving:" << q->toString() << q->numResults();
|
||||
|
||||
if ( !q->solved() )
|
||||
q->onResolvingFinished();
|
||||
|
||||
@@ -243,45 +240,43 @@ Pipeline::shunt( const query_ptr& q )
|
||||
qDebug() << Q_FUNC_INFO << q->solved() << q->toString() << q->id();
|
||||
unsigned int lastweight = 0;
|
||||
unsigned int lasttimeout = 0;
|
||||
|
||||
if ( q->solved() )
|
||||
{
|
||||
// qDebug() << "Query solved, pipeline aborted:" << q->toString()
|
||||
// << "numresults:" << q->results().length();
|
||||
|
||||
QList< result_ptr > rl;
|
||||
reportResults( q->id(), rl );
|
||||
return;
|
||||
}
|
||||
|
||||
int thisResolver = 0;
|
||||
int i = 0;
|
||||
foreach( Resolver* r, m_resolvers )
|
||||
bool dispatched = false;
|
||||
|
||||
if ( !q->resolvingFinished() )
|
||||
{
|
||||
i++;
|
||||
if ( r->weight() >= q->lastPipelineWeight() )
|
||||
continue;
|
||||
int i = 0;
|
||||
foreach( Resolver* r, m_resolvers )
|
||||
{
|
||||
i++;
|
||||
if ( r->weight() >= q->lastPipelineWeight() )
|
||||
continue;
|
||||
|
||||
if ( lastweight == 0 )
|
||||
{
|
||||
lastweight = r->weight();
|
||||
lasttimeout = r->timeout();
|
||||
//qDebug() << "Shunting into weight" << lastweight << "q:" << q->toString();
|
||||
}
|
||||
if ( lastweight == r->weight() )
|
||||
{
|
||||
// snag the lowest timeout at this weight
|
||||
if ( r->timeout() < lasttimeout )
|
||||
if ( lastweight == 0 )
|
||||
{
|
||||
lastweight = r->weight();
|
||||
lasttimeout = r->timeout();
|
||||
//qDebug() << "Shunting into weight" << lastweight << "q:" << q->toString();
|
||||
}
|
||||
if ( lastweight == r->weight() )
|
||||
{
|
||||
// snag the lowest timeout at this weight
|
||||
if ( r->timeout() < lasttimeout )
|
||||
lasttimeout = r->timeout();
|
||||
|
||||
// resolvers aren't allowed to block in this call:
|
||||
qDebug() << "Dispatching to resolver" << r->name() << q->toString();
|
||||
// resolvers aren't allowed to block in this call:
|
||||
if ( dispatched )
|
||||
incQIDState( q );
|
||||
|
||||
thisResolver = i;
|
||||
r->resolve( q );
|
||||
dispatched = true;
|
||||
qDebug() << "Dispatching to resolver" << r->name() << q->toString();
|
||||
|
||||
thisResolver = i;
|
||||
r->resolve( q );
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if ( lastweight > 0 )
|
||||
@@ -290,18 +285,19 @@ Pipeline::shunt( const query_ptr& q )
|
||||
|
||||
if ( thisResolver < m_resolvers.count() )
|
||||
{
|
||||
qDebug() << "Shunting in" << lasttimeout << "ms, q:" << q->toString();
|
||||
incQIDState( q );
|
||||
// qDebug() << "Shunting in" << lasttimeout << "ms, q:" << q->toString();
|
||||
new FuncTimeout( lasttimeout, boost::bind( &Pipeline::shunt, this, q ), this );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//qDebug() << "Reached end of pipeline for:" << q->toString();
|
||||
// reached end of pipeline
|
||||
QList< result_ptr > rl;
|
||||
reportResults( q->id(), rl );
|
||||
return;
|
||||
qDebug() << "Reached end of pipeline for:" << q->toString();
|
||||
|
||||
decQIDState( q );
|
||||
if ( !q->solved() )
|
||||
q->onResolvingFinished();
|
||||
}
|
||||
|
||||
shuntNext();
|
||||
@@ -329,7 +325,7 @@ Pipeline::incQIDState( const Tomahawk::query_ptr& query )
|
||||
state = m_qidsState.value( query->id() ) + 1;
|
||||
}
|
||||
|
||||
// qDebug() << Q_FUNC_INFO << "inserting to qidsstate:" << query->id() << state;
|
||||
qDebug() << Q_FUNC_INFO << "inserting to qidsstate:" << query->id() << state;
|
||||
m_qidsState.insert( query->id(), state );
|
||||
|
||||
return state;
|
||||
@@ -344,12 +340,12 @@ Pipeline::decQIDState( const Tomahawk::query_ptr& query )
|
||||
int state = m_qidsState.value( query->id() ) - 1;
|
||||
if ( state )
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << "replacing" << query->id() << state;
|
||||
qDebug() << Q_FUNC_INFO << "replacing" << query->id() << state;
|
||||
m_qidsState.insert( query->id(), state );
|
||||
}
|
||||
else
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << "removing" << query->id() << state;
|
||||
qDebug() << Q_FUNC_INFO << "removing" << query->id() << state;
|
||||
m_qidsState.remove( query->id() );
|
||||
}
|
||||
|
||||
|
2
thirdparty/jreen
vendored
2
thirdparty/jreen
vendored
Submodule thirdparty/jreen updated: 58fb2d4bc2...40fd6b0a3d
Reference in New Issue
Block a user