Skip to content

Commit 63b1f6d

Browse files
committed
Add unit test
1 parent 5f2890b commit 63b1f6d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llvm/unittests/Support/ThreadPool.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,20 @@ TYPED_TEST(ThreadPoolTest, Async) {
183183
ASSERT_EQ(2, i.load());
184184
}
185185

186+
TYPED_TEST(ThreadPoolTest, AsyncMoveOnly) {
187+
CHECK_UNSUPPORTED();
188+
DefaultThreadPool Pool;
189+
std::promise<int> p;
190+
std::future<int> f = p.get_future();
191+
Pool.async([this, p = std::move(p)] {
192+
this->waitForMainThread();
193+
p.set_value(42);
194+
});
195+
this->setMainThreadReady();
196+
Pool.wait();
197+
ASSERT_EQ(42, f.get());
198+
}
199+
186200
TYPED_TEST(ThreadPoolTest, GetFuture) {
187201
CHECK_UNSUPPORTED();
188202
DefaultThreadPool Pool(hardware_concurrency(2));

0 commit comments

Comments
 (0)