qt5base-lts/tests/auto/corelib/thread
Marc Mutz c55aec2ed7 QFutureInterface: allow to work with a QThreadPool != globalInstance()
Background:
It is often necessary/advisable to schedule tasks on thread pools !=
globalInstance(). As Herb Sutter writes in
http://www.drdobbs.com/parallel/use-thread-pools-correctly-keep-tasks-sh/216500409
and the Qt Training Material stresses, tasks you schedule on a (global)
thread pool should be non-blocking, which currently rules out using any of
the QtConcurrent functions for, say, file I/O.

Nonetheless it's often convenient to have thread pools also for file I/O, as
the thumbnail viewer exercise in the Qt Training Material shows. In this
case, you'd use a dedicated thead pool, leaving the global thread pool for
CPU-bound tasks.

Yet, none of the QtConcurrent functions allow to pick the QThreadPool
instance on which to schedule the work created with them.

This patch prepares for them to do so.

This is the first part of the forward-port of
https://qt.gitorious.org/qt/qt/merge_requests/1281.

Implement by using a new QThreadPool* member that defaults to nullptr,
and adding setThreadPool to set this member, then using it in lieu of
QThreadPool::globalInstance() everywhere.

I chose to leave m_pool == nullptr to mean globalInstance() to avoid
creating the global instance whenever a QFuture is created, even if the
future represents the result of a calculation not run on the global thread
pool.

[ChangeLog][QtCore][QFuture] Can now be used with any QThreadPool, not
just globalInstance().

Task-number: QTBUG-17220
Change-Id: I4e1dc18d55cf60141b2fa3d14e2d44a3e9e74858
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2014-08-05 18:04:56 +02:00
..
qatomicint Add a testAndSet overload to the atomics that returns the current value 2014-02-16 05:12:26 +01:00
qatomicinteger Remove use of templates in tst_qatomicinteger. 2014-03-04 15:59:05 +01:00
qatomicpointer Add a testAndSet overload to the atomics that returns the current value 2014-02-16 05:12:26 +01:00
qfuture QFutureInterface: allow to work with a QThreadPool != globalInstance() 2014-08-05 18:04:56 +02:00
qfuturesynchronizer Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qfuturewatcher Updated corelib's unit tests to use QSignalSpy's functor constructor 2014-05-08 04:22:54 +02:00
qmutex tst_QMutex: fix a race 2013-09-23 02:47:49 +02:00
qmutexlocker Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qreadlocker Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qreadwritelock Fix test compilation on WinRT 2013-11-26 20:29:09 +01:00
qresultstore Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qsemaphore Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qthread winrt: Use native threading 2014-06-25 16:34:39 +02:00
qthreadonce Remove QT_{BEGIN,END}_HEADER macro usage 2013-01-29 01:06:04 +01:00
qthreadpool Skip unstable autotests in QtBase. 2014-07-02 09:28:34 +02:00
qthreadstorage WinRT: Fix various test compilations 2013-10-02 12:36:05 +02:00
qwaitcondition Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qwritelocker Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
thread.pro Replace the type-based QAtomicIntegerTraits with a size-based one 2014-01-30 18:06:27 +01:00