mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +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 )
|
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() )
|
if ( !q->solved() )
|
||||||
q->onResolvingFinished();
|
q->onResolvingFinished();
|
||||||
|
|
||||||
@@ -243,18 +240,11 @@ Pipeline::shunt( const query_ptr& q )
|
|||||||
qDebug() << Q_FUNC_INFO << q->solved() << q->toString() << q->id();
|
qDebug() << Q_FUNC_INFO << q->solved() << q->toString() << q->id();
|
||||||
unsigned int lastweight = 0;
|
unsigned int lastweight = 0;
|
||||||
unsigned int lasttimeout = 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 thisResolver = 0;
|
||||||
|
bool dispatched = false;
|
||||||
|
|
||||||
|
if ( !q->resolvingFinished() )
|
||||||
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach( Resolver* r, m_resolvers )
|
foreach( Resolver* r, m_resolvers )
|
||||||
{
|
{
|
||||||
@@ -275,6 +265,10 @@ Pipeline::shunt( const query_ptr& q )
|
|||||||
lasttimeout = r->timeout();
|
lasttimeout = r->timeout();
|
||||||
|
|
||||||
// resolvers aren't allowed to block in this call:
|
// resolvers aren't allowed to block in this call:
|
||||||
|
if ( dispatched )
|
||||||
|
incQIDState( q );
|
||||||
|
|
||||||
|
dispatched = true;
|
||||||
qDebug() << "Dispatching to resolver" << r->name() << q->toString();
|
qDebug() << "Dispatching to resolver" << r->name() << q->toString();
|
||||||
|
|
||||||
thisResolver = i;
|
thisResolver = i;
|
||||||
@@ -283,6 +277,7 @@ Pipeline::shunt( const query_ptr& q )
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( lastweight > 0 )
|
if ( lastweight > 0 )
|
||||||
{
|
{
|
||||||
@@ -290,18 +285,19 @@ Pipeline::shunt( const query_ptr& q )
|
|||||||
|
|
||||||
if ( thisResolver < m_resolvers.count() )
|
if ( thisResolver < m_resolvers.count() )
|
||||||
{
|
{
|
||||||
|
qDebug() << "Shunting in" << lasttimeout << "ms, q:" << q->toString();
|
||||||
incQIDState( q );
|
incQIDState( q );
|
||||||
// qDebug() << "Shunting in" << lasttimeout << "ms, q:" << q->toString();
|
|
||||||
new FuncTimeout( lasttimeout, boost::bind( &Pipeline::shunt, this, q ), this );
|
new FuncTimeout( lasttimeout, boost::bind( &Pipeline::shunt, this, q ), this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//qDebug() << "Reached end of pipeline for:" << q->toString();
|
|
||||||
// reached end of pipeline
|
// reached end of pipeline
|
||||||
QList< result_ptr > rl;
|
qDebug() << "Reached end of pipeline for:" << q->toString();
|
||||||
reportResults( q->id(), rl );
|
|
||||||
return;
|
decQIDState( q );
|
||||||
|
if ( !q->solved() )
|
||||||
|
q->onResolvingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
shuntNext();
|
shuntNext();
|
||||||
@@ -329,7 +325,7 @@ Pipeline::incQIDState( const Tomahawk::query_ptr& query )
|
|||||||
state = m_qidsState.value( query->id() ) + 1;
|
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 );
|
m_qidsState.insert( query->id(), state );
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
@@ -344,12 +340,12 @@ Pipeline::decQIDState( const Tomahawk::query_ptr& query )
|
|||||||
int state = m_qidsState.value( query->id() ) - 1;
|
int state = m_qidsState.value( query->id() ) - 1;
|
||||||
if ( state )
|
if ( state )
|
||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO << "replacing" << query->id() << state;
|
qDebug() << Q_FUNC_INFO << "replacing" << query->id() << state;
|
||||||
m_qidsState.insert( query->id(), state );
|
m_qidsState.insert( query->id(), state );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO << "removing" << query->id() << state;
|
qDebug() << Q_FUNC_INFO << "removing" << query->id() << state;
|
||||||
m_qidsState.remove( query->id() );
|
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