Over on github I uploaded a more advanced version of the ThreadPool
class from the Thread Pool with C++11 entry. It allows to get std::future
s as return values of the enqueue method.
Example usage:
ThreadPool pool(4); std::future<std::string> str = pool.enqueue<std::string>( []() { return "hello world"; } ); std::future<int> x = pool.enqueue<int>( []() { return 42; } ); std::cout << str.get() << ' ' << x.get() << std::endl;