Use global threadpool

This commit is contained in:
Nicolas Werner 2021-12-21 15:57:46 +01:00
parent 8edc46dc16
commit 1ea9dc469b
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 7 additions and 18 deletions

View file

@ -34,12 +34,12 @@ private:
class BlurhashResponse : public QQuickImageResponse class BlurhashResponse : public QQuickImageResponse
{ {
public: public:
BlurhashResponse(const QString &id, const QSize &requestedSize, QThreadPool *pool) BlurhashResponse(const QString &id, const QSize &requestedSize)
{ {
auto runnable = new BlurhashRunnable(id, requestedSize); auto runnable = new BlurhashRunnable(id, requestedSize);
connect(runnable, &BlurhashRunnable::done, this, &BlurhashResponse::handleDone); connect(runnable, &BlurhashRunnable::done, this, &BlurhashResponse::handleDone);
connect(runnable, &BlurhashRunnable::error, this, &BlurhashResponse::handleError); connect(runnable, &BlurhashRunnable::error, this, &BlurhashResponse::handleError);
pool->start(runnable); QThreadPool::globalInstance()->start(runnable);
} }
QQuickTextureFactory *textureFactory() const override QQuickTextureFactory *textureFactory() const override
@ -72,9 +72,6 @@ public slots:
QQuickImageResponse * QQuickImageResponse *
requestImageResponse(const QString &id, const QSize &requestedSize) override requestImageResponse(const QString &id, const QSize &requestedSize) override
{ {
return new BlurhashResponse(id, requestedSize, &pool); return new BlurhashResponse(id, requestedSize);
} }
private:
QThreadPool pool;
}; };

View file

@ -70,12 +70,11 @@ clipRadius(QPixmap img, double radius)
JdenticonResponse::JdenticonResponse(const QString &key, JdenticonResponse::JdenticonResponse(const QString &key,
bool crop, bool crop,
double radius, double radius,
const QSize &requestedSize, const QSize &requestedSize)
QThreadPool *pool)
{ {
auto runnable = new JdenticonRunnable(key, crop, radius, requestedSize); auto runnable = new JdenticonRunnable(key, crop, radius, requestedSize);
connect(runnable, &JdenticonRunnable::done, this, &JdenticonResponse::handleDone); connect(runnable, &JdenticonRunnable::done, this, &JdenticonResponse::handleDone);
pool->start(runnable); QThreadPool::globalInstance()->start(runnable);
} }
JdenticonRunnable::JdenticonRunnable(const QString &key, JdenticonRunnable::JdenticonRunnable(const QString &key,

View file

@ -36,11 +36,7 @@ private:
class JdenticonResponse : public QQuickImageResponse class JdenticonResponse : public QQuickImageResponse
{ {
public: public:
JdenticonResponse(const QString &key, JdenticonResponse(const QString &key, bool crop, double radius, const QSize &requestedSize);
bool crop,
double radius,
const QSize &requestedSize,
QThreadPool *pool);
QQuickTextureFactory *textureFactory() const override QQuickTextureFactory *textureFactory() const override
{ {
@ -86,9 +82,6 @@ public slots:
} }
} }
return new JdenticonResponse(id_, crop, radius, requestedSize, &pool); return new JdenticonResponse(id_, crop, radius, requestedSize);
} }
private:
QThreadPool pool;
}; };