mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 00:09:47 +01:00
Set future on artist/album immediately after creating promise
This commit is contained in:
parent
1fe28714cb
commit
9d9fae75b5
@ -151,9 +151,17 @@ void
|
||||
Album::loadId( bool autoCreate )
|
||||
{
|
||||
Q_ASSERT( m_waitingForId );
|
||||
m_idFuture = IdThreadWorker::getAlbumId( m_ownRef.toStrongRef(), autoCreate );
|
||||
IdThreadWorker::getAlbumId( m_ownRef.toStrongRef(), autoCreate );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Album::setIdFuture( boost::unique_future< unsigned int > future )
|
||||
{
|
||||
m_idFuture = boost::move( future );
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
Album::id() const
|
||||
{
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "Collection.h"
|
||||
#include "infosystem/InfoSystem.h"
|
||||
|
||||
class IdThreadWorker;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
@ -82,6 +84,7 @@ private slots:
|
||||
private:
|
||||
Q_DISABLE_COPY( Album )
|
||||
QString infoid() const;
|
||||
void setIdFuture( boost::unique_future< unsigned int > future );
|
||||
|
||||
mutable bool m_waitingForId;
|
||||
mutable boost::unique_future< unsigned int > m_idFuture;
|
||||
@ -107,6 +110,8 @@ private:
|
||||
|
||||
static QHash< QString, album_ptr > s_albumsByName;
|
||||
static QHash< unsigned int, album_ptr > s_albumsById;
|
||||
|
||||
friend class ::IdThreadWorker;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
@ -230,7 +230,15 @@ void
|
||||
Artist::loadId( bool autoCreate )
|
||||
{
|
||||
Q_ASSERT( m_waitingForFuture );
|
||||
m_idFuture = IdThreadWorker::getArtistId( m_ownRef.toStrongRef(), autoCreate );
|
||||
|
||||
IdThreadWorker::getArtistId( m_ownRef.toStrongRef(), autoCreate );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Artist::setIdFuture( boost::unique_future< unsigned int > future )
|
||||
{
|
||||
m_idFuture = boost::move(future);
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
class IdThreadWorker;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
@ -97,6 +99,8 @@ private:
|
||||
Artist();
|
||||
QString infoid() const;
|
||||
|
||||
void setIdFuture( boost::unique_future< unsigned int > future );
|
||||
|
||||
mutable bool m_waitingForFuture;
|
||||
mutable boost::unique_future< unsigned int > m_idFuture;
|
||||
mutable unsigned int m_id;
|
||||
@ -133,6 +137,8 @@ private:
|
||||
|
||||
static QHash< QString, artist_ptr > s_artistsByName;
|
||||
static QHash< unsigned int, artist_ptr > s_artistsById;
|
||||
|
||||
friend class ::IdThreadWorker;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "Album.h"
|
||||
#include "Database.h"
|
||||
#include "DatabaseImpl.h"
|
||||
#include "Source.h"
|
||||
|
||||
#define ID_THREAD_DEBUG 0
|
||||
|
||||
@ -90,10 +91,11 @@ internalGet( const artist_ptr& artist, const album_ptr& album, bool autoCreate,
|
||||
}
|
||||
|
||||
|
||||
boost::unique_future< unsigned int >
|
||||
void
|
||||
IdThreadWorker::getArtistId( const artist_ptr& artist, bool autoCreate )
|
||||
{
|
||||
QueueItem* item = internalGet( artist, album_ptr(), autoCreate, ArtistType );
|
||||
artist->setIdFuture( item->promise.get_future() );
|
||||
|
||||
#if ID_THREAD_DEBUG
|
||||
qDebug() << "QUEUEING ARTIST:" << artist->name();
|
||||
@ -106,15 +108,14 @@ IdThreadWorker::getArtistId( const artist_ptr& artist, bool autoCreate )
|
||||
#if ID_THREAD_DEBUG
|
||||
qDebug() << "DONE WOKE UP THREAD:" << artist->name();
|
||||
#endif
|
||||
|
||||
return item->promise.get_future();
|
||||
}
|
||||
|
||||
|
||||
boost::unique_future< unsigned int >
|
||||
void
|
||||
IdThreadWorker::getAlbumId( const album_ptr& album, bool autoCreate )
|
||||
{
|
||||
QueueItem* item = internalGet( artist_ptr(), album, autoCreate, AlbumType );
|
||||
album->setIdFuture( item->promise.get_future() );
|
||||
|
||||
#if ID_THREAD_DEBUG
|
||||
qDebug() << "QUEUEING ALUBM:" << album->artist()->name() << album->name();
|
||||
@ -126,8 +127,6 @@ IdThreadWorker::getAlbumId( const album_ptr& album, bool autoCreate )
|
||||
#if ID_THREAD_DEBUG
|
||||
qDebug() << "DONE WOKE UP THREAD:" << album->artist()->name() << album->name();
|
||||
#endif
|
||||
|
||||
return item->promise.get_future();
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,8 +42,8 @@ public:
|
||||
void run();
|
||||
void stop();
|
||||
|
||||
static boost::unique_future< unsigned int > getArtistId( const Tomahawk::artist_ptr& artist, bool autoCreate = false );
|
||||
static boost::unique_future< unsigned int > getAlbumId( const Tomahawk::album_ptr& album, bool autoCreate = false );
|
||||
static void getArtistId( const Tomahawk::artist_ptr& artist, bool autoCreate = false );
|
||||
static void getAlbumId( const Tomahawk::album_ptr& album, bool autoCreate = false );
|
||||
|
||||
private:
|
||||
Database* m_db;
|
||||
|
Loading…
x
Reference in New Issue
Block a user