本文整理汇总了C++中tbb::atomic::fetch_and_increment方法的典型用法代码示例。如果您正苦于以下问题:C++ atomic::fetch_and_increment方法的具体用法?C++ atomic::fetch_and_increment怎么用?C++ atomic::fetch_and_increment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tbb::atomic
的用法示例。
在下文中一共展示了atomic::fetch_and_increment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
bool operator()( T &v ) {
v = (T)my_count.fetch_and_increment();
if ( (int)v < N )
return true;
else
return false;
}
示例2: operator
void operator () (const tbb::blocked_range<int> &range) const {
int i;
PARTITIONER partitioner;
for (i=range.begin(); i<range.end(); i++) {
//printf("Outer Loop Body[%d<=%d<%d]=[0,%d]\n", range.begin(), i, range.end(), degrees[currentLevelSet[i]]);
#ifdef SEQUENTIAL_INNER
for(int j=0; j<degrees[currentLevelSet[i]]; j++) {
int oldGatek;
int freshNode,currentEdge;
currentEdge = vertices[currentLevelSet[i]]+j;
// let's handle one edge
#ifdef XBOFILE
freshNode = edges[currentEdge][1]; // 0 RTM, value was prefetched
#else
freshNode = edges[currentEdge]; // 0 RTM, value was prefetched
#endif
oldGatek = -1;
// test gatekeeper
oldGatek = gatekeeper[freshNode].fetch_and_increment();
if (oldGatek == 0) { // destination vertex unvisited!
// increment newLevelIndex atomically
int myIndex = newLevelIndex.fetch_and_increment();
// store fresh node in new level
newLevelSet[myIndex] = freshNode;
level[freshNode] = currentLevel + 1;
} // end if freshNode
}
#else
tbb::parallel_for (tbb::blocked_range<int>(0,degrees[currentLevelSet[i]],INNER_GRAINSIZE), innerLoopBody(i), partitioner);
#endif
}
}
示例3: nextTaskID
bool nextTaskID(std::size_t &taskID)
{
taskID = counter.fetch_and_increment();
return taskID < NofAtom;
}