From e83392da4de386127ad92ae1e73b38404951da56 Mon Sep 17 00:00:00 2001 From: chanme <403567116@qq.com> Date: Fri, 9 Oct 2015 17:28:00 +0800 Subject: [PATCH] just for test for commit --- example2.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 example2.cpp diff --git a/example2.cpp b/example2.cpp new file mode 100644 index 0000000..837277b --- /dev/null +++ b/example2.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +#include "ThreadPool.h" + +int main() +{ + + ThreadPool pool(4); + std::vector< std::future > results; + + for(int i = 0; i < 8; ++i) { + results.emplace_back( + pool.enqueue([i] { + std::cout << "hello " << i << std::endl; + std::this_thread::sleep_for(std::chrono::seconds(1)); + std::cout << "world " << i << std::endl; + return i*i; + }) + ); + } + + for(auto && result: results) + std::cout << result.get() << ' '; + std::cout << std::endl; + + return 0; +}