From 0d0ad598c54652dbe04d5716025facd83adc979b Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 15 Sep 2017 17:53:48 +0100 Subject: QThread::create: move implementation out of line Now that we accept STL datatypes in our ABI, expose a factory function that takes a std::future, and hide the QThread subclass in our implementation. This also solves the problem of a non-exported polymorphic class that would generate duplicate vtables / typeinfo in all TUs. Change-Id: I70a5c301e7c589de1a4a189db39b86b956d1ba0d Reviewed-by: Thiago Macieira --- src/corelib/thread/qthread.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/corelib/thread/qthread.cpp') diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 1ec626a53b..e3ba1e4449 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -925,6 +925,30 @@ bool QThread::isInterruptionRequested() const \sa start() */ +#ifdef QTHREAD_HAS_CREATE +class QThreadCreateThread : public QThread +{ +public: + explicit QThreadCreateThread(std::future &&future) + : m_future(std::move(future)) + { + } + +private: + void run() override + { + m_future.get(); + } + + std::future m_future; +}; + +QThread *QThread::createThreadImpl(std::future &&future) +{ + return new QThreadCreateThread(std::move(future)); +} +#endif // QTHREAD_HAS_CREATE + /*! \class QDaemonThread \since 5.5 -- cgit v1.2.3