本文整理汇总了C++中JobQueue::has_idle方法的典型用法代码示例。如果您正苦于以下问题:C++ JobQueue::has_idle方法的具体用法?C++ JobQueue::has_idle怎么用?C++ JobQueue::has_idle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JobQueue
的用法示例。
在下文中一共展示了JobQueue::has_idle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/*
* returns true if all elements have been written to output
* false if the merge has been stopped to free work.
*/
inline bool
mergeToOutput(JobQueue& jobQueue)
{
for (size_t lastLength = length; length >= MERGE_BULK_SIZE; length -= MERGE_BULK_SIZE, output += MERGE_BULK_SIZE)
{
if (g_lengthOfLongestJob == lastLength)
g_lengthOfLongestJob = length;
if (g_lengthOfLongestJob < length)
g_lengthOfLongestJob = length; // else if to prevent work sharing when we just increased g_lengthOfLongestJob
else if (USE_WORK_SHARING &&
jobQueue.has_idle() &&
length > SHARE_WORK_THRESHOLD &&
g_lengthOfLongestJob == length)
return false;
loserTree.writeElementsToStream(output, MERGE_BULK_SIZE);
lastLength = length;
}
loserTree.writeElementsToStream(output, length);
return true;
}
示例2: run
virtual bool run(JobQueue& job_queue)
{
size_t n = strptr.size();
LOGC(debug_jobs)
<< "Process SmallsortJob8 " << this << " of size " << n;
strptr = strptr.copy_back();
if (n < g_inssort_threshold) {
inssort::inssort_generic(strptr.copy_back().active(), depth);
return true;
}
Char* charcache = new Char[n];
// std::deque is much slower than std::vector, so we use an artificial
// pop_front variable.
size_t pop_front = 0;
std::vector<RadixStep8_CI> radixstack;
radixstack.emplace_back(strptr, depth, charcache);
while (radixstack.size() > pop_front)
{
while (radixstack.back().idx < 255)
{
RadixStep8_CI& rs = radixstack.back();
size_t b = ++rs.idx; // process the bucket rs.idx
size_t bktsize = rs.bkt[b + 1] - rs.bkt[b];
if (bktsize == 0)
continue;
else if (bktsize < g_inssort_threshold)
{
inssort::inssort_generic(
rs.strptr.sub(rs.bkt[b], bktsize).copy_back().active(),
depth + radixstack.size());
}
else
{
radixstack.emplace_back(rs.strptr.sub(rs.bkt[b], bktsize),
depth + radixstack.size(),
charcache);
}
if (use_work_sharing && job_queue.has_idle())
{
// convert top level of stack into independent jobs
LOGC(debug_jobs)
<< "Freeing top level of SmallsortJob8's radixsort stack";
RadixStep8_CI& rt = radixstack[pop_front];
while (rt.idx < 255)
{
b = ++rt.idx; // enqueue the bucket rt.idx
size_t bktsize = rt.bkt[b + 1] - rt.bkt[b];
if (bktsize == 0) continue;
EnqueueSmallsortJob8(
job_queue, rt.strptr.sub(rt.bkt[b], bktsize),
depth + pop_front);
}
// shorten the current stack
++pop_front;
}
}
radixstack.pop_back();
}
delete[] charcache;
return true;
}