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


C++ ThreadPool::addTask方法代码示例

本文整理汇总了C++中ThreadPool::addTask方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadPool::addTask方法的具体用法?C++ ThreadPool::addTask怎么用?C++ ThreadPool::addTask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ThreadPool的用法示例。


在下文中一共展示了ThreadPool::addTask方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: startGame

void Room::startGame(ThreadPool & tp)
{
    _game.init(_playerList);
    _game.setDelegate(this);
    _playing = true;
    tp.addTask(new Task(&runGame, &_game));
}
开发者ID:zheck,项目名称:rtype,代码行数:7,代码来源:Room.cpp

示例2: computeColorsAntialiasing

 void Scene::computeColorsAntialiasing(std::function<void(int, int, ColorCRef)> paint, int threadCount, int level) {
     upto(threadCount, 1);
     downto(threadCount, 4);
     std::vector< std::vector <ColorFloat> > m(screen.width, std::vector<ColorFloat> (screen.height, ColorFloat()));
     computeColors([paint, &m](int x, int y, ColorCRef c) { m[x][y] = c; paint(x, y, c); }, threadCount);
     if (level > 1) {
         for (int x = 1; x + 1 < screen.width; x++) {
             for (int y = 1; y + 1 < screen.height; y++) {
                 int badness = 0;
                 for (int dx : {-1, 1})
                     for (int dy : {-1, 1})
                         badness += (m[x][y] - m[x + dx][y + dy]).norm();
                 if (badness > badnessLimit) {
                     paint(x, y, Color(255, 0, 0));
                 }
             }
         }
         int taskCount = 10;
         ThreadPool pool;
         for (int t = 0; t < taskCount; t++)
             pool.addTask([this, &paint, &m, level, t, taskCount]()
                          { multiThreadAntialiasePart(paint, m, level, t, taskCount); });
         pool.executeAll(threadCount);
     }
 }
开发者ID:yuri-pechatnov,项目名称:MiptCLionProjects,代码行数:25,代码来源:scene.cpp

示例3: main

int main() {
    ThreadPool<Thread> *threadPool = new ThreadPool<Thread>(3);
    for (int i = 0; i < 999; ++ i) {
        usleep(1000 * 1000);  
        cout<<"add Task " << endl;
        threadPool->addTask();
    }
    //threadPool->stop();
    delete threadPool;
}
开发者ID:zuocheng-liu,项目名称:code-samples,代码行数:10,代码来源:ThreadPool.cpp

示例4: computeColors

 void Scene::computeColors(std::function<void(int, int, ColorCRef)> paint, int threadCount) {
     figuresKDTree.init(figures);
     upto(threadCount, 1);
     downto(threadCount, 4);
     int taskCount = 10;
     ThreadPool pool;
     for (int t = 0; t < taskCount; t++)
         pool.addTask([this, &paint, t, taskCount]() { multiThreadComputePartOfColors(paint, t, taskCount); });
     pool.executeAll(threadCount);
 }
开发者ID:yuri-pechatnov,项目名称:MiptCLionProjects,代码行数:10,代码来源:scene.cpp

示例5:

void
ThreadPool::addGlobalTask (Task* task)
{
    gThreadPool.addTask (task);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:5,代码来源:IlmThreadPool.cpp


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