#ifndef ASYNC_CALL_H #define ASYNC_CALL_H #include #include #include class DoricAsyncCall { public: static void ensureRunInThreadPool(QThreadPool *threadPool, std::function lambda) { QFuture::result_type> future = QtConcurrent::run(threadPool, lambda); } template static void ensureRunInMain(Function &&function, QThread *thread = qApp->thread()) { auto *obj = QAbstractEventDispatcher::instance(thread); Q_ASSERT(obj); QMetaObject::invokeMethod(obj, std::forward(function)); } }; #endif // ASYNC_CALL_H