mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 11:02:59 +02:00
Fix template parameter pack handling in ThreadPool
Fixes passing of template parameter pack via std::forward and add unittest. llvm-svn: 255617
This commit is contained in:
parent
348c97685c
commit
ff38b7b132
@ -66,7 +66,7 @@ public:
|
||||
template <typename Function, typename... Args>
|
||||
inline std::shared_future<VoidTy> async(Function &&F, Args &&... ArgList) {
|
||||
auto Task =
|
||||
std::bind(std::forward<Function>(F), std::forward<Args...>(ArgList...));
|
||||
std::bind(std::forward<Function>(F), std::forward<Args>(ArgList)...);
|
||||
#ifndef _MSC_VER
|
||||
return asyncImpl(std::move(Task));
|
||||
#else
|
||||
|
@ -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};
|
||||
|
Loading…
Reference in New Issue
Block a user