mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 07:27:22 -06:00
Avoid heavy weight function object
Also, by switching to template we can avoid the cost of converting to some specific type and perfectly forward the parameter to the final function. PR #21572.
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include <QMap>
|
||||
#include <QPointer>
|
||||
#include <QSet>
|
||||
#include <QThreadPool>
|
||||
|
||||
#include "base/path.h"
|
||||
#include "base/settingvalue.h"
|
||||
@@ -57,7 +58,6 @@
|
||||
#include "trackerentrystatus.h"
|
||||
|
||||
class QString;
|
||||
class QThreadPool;
|
||||
class QTimer;
|
||||
class QUrl;
|
||||
|
||||
@@ -482,7 +482,11 @@ namespace BitTorrent
|
||||
QMetaObject::invokeMethod(this, std::forward<Func>(func), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void invokeAsync(std::function<void ()> func);
|
||||
template <typename Func>
|
||||
void invokeAsync(Func &&func)
|
||||
{
|
||||
m_asyncWorker->start(std::forward<Func>(func));
|
||||
}
|
||||
|
||||
signals:
|
||||
void addTorrentAlertsReceived(qsizetype count);
|
||||
|
||||
Reference in New Issue
Block a user