Fix template parameter pack handling in ThreadPool
[oota-llvm.git] / unittests / Support / ThreadPool.cpp
index d36341e425df72b1defd0ecee771a358a333243c..5457cdc1c683aea6fb55c17a671e45ec0dce3bff 100644 (file)
@@ -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};