This is a C++11 port based on the fast thread pool from Martin Vorbrodt.
From his great blog posts:
Just drop src/threadpool to your project
thread_pool pool;
auto work = [](const char *name) {
printf("Hello %s!\n", name);
};
auto task = [](int a, int b) {
return a + b;
};
pool.enqueue_work(work, "work");
auto result = pool.enqueue_task(task, 2, 3);
printf("Result: %d\n", result.get());
Note that work is 5-10x faster than task.