From ab8b0aa3a48267f2c34b1f5fe8e6569515bf9969 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Mon, 15 Jun 2015 22:26:07 +0200 Subject: [PATCH] Run more stuff in parallel. --- tests/threaded.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/threaded.cpp b/tests/threaded.cpp index f4ca1bb..7c38891 100644 --- a/tests/threaded.cpp +++ b/tests/threaded.cpp @@ -1,5 +1,6 @@ #include #include +#include using namespace std; @@ -14,27 +15,28 @@ int** alloc() return block; } -bool dealloc(future&& f) +void dealloc(future&& f) { int** block = f.get(); for (int i = 0; i < ALLOCS_PER_THREAD; ++i) { delete block[i]; } delete[] block; - return true; } int main() { + vector> futures; + futures.reserve(100 * 4); for (int i = 0; i < 100; ++i) { auto f1 = async(launch::async, alloc); auto f2 = async(launch::async, alloc); auto f3 = async(launch::async, alloc); auto f4 = async(launch::async, alloc); - auto f5 = async(launch::async, dealloc, move(f1)); - auto f6 = async(launch::async, dealloc, move(f2)); - auto f7 = async(launch::async, dealloc, move(f3)); - auto f8 = async(launch::async, dealloc, move(f4)); + futures.emplace_back(async(launch::async, dealloc, move(f1))); + futures.emplace_back(async(launch::async, dealloc, move(f2))); + futures.emplace_back(async(launch::async, dealloc, move(f3))); + futures.emplace_back(async(launch::async, dealloc, move(f4))); } return 0; } -- 2.7.4