From 6bfbd9b12911025bebc41b715667ba1cd6863c25 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Sat, 18 Feb 2023 19:27:19 +0800 Subject: feat: implement concurrent task in a proper way --- src/core/thread/Task.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/core/thread/Task.cpp') diff --git a/src/core/thread/Task.cpp b/src/core/thread/Task.cpp index 937211cf..f3c6ae86 100644 --- a/src/core/thread/Task.cpp +++ b/src/core/thread/Task.cpp @@ -160,10 +160,18 @@ void GpgFrontend::Thread::Task::run() { if (thread() != QThread::currentThread()) { SPDLOG_DEBUG("task running thread is not object living thread"); - // running in another thread, blocking until returned - if (!QMetaObject::invokeMethod(thread(), runnable_package, - Qt::BlockingQueuedConnection)) { - SPDLOG_ERROR("qt invoke method failed"); + // if running sequently + if (sequency_) { + // running in another thread, blocking until returned + if (!QMetaObject::invokeMethod(thread(), runnable_package, + Qt::BlockingQueuedConnection)) { + SPDLOG_ERROR("qt invoke method failed"); + } + } else { + // running in another thread, non-blocking + if (!QMetaObject::invokeMethod(thread(), runnable_package)) { + SPDLOG_ERROR("qt invoke method failed"); + } } } else { if (!QMetaObject::invokeMethod(this, runnable_package)) { -- cgit v1.2.3