Using boost::asio thread pool for general purpose tasks

前端 未结 3 1937
执念已碎
执念已碎 2020-12-05 12:12

In this blog I found a pretty neat example on how to create a simple thread pool using boost::asio. I basically want to use it like this:

#include 

        
相关标签:
3条回答
  • 2020-12-05 12:44

    I wrote a ThreadPool class with boost asio. It works and it is clean &clear enough to understand easily. ThreadPool with boost asio

    0 讨论(0)
  • 2020-12-05 12:48

    Boost.Asio is not solely for network programming, see the reference documentation. It has extensive support for things like

    • time based operations (deadline_timer)
    • signal handling
    • platform specific operations such as posix streams and Windows handles

    I've used it for other purposes in several applications as well. One example being a thread pool to service potentially long running blocking database operations while providing an asynchronous interface for the application. Boost.Asio really is a very powerful library. Using it for a general purpose thread pool as you propose can work just fine.

    0 讨论(0)
  • 2020-12-05 12:52

    I don't see any reason not to do things this way. As a benefit, you can use things like deadline timers which are built on top of boost::asio.

    0 讨论(0)
提交回复
热议问题