Conditionally disable code snippets that depend on cxx11_future

Fixes: QTBUG-88392
Change-Id: Ida215253fdcad66a5a67084d3ff6781583101859
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
This commit is contained in:
Sona Kurazyan 2020-11-13 14:09:15 +01:00
parent 1c4ddbafbb
commit 2bce62a318

View File

@ -71,6 +71,7 @@ public:
void snippet_QPromise::basicExample()
{
#if QT_CONFIG(cxx11_future)
//! [basic]
QPromise<int> promise;
QFuture<int> future = promise.future();
@ -88,10 +89,12 @@ void snippet_QPromise::basicExample()
QCOMPARE(future.result(), 42);
thread->wait();
#endif
}
void snippet_QPromise::multithreadExample()
{
#if QT_CONFIG(cxx11_future)
//! [multithread_init]
QSharedPointer<QPromise<int>> sharedPromise(new QPromise<int>());
QFuture<int> future = sharedPromise->future();
@ -133,10 +136,12 @@ void snippet_QPromise::multithreadExample()
for (auto& t : threads)
t->wait();
sharedPromise->finish();
#endif
}
void snippet_QPromise::suspendExample()
{
#if QT_CONFIG(cxx11_future)
//! [suspend_start]
// Create promise and future
QPromise<int> promise;
@ -194,4 +199,5 @@ void snippet_QPromise::suspendExample()
QList<int> expected(100);
std::iota(expected.begin(), expected.end(), 0);
QCOMPARE(future.results(), expected);
#endif
}