本文整理汇总了C++中WorkQueue::push方法的典型用法代码示例。如果您正苦于以下问题:C++ WorkQueue::push方法的具体用法?C++ WorkQueue::push怎么用?C++ WorkQueue::push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkQueue
的用法示例。
在下文中一共展示了WorkQueue::push方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loop
TEST(WorkQueue, cancel) {
RunLoop loop(uv_default_loop());
WorkQueue queue;
auto work = [&]() {
FAIL() << "Should never be called";
};
queue.push(work);
queue.push(work);
queue.push(work);
queue.push(work);
queue.push(work);
}
示例2: ci
// store equivalence class in VertexInfo for each vertex
static
vector<VertexInfoSet> partitionGraph(ptr_vector<VertexInfo> &infos,
WorkQueue &work_queue, const NGHolder &g,
EquivalenceType eq) {
const size_t num_verts = infos.size();
vector<VertexInfoSet> classes;
unordered_map<ClassInfo, unsigned> classinfomap;
// assume we will have lots of classes, so we don't waste time resizing
// these structures.
classes.reserve(num_verts);
classinfomap.reserve(num_verts);
// get distances from start (or accept) for all vertices
// only one of them is used at a time, never both
vector<NFAVertexDepth> depths;
vector<NFAVertexRevDepth> rdepths;
if (eq == LEFT_EQUIVALENCE) {
calcDepths(g, depths);
} else {
calcDepths(g, rdepths);
}
// partition the graph based on CharReach
for (VertexInfo &vi : infos) {
ClassInfo::ClassDepth depth;
if (eq == LEFT_EQUIVALENCE) {
depth = depths[vi.vert_index];
} else {
depth = rdepths[vi.vert_index];
}
ClassInfo ci(g, vi, depth, eq);
auto ii = classinfomap.find(ci);
if (ii == classinfomap.end()) {
// vertex is in a new equivalence class by itself.
unsigned eq_class = classes.size();
vi.equivalence_class = eq_class;
classes.push_back({&vi});
classinfomap.emplace(move(ci), eq_class);
} else {
// vertex is added to an existing class.
unsigned eq_class = ii->second;
vi.equivalence_class = eq_class;
classes.at(eq_class).insert(&vi);
// we now know that this particular class has more than one
// vertex, so we add it to the work queue
work_queue.push(eq_class);
}
}
DEBUG_PRINTF("partitioned, %zu equivalence classes\n", classes.size());
return classes;
}
示例3: test_work_queue
void test_work_queue() {
WorkQueue<string> q;
string t = "hello";
q.push(t);
string s;
if(q.try_pop(s, 500)){
cout << "got " << s << " from queue" << endl;
}
bool ok = q.try_pop(s,500);
if(ok) {
cout << "failed, should have timed out" << endl;
}
else{
cout << "passed, timed out as expected" << endl;
}
}
示例4: submit_work
///////////////////////// Platform::submit_work /////////////////////////////
void Platform::submit_work(void (*func)(PlatformInterface &, void*, void*), void *ldata, void *rdata)
{
m_workqueue.push([=]() { func(*this, ldata, rdata); });
}