diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-15 06:59:06 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-15 07:12:13 +0200 |
commit | 77115bab30aa789f9af9fe49006e8747488f8a4c (patch) | |
tree | 5a370c6f25fdce3396d8172b509306f8f501d34f /common/threadboundary.cpp | |
parent | bb70bdcd0eaf72ffc304536267a66c5de5eaf2e9 (diff) | |
download | sink-77115bab30aa789f9af9fe49006e8747488f8a4c.tar.gz sink-77115bab30aa789f9af9fe49006e8747488f8a4c.zip |
Moved thread-boundary crossing to the model.
That way we avoid any unnecessary queuing for the sync API,
and enable fine-tuning in the model code at a later stage.
Diffstat (limited to 'common/threadboundary.cpp')
-rw-r--r-- | common/threadboundary.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/common/threadboundary.cpp b/common/threadboundary.cpp index 705009b..22864dd 100644 --- a/common/threadboundary.cpp +++ b/common/threadboundary.cpp | |||
@@ -19,6 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "threadboundary.h" | 21 | #include "threadboundary.h" |
22 | #include <QThread> | ||
22 | 23 | ||
23 | Q_DECLARE_METATYPE(std::function<void()>); | 24 | Q_DECLARE_METATYPE(std::function<void()>); |
24 | 25 | ||
@@ -39,7 +40,11 @@ void ThreadBoundary::callInMainThread(std::function<void()> f) | |||
39 | * than the target thread is able to execute the function calls. In that case any captures will equally pile up, resulting | 40 | * than the target thread is able to execute the function calls. In that case any captures will equally pile up, resulting |
40 | * in significant memory usage i.e. due to Emitter::addHandler calls that each capture a domain object. | 41 | * in significant memory usage i.e. due to Emitter::addHandler calls that each capture a domain object. |
41 | */ | 42 | */ |
42 | QMetaObject::invokeMethod(this, "runInMainThread", Qt::QueuedConnection, QGenericReturnArgument(), Q_ARG(std::function<void()>, f)); | 43 | if (QThread::currentThread() == this->thread()) { |
44 | f(); | ||
45 | } else { | ||
46 | QMetaObject::invokeMethod(this, "runInMainThread", Qt::QueuedConnection, QGenericReturnArgument(), Q_ARG(std::function<void()>, f)); | ||
47 | } | ||
43 | } | 48 | } |
44 | 49 | ||
45 | void ThreadBoundary::runInMainThread(std::function<void()> f) | 50 | void ThreadBoundary::runInMainThread(std::function<void()> f) |