diff options
Diffstat (limited to 'llvm/unittests/Support/ThreadPool.cpp')
-rw-r--r-- | llvm/unittests/Support/ThreadPool.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/unittests/Support/ThreadPool.cpp b/llvm/unittests/Support/ThreadPool.cpp index d36341e425d..5457cdc1c68 100644 --- a/llvm/unittests/Support/ThreadPool.cpp +++ b/llvm/unittests/Support/ThreadPool.cpp @@ -44,6 +44,20 @@ TEST(ThreadPoolTest, AsyncBarrier) { ASSERT_EQ(5, checked_in); } +static void TestFunc(std::atomic_int &checked_in, int i) { checked_in += i; } + +TEST(ThreadPoolTest, AsyncBarrierArgs) { + // Test that async works with a function requiring multiple parameters. + std::atomic_int checked_in{0}; + + ThreadPool Pool; + for (size_t i = 0; i < 5; ++i) { + Pool.async(TestFunc, std::ref(checked_in), i); + } + Pool.wait(); + ASSERT_EQ(10, checked_in); +} + TEST(ThreadPoolTest, Async) { ThreadPool Pool; std::atomic_int i{0}; |