3

This question refers to boost::threadpool::pool, and there's docs about it here on sourceforge, but I can't find it in the boost docs.

Why is it called boost if it's not on boost?

PS: I know how to use Boost::ASIO's io_service to create a thread pool, but I'd like to understand what this boost::threadpool is.

Community
  • 1
  • 1
The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
  • 2
    It is very old library. Seems that it was not a part of the `boost` officially. Nowadays thread pools is a part of `boost::asio`. – Zefick Mar 24 '17 at 09:16
  • @Zefick `io_service` doesn't spawn any threads, does it? So, you can't call it thread pool. – Michael Nastenko Mar 24 '17 at 09:31
  • 2
    There is no `boost::threadpool::pool`. But you can find `boost::executors::basic_thread_pool` and `boost::executors::scheduled_thread_pool' in source code and examples. But not in docs. Last changes were made in boost 1.60, so is doesn't seem to be abandoned. Maybe it is experimental? – Michael Nastenko Mar 24 '17 at 09:55
  • Ay. How did I not know these @MichaelNastenko. Also, seeing that executors are being standardized as we speak, I'm not comfortable concluding they're not abandoned because "last changes were in boost 1.60". That's much too old by any practical measure. I think the better versions should be in Chris Kohlhoffs github https://github.com/chriskohlhoff/executors – sehe Mar 24 '17 at 11:05

1 Answers1

0

As a former helper with Boost.Thread maintenance, I was often asked why Boost.Thread doesn't provide a thread pool. The simple answer is that it really is too easy to roll your own, for example here is a perfectly fine threadpool implementation in only a few lines of C++.

It's too small a thing for Boost, and too much bike shedding would happen on trying to submit a general purpose thread pool. So you can misuse ASIO to implement a thread pool (also easy), roll your own, or just use the thread pool in the C++ 11 standard library accessible via std::async.

Niall Douglas
  • 9,212
  • 2
  • 44
  • 54
  • 2
    The reason to put it in Boost is that Boost is where people go looking for this, time and time again (myself included). You say it takes only a few lines of code (that old canard) to roll your own, but then surely Boost.Bimap should not exist? And finally, the link you provided does not contain the word "pool" according to my browser. So mere mortals will never puzzle it out. – John Zwinck Mar 25 '17 at 00:19
  • To get something past peer review in Boost requires it to be sufficiently uncontroversial. A "perfect" thread pool would be extremely controversial. I would doubt it could ever pass, at least not until the Executors WG21 proposal eliminates a large chunk of the potential bikeshedding. So you may get your wish eventually, but it won't be for a few years yet. – Niall Douglas Mar 25 '17 at 12:50
  • Link to example is dead. – Raedwald Nov 24 '17 at 21:25
  • Replaced with absolute link to fixed SHA, thanks for letting me know it had gone stale. – Niall Douglas Nov 27 '17 at 10:23
  • 5
    Whenever I hear “easy” in the context of threading infrastructure I get queasy. Concurrency users and concurrency implementers are two distinct groups of people with different expertise. I strongly disagree that it’s “too small” for Boost. But you’re right about the bikeshedding aspect: getting the API right for a general-purpose thread pool would be hard. – Konrad Rudolph Nov 27 '17 at 11:09
  • 3
    This is just begging the question -- if it were so easy, people would just roll their own and not look to boost to provide one. That people keep asking for it should suggest to you that maybe it isn't so easy. And if it is bike-shedding that we are worried about, why does boost exist at all? How can it be "too small a thing" yet so controversial that relentless bike-shedding is a reason to not provide it? – mcmcc Mar 15 '18 at 20:19