4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
17 #include <QWaitCondition>
19 #include "support/bind.h"
20 #include "support/functional.h"
26 class IntoGuiThreadMover : public QObject
34 void callInGuiThread();
37 void triggerFunctionCall();
40 void doFunctionCall();
43 virtual void synchronousFunctionCall() = 0;
45 QWaitCondition condition_;
51 class InGuiThread : private IntoGuiThreadMover
55 // please coverity by explicitly initializing this variable.
56 InGuiThread() : return_value_(R()) {}
66 template<class F, class P1>
69 return call(lyx::bind(f, lyx::ref(p1)));
72 template<class F, class P1, class P2>
73 R call(F f, P1& p1, P2& p2)
75 return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2)));
78 template<class F, class P1, class P2, class P3>
79 R call(F f, P1& p1, P2& p2, P3& p3)
81 return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3)));
84 template<class F, class P1, class P2, class P3, class P4>
85 R call(F f, P1& p1, P2& p2, P3& p3, P4& p4)
87 return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4)));
94 template<class F, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
95 R call(F f, P1& p1, P2& p2, P3& p3, P4& p4, P5& p5, P6& p6, P7& p7, P8& p8)
97 return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4),
98 lyx::ref(p5), lyx::ref(p6), lyx::ref(p7), lyx::ref(p8)));
103 void synchronousFunctionCall() override
105 return_value_ = func_();
114 // void specialisation
116 class InGuiThread<void> : private IntoGuiThreadMover
129 template<class F, class P1>
130 void call(F f, P1& p1)
132 call(lyx::bind(f, lyx::ref(p1)));
135 template<class F, class P1, class P2>
136 void call(F f, P1& p1, P2& p2)
138 call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2)));
141 template<class F, class P1, class P2, class P3>
142 void call(F f, P1& p1, P2& p2, P3& p3)
144 call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3)));
147 template<class F, class P1, class P2, class P3, class P4>
148 void call(F f, P1& p1, P2& p2, P3& p3, P4& p4)
150 call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4)));
157 template<class F, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
158 void call(F f, P1& p1, P2& p2, P3& p3, P4& p4, P5& p5, P6& p6, P7& p7, P8& p8)
160 call(bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4), lyx::ref(p5),
161 lyx::ref(p6), lyx::ref(p7), lyx::ref(p8)));
166 void synchronousFunctionCall() override
172 function<void()> func_;
176 } // namespace frontend
179 #endif // INGUITHREAD_H