创建使用boost线程池 [英] Creating a thread pool using boost

查看:153
本文介绍了创建使用boost线程池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使用提升的线程创建一个线程池?
我一直在寻找遍布升压转换器的库,我无法找到一个线程池管理器(或者类似的东西)...
有没有办法做到这一点?

Is it possible to create a thread pool using boost's thread? i was looking all over boost's libs and I couldn't find a thread pool manager (or something like that)... Is there a way to do it?

TNX!

推荐答案

有是一个非官方的(但)线程池的提升。
但它不是一个问题,实现一个自己尤其是伟大的通用性不是首要目标。理念:您的线程池可以用任务类型的类型和工人的数量进行参数化。该TP必须给予处理函数,它接受任务类型。 TP包含添加的任务的队列。真正的线程函数只需要从队列的任务​​,并调用传递的处理程序。类似的东西。

There is an unofficial (yet) threadpool in boost. But it's not a problem to implement one yourself especially if great genericity is not a primary goal. Idea: your threadpool can be parametrized with TaskType type and the number of workers. The TP must be given the handler function which takes TaskType. TP contains a queue of added tasks. The real thread function just takes a task from the queue and calls the passed handler. Something like that.

这篇关于创建使用boost线程池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆