本文整理汇总了C++中ThreadPool::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadPool::addItem方法的具体用法?C++ ThreadPool::addItem怎么用?C++ ThreadPool::addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThreadPool
的用法示例。
在下文中一共展示了ThreadPool::addItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startProcessingNextState
void State::startProcessingNextState(ThreadPool &pool, State &next, unsigned short logicMask, float dt) {
// Add all non-destroyed objects to the new state and keep track of reference changes
_newIndices.resize(_sceneObjects.size());
for (size_t i = 0; i < _sceneObjects.size(); i++)
_newIndices[i] = i;
size_t numLess = 0;
for (size_t i = 0; i < _sceneObjects.size(); i++) {
_newIndices[i] -= numLess;
if (!_sceneObjects[i]->_shouldDestroy) {
next._sceneObjects.push_back(std::shared_ptr<SceneObject>(_sceneObjects[i]->copyFactory()));
next._sceneObjects.back()->_indexPlusOne = next._sceneObjects.size();
next._sceneObjects.back()->_pReferences.clear();
}
else
numLess++;
}
// Update all new scene objects in parallel
for (size_t i = 0; i < next._sceneObjects.size(); i++)
if ((logicMask & next._sceneObjects[i]->_logicMask) != 0) {
std::shared_ptr<SceneObjectWorkItem> workItem(new SceneObjectWorkItem());
workItem->_pItem = next._sceneObjects[i].get();
workItem->_dt = dt;
pool.addItem(workItem);
}
// Update all new scene objects in parallel
/*for (size_t i = 0; i < next._sceneObjects.size(); i++)
if ((logicMask & next._sceneObjects[i]->_logicMask) != 0) {
next._sceneObjects[i]->update(dt);
}*/
}