summaryrefslogtreecommitdiffstats
path: root/common/threadboundary.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/threadboundary.h')
-rw-r--r--common/threadboundary.h36
1 files changed, 17 insertions, 19 deletions
diff --git a/common/threadboundary.h b/common/threadboundary.h
index d73bdae..0d8ed3b 100644
--- a/common/threadboundary.h
+++ b/common/threadboundary.h
@@ -24,24 +24,22 @@
24#include <functional> 24#include <functional>
25 25
26namespace async { 26namespace async {
27 /*
28 * A helper class to invoke a method in a different thread using the event loop.
29 * The ThreadBoundary object must live in the thread where the function should be called.
30 */
31 class ThreadBoundary : public QObject {
32 Q_OBJECT
33 public:
34 ThreadBoundary();
35 virtual ~ThreadBoundary();
36 27
37 //Call in worker thread 28/*
38 void callInMainThread(std::function<void()> f) { 29* A helper class to invoke a method in a different thread using the event loop.
39 QMetaObject::invokeMethod(this, "runInMainThread", Qt::QueuedConnection, QGenericReturnArgument(), Q_ARG(std::function<void()>, f)); 30* The ThreadBoundary object must live in the thread where the function should be called.
40 } 31*/
41 public slots: 32class ThreadBoundary : public QObject {
42 //Get's called in main thread by it's eventloop 33 Q_OBJECT
43 void runInMainThread(std::function<void()> f) { 34public:
44 f(); 35 ThreadBoundary();
45 } 36 virtual ~ThreadBoundary();
46 }; 37
38 //Call in worker thread
39 void callInMainThread(std::function<void()> f);
40public slots:
41 //Get's called in main thread by it's eventloop
42 void runInMainThread(std::function<void()> f);
43};
44
47} 45}