aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/thread/Task.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2023-02-18 11:27:19 +0000
committerSaturneric <[email protected]>2023-02-18 11:27:19 +0000
commit6bfbd9b12911025bebc41b715667ba1cd6863c25 (patch)
tree9099a5c04319bc6c5ea912847b11ff3e15f36d9c /src/core/thread/Task.cpp
parentfix: improve the task execution model (diff)
downloadGpgFrontend-6bfbd9b12911025bebc41b715667ba1cd6863c25.tar.gz
GpgFrontend-6bfbd9b12911025bebc41b715667ba1cd6863c25.zip
feat: implement concurrent task in a proper way
Diffstat (limited to 'src/core/thread/Task.cpp')
-rw-r--r--src/core/thread/Task.cpp16
1 files changed, 12 insertions, 4 deletions
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)) {