CMake: remove check for cxx11_future
Everyone must have this by now. This test was 1193 ms of CMake time. Since this was a PUBLIC feature, I've left it around with a constant condition. Change-Id: Ifbf974a4d10745b099b1fffd177754538bbff245 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
f44072ca43
commit
4a5f3c8b93
@ -137,27 +137,6 @@ int pipes[2];
|
||||
}
|
||||
")
|
||||
|
||||
# cxx11_future
|
||||
if (UNIX AND NOT ANDROID AND NOT QNX AND NOT INTEGRITY)
|
||||
set(cxx11_future_TEST_LIBRARIES pthread)
|
||||
endif()
|
||||
qt_config_compile_test(cxx11_future
|
||||
LABEL "C++11 <future>"
|
||||
LIBRARIES
|
||||
"${cxx11_future_TEST_LIBRARIES}"
|
||||
CODE
|
||||
"#include <future>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* BEGIN TEST: */
|
||||
std::future<int> f = std::async([]() { return 42; });
|
||||
(void)f.get();
|
||||
/* END TEST: */
|
||||
return 0;
|
||||
}
|
||||
")
|
||||
|
||||
# cxx17_filesystem
|
||||
qt_config_compile_test(cxx17_filesystem
|
||||
LABEL "C++17 <filesystem>"
|
||||
@ -565,7 +544,7 @@ qt_feature("system-doubleconversion" PRIVATE
|
||||
)
|
||||
qt_feature("cxx11_future" PUBLIC
|
||||
LABEL "C++11 <future>"
|
||||
CONDITION TEST_cxx11_future
|
||||
CONDITION ON
|
||||
)
|
||||
qt_feature("cxx17_filesystem" PUBLIC
|
||||
LABEL "C++17 <filesystem>"
|
||||
|
@ -1201,7 +1201,6 @@ bool QThread::isInterruptionRequested() const
|
||||
\sa start()
|
||||
*/
|
||||
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
class QThreadCreateThread : public QThread
|
||||
{
|
||||
public:
|
||||
@ -1230,7 +1229,6 @@ QThread *QThread::createThreadImpl(std::future<void> &&future)
|
||||
{
|
||||
return new QThreadCreateThread(std::move(future));
|
||||
}
|
||||
#endif // QT_CONFIG(cxx11_future)
|
||||
|
||||
/*!
|
||||
\class QDaemonThread
|
||||
|
@ -9,10 +9,8 @@
|
||||
#include <QtCore/qdeadlinetimer.h>
|
||||
|
||||
// For QThread::create
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
# include <future> // for std::async
|
||||
# include <functional> // for std::invoke; no guard needed as it's a C++98 header
|
||||
#endif
|
||||
#include <future> // for std::async
|
||||
#include <functional> // for std::invoke; no guard needed as it's a C++98 header
|
||||
// internal compiler error with mingw 8.1
|
||||
#if defined(Q_CC_MSVC) && defined(Q_PROCESSOR_X86)
|
||||
#include <intrin.h>
|
||||
@ -70,10 +68,8 @@ public:
|
||||
bool event(QEvent *event) override;
|
||||
int loopLevel() const;
|
||||
|
||||
#if QT_CONFIG(cxx11_future) || defined(Q_QDOC)
|
||||
template <typename Function, typename... Args>
|
||||
[[nodiscard]] static QThread *create(Function &&f, Args &&... args);
|
||||
#endif
|
||||
|
||||
public Q_SLOTS:
|
||||
void start(Priority = InheritPriority);
|
||||
@ -112,16 +108,13 @@ private:
|
||||
Q_DECLARE_PRIVATE(QThread)
|
||||
friend class QEventLoopLocker;
|
||||
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
[[nodiscard]] static QThread *createThreadImpl(std::future<void> &&future);
|
||||
#endif
|
||||
static Qt::HANDLE currentThreadIdImpl() noexcept Q_DECL_PURE_FUNCTION;
|
||||
|
||||
friend class QCoreApplication;
|
||||
friend class QThreadData;
|
||||
};
|
||||
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
template <typename Function, typename... Args>
|
||||
QThread *QThread::create(Function &&f, Args &&... args)
|
||||
{
|
||||
@ -136,7 +129,6 @@ QThread *QThread::create(Function &&f, Args &&... args)
|
||||
std::move(threadFunction),
|
||||
std::forward<Args>(args)...));
|
||||
}
|
||||
#endif // QT_CONFIG(cxx11_future)
|
||||
|
||||
/*
|
||||
On architectures and platforms we know, interpret the thread control
|
||||
|
@ -1342,14 +1342,10 @@ void tst_QTimer::timerOrder_data()
|
||||
|
||||
void tst_QTimer::timerOrderBackgroundThread()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
auto *thread = QThread::create([this]() { timerOrder(); });
|
||||
thread->start();
|
||||
QVERIFY(thread->wait());
|
||||
delete thread;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct StaticSingleShotUser
|
||||
|
@ -9,9 +9,7 @@
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
# include <thread>
|
||||
#endif
|
||||
#include <thread>
|
||||
|
||||
// COM interface
|
||||
#if defined(Q_OS_WIN) && defined(interface)
|
||||
@ -253,14 +251,7 @@ void tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork()
|
||||
QCOMPARE(large.size(), BaseSize + needle.size());
|
||||
qDebug("created dataset in %lld ms", timer.elapsed());
|
||||
|
||||
# if QT_CONFIG(cxx11_future)
|
||||
using MaybeThread = std::thread;
|
||||
# else
|
||||
struct MaybeThread {
|
||||
std::function<void()> func;
|
||||
void join() { func(); }
|
||||
};
|
||||
# endif
|
||||
|
||||
//
|
||||
// WHEN: trying to match an occurrence past the 4GiB mark
|
||||
|
@ -8,9 +8,7 @@
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
# include <thread>
|
||||
#endif
|
||||
#include <thread>
|
||||
|
||||
// COM interface
|
||||
#if defined(interface)
|
||||
@ -264,15 +262,7 @@ void tst_QLatin1StringMatcher::haystacksWithMoreThan4GiBWork()
|
||||
QCOMPARE(large.size(), BaseSize + needle.size());
|
||||
qDebug("created dataset in %lld ms", timer.elapsed());
|
||||
|
||||
# if QT_CONFIG(cxx11_future)
|
||||
using MaybeThread = std::thread;
|
||||
# else
|
||||
struct MaybeThread
|
||||
{
|
||||
std::function<void()> func;
|
||||
void join() { func(); }
|
||||
};
|
||||
# endif
|
||||
|
||||
//
|
||||
// WHEN: trying to match an occurrence past the 4GiB mark
|
||||
|
@ -3908,9 +3908,6 @@ void tst_QFuture::signalConnect()
|
||||
|
||||
void tst_QFuture::waitForFinished()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
QFutureInterface<void> fi;
|
||||
auto future = fi.future();
|
||||
|
||||
@ -3931,7 +3928,6 @@ void tst_QFuture::waitForFinished()
|
||||
|
||||
QVERIFY(waitingThread->wait());
|
||||
QVERIFY(waitingThread->isFinished());
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QFuture::rejectResultOverwrite_data()
|
||||
|
@ -86,7 +86,6 @@ do { \
|
||||
QFAIL("Test case " #test "(" #__VA_ARGS__ ") failed"); \
|
||||
} while (false)
|
||||
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
// std::thread-like wrapper that ensures that the thread is joined at the end of
|
||||
// a scope to prevent potential std::terminate
|
||||
struct ThreadWrapper
|
||||
@ -103,7 +102,6 @@ struct ThreadWrapper
|
||||
t->wait();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void tst_QPromise::promise()
|
||||
{
|
||||
@ -344,9 +342,6 @@ void tst_QPromise::progress()
|
||||
|
||||
void tst_QPromise::addInThread()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
const auto testAddResult = [] (auto promise, const auto &result) {
|
||||
promise.start();
|
||||
auto f = promise.future();
|
||||
@ -362,14 +357,10 @@ void tst_QPromise::addInThread()
|
||||
RUN_TEST_FUNC(testAddResult, QPromise<int>(), 42);
|
||||
RUN_TEST_FUNC(testAddResult, QPromise<QString>(), u8"42");
|
||||
RUN_TEST_FUNC(testAddResult, QPromise<CopyOnlyType>(), CopyOnlyType{99});
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QPromise::addInThreadMoveOnlyObject()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
QPromise<MoveOnlyType> promise;
|
||||
promise.start();
|
||||
auto f = promise.future();
|
||||
@ -381,14 +372,10 @@ void tst_QPromise::addInThreadMoveOnlyObject()
|
||||
// Iterators wait for result first
|
||||
for (auto& result : f)
|
||||
QCOMPARE(result, MoveOnlyType{-11});
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QPromise::reportFromMultipleThreads()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
QPromise<int> promise;
|
||||
auto f = promise.future();
|
||||
promise.start();
|
||||
@ -407,14 +394,10 @@ void tst_QPromise::reportFromMultipleThreads()
|
||||
QVERIFY(std::find(expected.begin(), expected.end(), actual) != expected.end());
|
||||
expected.removeOne(actual);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QPromise::reportFromMultipleThreadsByMovedPromise()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
QPromise<int> initialPromise;
|
||||
auto f = initialPromise.future();
|
||||
{
|
||||
@ -441,14 +424,10 @@ void tst_QPromise::reportFromMultipleThreadsByMovedPromise()
|
||||
QVERIFY(std::find(expected.begin(), expected.end(), actual) != expected.end());
|
||||
expected.removeOne(actual);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QPromise::doNotCancelWhenFinished()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
const auto testFinishedPromise = [] (auto promise) {
|
||||
auto f = promise.future();
|
||||
promise.start();
|
||||
@ -467,15 +446,11 @@ void tst_QPromise::doNotCancelWhenFinished()
|
||||
RUN_TEST_FUNC(testFinishedPromise, QPromise<QString>());
|
||||
RUN_TEST_FUNC(testFinishedPromise, QPromise<CopyOnlyType>());
|
||||
RUN_TEST_FUNC(testFinishedPromise, QPromise<MoveOnlyType>());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_NO_EXCEPTIONS
|
||||
void tst_QPromise::cancelWhenDestroyed()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
QPromise<int> initialPromise;
|
||||
auto f = initialPromise.future();
|
||||
|
||||
@ -503,15 +478,11 @@ void tst_QPromise::cancelWhenDestroyed()
|
||||
QVERIFY(std::find(expected.begin(), expected.end(), actual) != expected.end());
|
||||
expected.removeOne(actual);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void tst_QPromise::cancelWhenReassigned()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
QPromise<int> promise;
|
||||
auto f = promise.future();
|
||||
promise.start();
|
||||
@ -525,7 +496,6 @@ void tst_QPromise::cancelWhenReassigned()
|
||||
|
||||
QCOMPARE(f.isFinished(), true);
|
||||
QCOMPARE(f.isCanceled(), true);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -640,9 +610,6 @@ void tst_QPromise::continuationsRunWhenFinished()
|
||||
|
||||
void tst_QPromise::finishWhenSwapped()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
QPromise<int> promise1;
|
||||
auto f1 = promise1.future();
|
||||
promise1.start();
|
||||
@ -677,15 +644,11 @@ void tst_QPromise::finishWhenSwapped()
|
||||
|
||||
QCOMPARE(f2.resultAt(0), 1);
|
||||
QCOMPARE(f2.resultAt(1), 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void testCancelWhenMoved()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
QPromise<T> promise1;
|
||||
auto f1 = promise1.future();
|
||||
promise1.start();
|
||||
@ -711,7 +674,6 @@ void testCancelWhenMoved()
|
||||
// Future #2 is explicitly finished inside thread
|
||||
QCOMPARE(f2.isFinished(), true);
|
||||
QCOMPARE(f2.isCanceled(), false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QPromise::cancelWhenMoved()
|
||||
@ -753,9 +715,6 @@ void tst_QPromise::waitUntilResumed()
|
||||
|
||||
void tst_QPromise::waitUntilCanceled()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
QPromise<int> promise;
|
||||
promise.start();
|
||||
auto f = promise.future();
|
||||
@ -776,7 +735,6 @@ void tst_QPromise::waitUntilCanceled()
|
||||
f.waitForFinished();
|
||||
|
||||
QCOMPARE(f.resultCount(), 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Below is a quick and dirty hack to make snippets a part of a test suite
|
||||
|
@ -1355,9 +1355,6 @@ void tst_QThread::quitLock()
|
||||
|
||||
void tst_QThread::create()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
{
|
||||
const auto &function = [](){};
|
||||
QScopedPointer<QThread> thread(QThread::create(function));
|
||||
@ -1597,7 +1594,6 @@ void tst_QThread::create()
|
||||
QVERIFY(!thread);
|
||||
}
|
||||
#endif // QT_NO_EXCEPTIONS
|
||||
#endif // QT_CONFIG(cxx11_future)
|
||||
}
|
||||
|
||||
void tst_QThread::createDestruction()
|
||||
|
@ -8,9 +8,7 @@
|
||||
#include <QCryptographicHash>
|
||||
#include <QtCore/QMetaEnum>
|
||||
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
# include <thread>
|
||||
#endif
|
||||
#include <thread>
|
||||
|
||||
Q_DECLARE_METATYPE(QCryptographicHash::Algorithm)
|
||||
|
||||
@ -520,14 +518,7 @@ void tst_QCryptographicHash::moreThan4GiBOfData()
|
||||
{
|
||||
QFETCH(const QCryptographicHash::Algorithm, algorithm);
|
||||
|
||||
# if QT_CONFIG(cxx11_future)
|
||||
using MaybeThread = std::thread;
|
||||
# else
|
||||
struct MaybeThread {
|
||||
std::function<void()> func;
|
||||
void join() { func(); }
|
||||
};
|
||||
# endif
|
||||
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
@ -2820,9 +2820,6 @@ void tst_QHash::QTBUG98265()
|
||||
*/
|
||||
void tst_QHash::detachAndReferences()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires cxx11_future")
|
||||
#else
|
||||
// Repeat a few times because it's not a guarantee
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
QHash<char, char> hash;
|
||||
@ -2860,7 +2857,6 @@ void tst_QHash::detachAndReferences()
|
||||
QVERIFY(hash.contains(kCopy));
|
||||
QCOMPARE(hash.value(kCopy), vCopy);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QHash::lookupUsingKeyIterator()
|
||||
|
@ -318,9 +318,6 @@ private:
|
||||
|
||||
void tst_QObjectRace::blockingQueuedDestroyRace()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
enum { MinIterations = 100, MinTime = 3000, WaitTime = 25 };
|
||||
|
||||
BlockingQueuedDestroyRaceObject sender;
|
||||
@ -366,7 +363,6 @@ void tst_QObjectRace::blockingQueuedDestroyRace()
|
||||
|
||||
thread->wait();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static QAtomicInteger<unsigned> countedStructObjectsCount;
|
||||
|
@ -101,13 +101,9 @@ void qtimer_vs_qmetaobject::bench_data()
|
||||
|
||||
void qtimer_vs_qmetaobject::benchBackgroundThread()
|
||||
{
|
||||
#if !QT_CONFIG(cxx11_future)
|
||||
QSKIP("This test requires QThread::create");
|
||||
#else
|
||||
QScopedPointer<QThread> thread(QThread::create([this]() { bench(); }));
|
||||
thread->start();
|
||||
QVERIFY(thread->wait());
|
||||
#endif
|
||||
}
|
||||
|
||||
QTEST_MAIN(qtimer_vs_qmetaobject)
|
||||
|
Loading…
x
Reference in New Issue
Block a user