简体   繁体   English

用于工作线程池和作业队列等的可移植库

[英]a portable library for worker thread pools and job queues and such

I am developing a portable (as in Linux and Windows) C/C++ program - a game - that will use multi-threading for the jobs such as path-finding. 我正在开发一个可移植的(如在Linux和Windows中)C / C ++程序-一个游戏-该程序将使用多线程处理诸如寻路之类的工作。

Are there any robust libraries for handling the allocation of tasks to the thread-pool? 是否有任何强大的库来处理线程池的任务分配? Preferably with lock-free structures and work-stealing and other cutting-edge ideas. 优选地具有无锁结构和工作窃取以及其他尖端的想法。 Or do I have to really start with pthreads or a threading library and then implement the job queuing and such myself? 或者我是否必须真正开始使用pthreads或线程库,然后实现作业排队等等?

You should look into tbb from Intel. 您应该查看Intel的tbb I haven't used their task groups, but it might give you a good starting point if you can't find anything better. 我没有使用他们的任务组,但如果你找不到更好的东西,它可能会给你一个很好的起点。

If you are going to do your own threading, then use Boost.Thread . 如果您要进行自己的线程,请使用Boost.Thread

As for thread-pools and task queuing, I think that Boost.Asio is a good library to look at. 至于线程池和任务排队,我认为Boost.Asio是一个很好的库。 It might not be using the cutting edge stuff and provide the most features, but it is portable, robust, and lock-free (I think). 它可能没有使用最先进的工具并提供最多的功能,但是它是便携式,健壮且无锁的(我认为)。 It is meant for asynchronous IO, but you can basically consider tasks as asynchronous message handlers. 它适用于异步IO,但您基本上可以将任务视为异步消息处理程序。

TBB is also a good option, but it might be a bit of overkill for a computer game (it's more geared towards true parallel computing). TBB也是一个不错的选择,但是对于电脑游戏来说可能有点过大(它更适合真正的并行计算)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM