当前位置: 首页>>代码示例>>C++>>正文


C++ WorkQueue::push方法代码示例

本文整理汇总了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);
}
开发者ID:MaxGraey,项目名称:mapbox-gl-native,代码行数:15,代码来源:work_queue.cpp

示例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;
}
开发者ID:01org,项目名称:hyperscan,代码行数:59,代码来源:ng_equivalence.cpp

示例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;
  }
}
开发者ID:berickson,项目名称:car,代码行数:16,代码来源:work_queue.cpp

示例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); });
}
开发者ID:pniekamp,项目名称:datum,代码行数:5,代码来源:example-win32.cpp


注:本文中的WorkQueue::push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。