Skip to content

Commit 6f2c015

Browse files
authored
Thread/ThreadPool: Unit test waitUntilFinished
1 parent f4100e2 commit 6f2c015

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/Thread/ThreadPool.mpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import CppUtils;
66
export namespace CppUtils::UnitTest::Thread::ThreadPool
77
{
88
inline auto _ = CppUtils::UnitTest::TestSuite{"Thread/ThreadPool", {"UnitTest"}, [](auto& suite) {
9+
using namespace std::chrono_literals;
910
using Logger = CppUtils::Logger<"CppUtils">;
1011

1112
suite.addTest("0 task / 1 thread", [&] {
@@ -40,6 +41,19 @@ export namespace CppUtils::UnitTest::Thread::ThreadPool
4041
called = true;
4142
});
4243
}
44+
std::this_thread::sleep_for(50ms);
45+
suite.expect(called);
46+
});
47+
48+
suite.addTest("waitUntilFinished", [&] {
49+
auto called = std::atomic_bool{false};
50+
{
51+
auto threadPool = CppUtils::Thread::ThreadPool{};
52+
threadPool.call([&called] {
53+
called = true;
54+
});
55+
threadPool.waitUntilFinished();
56+
}
4357
suite.expect(called);
4458
});
4559

0 commit comments

Comments
 (0)