Skip to content

Commit

Permalink
Conditionally disable code snippets that depend on cxx11_future
Browse files Browse the repository at this point in the history
Fixes: QTBUG-88392
Change-Id: Ida215253fdcad66a5a67084d3ff6781583101859
Reviewed-by: Tony Sarajärvi <[email protected]>
  • Loading branch information
Sona Kurazyan committed Nov 13, 2020
1 parent 1c4ddba commit 2bce62a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class snippet_QPromise

void snippet_QPromise::basicExample()
{
#if QT_CONFIG(cxx11_future)
//! [basic]
QPromise<int> promise;
QFuture<int> future = promise.future();
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -194,4 +199,5 @@ void snippet_QPromise::suspendExample()
QList<int> expected(100);
std::iota(expected.begin(), expected.end(), 0);
QCOMPARE(future.results(), expected);
#endif
}

0 comments on commit 2bce62a

Please sign in to comment.