I am looking for a thread pool implementation based on C++11 threading facilities. The library should be preferably headers only. License has to be BSD style or MIT style permissive kind of license, i.e., no GPL.


There seems to be a GitHub of someone who developed a small library for C++ 11.

It also is just a central header file (no cpp files to add), and fits into your License requirements (it actually uses a permissive free software license).

|improve this answer|||||

I noticed this question trying to ask the same thing basically, except that I've already noticed a few, and I would like to get a proper recommendation/review of strengths and weaknesses rather than just a list. But for now, here's my list:

  • CTPL - A no-frills single-header-only library; has two variants: one only relying on the standard library, the other using a lock-free queue implementation from Boost. ~250 lines lines at this time.
  • threadpool11 by Tolga Hoşgör - "A fast, lock-free, cross-platform, full CPU utilizing thread pool implementation using C++11 features." claims to beat OpenMP in some benchmark; at the very least it means the author is proud and confident about it rather than just putting it out there... ~590 lines but that's with a lot more boilerplate license etc. So probably something like 500 lines.
  • thread_pool by Tyler Hardin - A single-class, 1 .hpp + 1 .cpp, library (the choice of code to put in the .cpp is very reasonable, so this is not a weakness compared to CTPL). ~290 lines
  • A Boost.ASIO-based 30-line threadpool implementation...

Now, I have not used any of these and cannot describe the differences between them, but would very much like someone with experience using threadpools to do so (in a separate answer).

|improve this answer|||||
  • So, I saw this in my referrer list on github. My library has changed a bit. It's still possible to use as a one header, one source lib, but it also has cooperative threading with a priority queue on POSIX now. This is really useful for solving recursive problems with a thread pool. Without yielding, it's impossible to avoid blocking while waiting on the results of subcomputations. – Tyler Dec 11 '16 at 1:21
  • Oh, and it's also not C++11 compatible anymore. The last C++11 and 14 compatible versions are documented in the readme, though, so with a bit of git competence it's possible to get and use them. – Tyler Dec 11 '16 at 1:23
  • @Tyler: Then, can you please edit my answer to reflect the state of your library right now? Alternatively, post your own, longer answer, describing the strengths and weaknesses of your library. – einpoklum Dec 11 '16 at 7:31


ThreadPool is an easy-to-use header-only thread pool library using C++11 threading API, and no GPL.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.