|
|
@ -17,9 +17,9 @@ TEST(ConcurrentRunTest, ConcurrentRun0StartAndWait) { |
|
|
|
QThreadPool threadpool; |
|
|
|
QFuture<int> future = ConcurrentRun::Run<int>(&threadpool, &f); |
|
|
|
QFutureWatcher<int> watcher; |
|
|
|
watcher.setFuture(future); |
|
|
|
QEventLoop loop; |
|
|
|
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); |
|
|
|
watcher.setFuture(future); |
|
|
|
loop.exec(); |
|
|
|
EXPECT_EQ(1337, watcher.result()); |
|
|
|
} |
|
|
@ -33,9 +33,9 @@ TEST(ConcurrentRunTest, ConcurrentRun1StartAndWait) { |
|
|
|
int i = 1336; |
|
|
|
QFuture<int> future = ConcurrentRun::Run<int, int>(&threadpool, &g, i); |
|
|
|
QFutureWatcher<int> watcher; |
|
|
|
watcher.setFuture(future); |
|
|
|
QEventLoop loop; |
|
|
|
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); |
|
|
|
watcher.setFuture(future); |
|
|
|
loop.exec(); |
|
|
|
EXPECT_EQ(1337, watcher.result()); |
|
|
|
} |
|
|
@ -50,9 +50,9 @@ TEST(ConcurrentRunTest, ConcurrentRun2StartAndWait) { |
|
|
|
QThreadPool threadpool; |
|
|
|
QFuture<int> future = ConcurrentRun::Run<int, int, int>(&threadpool, &max, i, j); |
|
|
|
QFutureWatcher<int> watcher; |
|
|
|
watcher.setFuture(future); |
|
|
|
QEventLoop loop; |
|
|
|
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); |
|
|
|
watcher.setFuture(future); |
|
|
|
loop.exec(); |
|
|
|
EXPECT_EQ(42, watcher.result()); |
|
|
|
} |
|
|
@ -68,9 +68,9 @@ TEST(ConcurrentRunTest, ConcurrentRun3StartAndWait) { |
|
|
|
QThreadPool threadpool; |
|
|
|
QFuture<int> future = ConcurrentRun::Run<int, int, int, int>(&threadpool, &sum, i, j, k); |
|
|
|
QFutureWatcher<int> watcher; |
|
|
|
watcher.setFuture(future); |
|
|
|
QEventLoop loop; |
|
|
|
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); |
|
|
|
watcher.setFuture(future); |
|
|
|
loop.exec(); |
|
|
|
EXPECT_EQ(102, watcher.result()); |
|
|
|
} |
|
|
@ -95,9 +95,9 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidFunction1Start) { |
|
|
|
int n = 10; |
|
|
|
QFuture<void> future = ConcurrentRun::Run<void, int*>(&threadpool, &aFunction, &n); |
|
|
|
QFutureWatcher<void> watcher; |
|
|
|
watcher.setFuture(future); |
|
|
|
QEventLoop loop; |
|
|
|
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); |
|
|
|
watcher.setFuture(future); |
|
|
|
loop.exec(); |
|
|
|
EXPECT_EQ(1337, n); |
|
|
|
} |
|
|
@ -108,9 +108,9 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidFunction2Start) { |
|
|
|
int n = 10, m = 11; |
|
|
|
QFuture<void> future = ConcurrentRun::Run<void, int*, int*>(&threadpool, &bFunction, &n, &m); |
|
|
|
QFutureWatcher<void> watcher; |
|
|
|
watcher.setFuture(future); |
|
|
|
QEventLoop loop; |
|
|
|
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); |
|
|
|
watcher.setFuture(future); |
|
|
|
loop.exec(); |
|
|
|
EXPECT_EQ(1337, n); |
|
|
|
EXPECT_EQ(1338, m); |
|
|
@ -122,9 +122,9 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidFunction3Start) { |
|
|
|
int n = 10, m = 11, o = 12; |
|
|
|
QFuture<void> future = ConcurrentRun::Run<void, int*, int*, int*>(&threadpool, &cFunction, &n, &m, &o); |
|
|
|
QFutureWatcher<void> watcher; |
|
|
|
watcher.setFuture(future); |
|
|
|
QEventLoop loop; |
|
|
|
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); |
|
|
|
watcher.setFuture(future); |
|
|
|
loop.exec(); |
|
|
|
EXPECT_EQ(1337, n); |
|
|
|
EXPECT_EQ(1338, m); |
|
|
@ -145,9 +145,9 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidBindFunctionStart) { |
|
|
|
int nb = 10; |
|
|
|
QFuture<void> future = ConcurrentRun::Run<void>(&threadpool, std::bind(&A::f, &a, &nb)); |
|
|
|
QFutureWatcher<void> watcher; |
|
|
|
watcher.setFuture(future); |
|
|
|
QEventLoop loop; |
|
|
|
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); |
|
|
|
watcher.setFuture(future); |
|
|
|
loop.exec(); |
|
|
|
EXPECT_EQ(11, nb); |
|
|
|
} |
|
|
|