【发布时间】:2011-02-02 02:15:58
【问题描述】:
所以我有类似的东西
typedef boost::function<void(DataType)> Function;
typedef std::vector<Function> FunctionSequence;
typedef typename FunctionSequence::iterator FunctionIterator;
DataType* dataElement;
FunctionSequence funcs;
//...
for (FunctionIterator it(funcs.begin()); it != funcs.end(); ++it){
DataType dataCopy;
dataCopy = *dataElement;
(*it)(dataCopy);
如何使用 boost.thread 使每个向量函数在单独的新线程中运行,或者如果它最好有一个线程向量而不是每次都创建 therad?
【问题讨论】:
-
不确定您要完成什么。你能再详细一点吗?您是否尝试在同一个 DataType 实例上执行每个函数?如果是这样,这些函数会修改 DataType 的值吗?谢谢
标签: c++ multithreading boost boost-thread