C++ 中的简单线程池
谁能给我提供一个 C++ 线程池的示例实现吗?我正在寻找一个非常基本的、没有太多复杂性的、适合线程初学者学习的。
Could anyone point me to a sample implementation of a thread pool in C++, please? I'm looking for a very basic one without too much complexity, which would be suitable for a beginner in threading to study.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看英特尔的线程构建块。我不知道该库在多大程度上符合您的“简单”标准,但它似乎经过深思熟虑和彻底。我认为如果你想在 C++ 中进行线程处理,那么学习是值得的。
Boost 也有一些线程工具。
Look at Intel's Thread Building Blocks. I don't know how well that library meets your "simple" criteria, but it seems to be very well thought-out and thorough. I would think that it would be worth the effort to learn if you want to do threading in C++.
Boost also has some threading facilities.
也许值得检查一下 Qt 的 QThreadPool 实现。
It may be worth to check out Qt's QThreadPool implementation.
这是一个非常好的一个: threadpool 它建立在 boost 之上,因此它是跨平台的,非常容易使用出色地
This is a very good one : threadpool its built uppon boost so its cross platform and everything , very easy to use as well
Jeff Langr 在他的《现代 C++ 编程与测试驱动开发》一书中介绍了线程池实现。这是一个繁忙的等待实现。我在这里进一步修改了它 https://github.com/spakai/threadpool_future 以支持诸如此类的事情作为信号等待和期货。
in his book Modern C++ Programming with Test-Driven Development, Jeff Langr walks thru a threadpool implementation. It's a busy wait implementation. I've modified it further here https://github.com/spakai/threadpool_future to support things such as signal-wait and futures.