qt6-bb10/tests/auto/corelib/thread
Marc Mutz 44d4d2593c tst_QPromise: don't rely on move-only lambdas
VxWorks, at least as used in the 6.8 CI, has a problem with move-only
lambdas passed to QThread::create(). This might have been the reason
for the resurrection of the cxx11_future feature in
408430a543ef605157963b1a894847c7ba9f9956.

This patch tries to work around the issue by not moving the promise
into the lambda capture, but caputuring it by reference, and then
moving it into a local stack variable. In all cases, the ThreadWrapper
is created after the promise, so, since the ThreadWrapper dtor join()s
(like jthread), the promise out-lives the thread, and the destruction
of the promise happens-after the join() with the thread. So, no data
races. Code mustn't touch the promise object from the main thread once
the ThreadWrapper has started, but that's the case already and the
test functions are small enough for any such future use to be obvious
in review.

Amends 385f0732d9 and
4e1b20893aeeb9580bc6b52ac4baea297675bfee.

It appears that dev no longer has the problem¹, but apply this to dev,
too, to maintain consistency with the test in last three LTS releases.

¹ 4e1b20893aeeb9580bc6b52ac4baea297675bfee passed, but its cherry-pick
  to 6.8 did not

Pick-to: 6.5 6.2
Change-Id: If1feba9d3a7f8677789d45fa9f4990cf44145709
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 4d6cf54664a98e01d4caab42431c62d6deb9f86e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-05 18:53:16 +00:00
..
qatomicint Change license for tests files 2024-02-04 09:56:42 +01:00
qatomicinteger Change license for tests files 2024-02-04 09:56:42 +01:00
qatomicpointer Change license for tests files 2024-02-04 09:56:42 +01:00
qfuture Skip tst_QFuture::whenAllDifferentTypes and whenAnyDifferentTypes on VxWorks 2024-06-20 19:30:41 +00:00
qfuturesynchronizer Change license for tests files 2024-02-04 09:56:42 +01:00
qfuturewatcher Tests: Reduce the number of module includes 2024-11-04 19:42:27 +00:00
qmutex tst_QMutex[qnx]: increase system timer resolution 2024-03-12 14:23:57 +01:00
qmutexlocker Change license for tests files 2024-02-04 09:56:42 +01:00
qpromise tst_QPromise: don't rely on move-only lambdas 2024-11-05 18:53:16 +00:00
qreadlocker Change license for tests files 2024-02-04 09:56:42 +01:00
qreadwritelock Change license for tests files 2024-02-04 09:56:42 +01:00
qresultstore QtPrivate::ResultIteratorBase: use modernize comparisons 2024-05-14 00:32:35 +02:00
qsemaphore Change license for tests files 2024-02-04 09:56:42 +01:00
qthread tst_QThread: add a test for multiple threads wait()ing for one 2024-11-02 16:25:06 +00:00
qthreadonce Change license for tests files 2024-02-04 09:56:42 +01:00
qthreadpool QThreadPool: fix regression with negative expiryTimeout 2024-10-15 12:45:00 +00:00
qthreadstorage Change license for tests files 2024-02-04 09:56:42 +01:00
qwaitcondition Change license for tests files 2024-02-04 09:56:42 +01:00
qwritelocker Change license for tests files 2024-02-04 09:56:42 +01:00
CMakeLists.txt Fix test compilation issues with QtLite configuration 2024-05-06 14:29:02 +00:00