summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2015-12-15 04:44:02 +0000
committerTeresa Johnson <tejohnson@google.com>2015-12-15 04:44:02 +0000
commitf064d62279da574760725e86450b08dc627a9f3e (patch)
tree2a8f78069aac0c8e481524dec5caf0e8148cb76c /llvm/unittests
parent20447ce00e772b572a23df435feed1ce24c3ecef (diff)
downloadbcm5719-llvm-f064d62279da574760725e86450b08dc627a9f3e.tar.gz
bcm5719-llvm-f064d62279da574760725e86450b08dc627a9f3e.zip
Fix template parameter pack handling in ThreadPool
Fixes passing of template parameter pack via std::forward and add unittest. llvm-svn: 255617
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/Support/ThreadPool.cpp14
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};
OpenPOWER on IntegriCloud