您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ thr函数代码示例

51自学网 2021-06-03 08:48:19
  C++
这篇教程C++ thr函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中thr函数的典型用法代码示例。如果您正苦于以下问题:C++ thr函数的具体用法?C++ thr怎么用?C++ thr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

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

示例1: stopThreads

 inline void stopThreads() const {     lst_sem()->wait();     for (RobotInterface::ThreadList::iterator tit = thr()->begin(); tit != thr()->end(); tit++) {         yarp::os::Thread *thread = *tit;         thread->stop();     }     lst_sem()->post(); }
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:9,


示例2: listen

    void listen(int port) {        //testTheDb();        log() << "waiting for connections on port " << port << endl;        OurListener l(cmdLine.bind_ip, port);        l.setAsTimeTracker();        startReplication();        if ( !noHttpInterface )            boost::thread thr(webServerThread);#if(TESTEXHAUST)        boost::thread thr(testExhaust);#endif        l.initAndListen();    }
开发者ID:gilles,项目名称:mongo,代码行数:14,


示例3: SimpleAsync

std::future<typename std::result_of<Function(Arg)>::type>SimpleAsync(Function func, Arg arg){    typedef std::result_of<Function(Arg)>::type return_val;    // prom.cpp:10:13: error: missing 'typename' prior to dependent type name 'std::result_of<Function (Arg)>::type'    //   (Arg)>::type'    // typedef std::result_of<Function(Arg)>::type return_val;    //         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    //         typename    // http://www.cplusplus.com/reference/type_traits/result_of/     std::promise<return_val> prom;    std::future<return_val> fut = prom.get_future();     std::thread thr([](std::promise<return_val>& prom, Function func, Arg arg)    {        try        {            prom.set_value(func(arg));        }        catch (const std::exception& e)        {            prom.set_exception(std::current_exception());        }    }, std::move(prom), func, arg);     thr.detach();     return std::move(fut);}
开发者ID:DanBrennan33,项目名称:SenecaOOP345-attic,代码行数:31,


示例4: test

  static void test()  {    try    {      attributes attrs;      attrs.thread_num_ = 2;      context ctx(attrs);      threaded_actor ping = spawn(ctx);      threaded_actor pong = spawn(ctx);      aid_t pong_id = pong.get_aid();      boost::thread thr(        boost::bind(          &mixin_pingpong_ut::pong_actor, pong          )        );      boost::timer::auto_cpu_timer t;      message m(1);      for (std::size_t i=0; i<msg_size; ++i)      {        ping.send(pong_id, m);        ping.recv(m);      }      ping->send(pong_id, 2);      thr.join();    }    catch (std::exception& ex)    {      std::cerr << ex.what() << std::endl;    }  }
开发者ID:BianJian,项目名称:mmo,代码行数:32,


示例5: main

intmain (int argc, char **argv){  error_t err;  int i;  pthread_t tid[THREADS];  for (i = 0; i < THREADS; i ++)    {      err = pthread_create (&tid[i], 0, thr, 0);      if (err)	error (1, err, "pthread_create (%d)", i);    }  assert (thr (0) == 0);  for (i = 0; i < THREADS; i ++)    {      void *ret;      err = pthread_join (tid[i], &ret);      if (err)	error (1, err, "pthread_join");      assert (ret == 0);    }  assert (var == 1);  return 0;}
开发者ID:OldRepoPreservation,项目名称:viengoos,代码行数:31,


示例6: main

intmain(int argc, char** argv){    ThreadFunctor tf;    std::thread thr(doit);    std::thread thr2(doit2, 10);    std::thread thr3(tf);    thr.join();    thr2.join();    thr3.join();    std::vector<std::thread> threads;    threads.push_back(std::thread(doit2, 1));    threads.push_back(std::thread(doit2, 2));    threads.push_back(std::thread(doit2, 3));    for (auto &thr:threads) {        thr.join();    }    printf("Nubmer of hardware thread contexts: %u/n",         std::thread::hardware_concurrency());    return 0;}
开发者ID:pp7462-git,项目名称:sandbox,代码行数:25,


示例7: main

int main(int argc, char**argv){	scene = new Scene();	int renderingMode = 5;	RES_X = scene->getWidth();	RES_Y = scene->getHeight();	std::cout << "Please choose your scene from (enter the number):" << std::endl;	std::cout << "1 - Balls_low" << std::endl;	std::cout << "2 - Balls_high" << std::endl;	std::cout << "3 - Mount_Low" << std::endl;	std::cout << "4 - Mount_high" << std::endl;	std::cout << "5 - Solo dragon" << std::endl;	std::cout << "6 - Custom scene" << std::endl;	std::string s;	getline(std::cin, s);	sceneNum = atoi(s.c_str());	std::cout << "Please choose your rendering mode from (enter the number):" << std::endl;	std::cout << "1 - Aliasing with DOF" << std::endl;	std::cout << "2 - Monte Carlo with DOF" << std::endl;	std::cout << "3 - Aliasing only" << std::endl;	std::cout << "4 - Monte Carlo only" << std::endl;	std::cout << "5 - No DOF or Aliasing" << std::endl;	std::cout << "6 - DOF only" << std::endl;	getline(std::cin, s);	renderingMode = atoi(s.c_str());	std::cout << "Please choose the number of Shadow Rays:" << std::endl;	getline(std::cin, s);	numSF = atoi(s.c_str());	std::cout << "Please choose the number of Depth Rays:" << std::endl;	getline(std::cin, s);	numDepth = atoi(s.c_str());	std::thread thr(glutInitv, std::ref(argc), std::ref(argv));	std::thread thr1(loadScene, std::ref(scene ), renderingMode, sceneNum);	//threads[2] = std::thread(loadScene, std::ref(scene), 3);	//threads[3] = std::thread(loadScene, std::ref(scene), 4);	//threads[4] = std::thread(loadScene, std::ref(scene), 5);	//threads[5] = std::thread(loadScene, std::ref(scene), 6);	//aux[0] = std::thread(loadScene, std::ref(scene), 1);	//aux[1] = std::thread(loadScene, std::ref(scene), 2);	//aux[2] = std::thread(loadScene, std::ref(scene), 3);	//aux[3] = std::thread(loadScene, std::ref(scene), 4);	//aux[4] = std::thread(loadScene, std::ref(scene), 5);	//aux[5] = std::thread(loadScene, std::ref(scene), 6);	thr.join();	thr1.join();}
开发者ID:AndreJFBico,项目名称:P3SJ_RayTracer,代码行数:60,


示例8: main

int main(int argc, char* argv[]){if (argc != 2) {     std::cout << "usage: raytracer file.sdf/n";     return 1;  }  Scene scene = load_sdf_file(argv[1]);  std::string const filename = "./checkerboard.ppm";  unsigned const width = scene.xresolution;  unsigned const height = scene.yresolution;  Renderer app(scene, 3);  std::thread thr([&app]() { app.render(); });  Window win(glm::ivec2(width,height));  while (!win.shouldClose()) {    if (win.isKeyPressed(GLFW_KEY_ESCAPE)) {      win.stop();    }    glDrawPixels( width, height, GL_RGB, GL_FLOAT                , app.colorbuffer().data());    win.update();  }  thr.join();  return 0;}
开发者ID:Ridslake,项目名称:programmiersprachen-raytracer,代码行数:34,


示例9: main

int main() {  Logger::init("AISTest.log");  auto future = canService.start();  aisNode = new CANAISNode(msgBus, dbHandler, canService);  aisNode->start();  aisProc = new AISProcessing(msgBus,dbHandler, &cMgr);  aisProc->start();  cMgr.startGC();  std::thread thr(messageLoop);  thr.detach();  int now;  while (true) {    std::this_thread::sleep_for(std::chrono::milliseconds(5000));    now = SysClock::unixTime();    Logger::info("Collidable manager size: " + std::to_string(cMgr.getAISContacts().length()));    auto colList = cMgr.getAISContacts();    for (int i = 0; i<cMgr.getAISContacts().length(); i++) {        auto t = colList.next();        Logger::info("MMSI: " + std::to_string(t.mmsi) + ", Lat: " + std::to_string(t.latitude) + ", Lon: " + std::to_string(t.longitude) +                ", COG: " + std::to_string(t.course) + " (" + std::to_string(t.course*180/3.141592) + ")" + ", SOG: " + std::to_string(t.speed) +                " (" + std::to_string(t.speed*1.9438) + ")" + ", Length: " + std::to_string(t.length) + ", Beam: " + std::to_string(t.beam) +                ", Report age: " + std::to_string(now-t.lastUpdated));    }  }}
开发者ID:AlandSailingRobots,项目名称:sailingrobot,代码行数:30,


示例10: makeFuture

/** Spawn a thread to read from the pipe connected to the specified fd. * Returns a Future that will hold a string with the entire output from * that stream. */Future<w_string> ChildProcess::readPipe(int fd) {  auto it = pipes_.find(fd);  if (it == pipes_.end()) {    return makeFuture(w_string(nullptr));  }  auto p = std::make_shared<Promise<w_string>>();  std::thread thr([this, fd, p] {    std::string result;    try {      auto& pipe = pipes_[fd];      while (true) {        char buf[4096];        auto x = read(pipe->read.fd(), buf, sizeof(buf));        if (x == 0) {          // all done          break;        }        if (x == -1) {          p->setException(std::make_exception_ptr(std::system_error(              errno, std::generic_category(), "reading from child process")));          return;        }        result.append(buf, x);      }      p->setValue(w_string(result.data(), result.size()));    } catch (const std::exception& exc) {      p->setException(std::current_exception());    }  });  thr.detach();  return p->getFuture();}
开发者ID:otrempe,项目名称:watchman,代码行数:37,


示例11: main

int main(int argc, char* argv[]){  std::string const filename = "./ppm_tes.ppm";  SDFloader loader;  std::string filepath = "../framework/res/test_scene_3.sdf";  Scene loaded{loader.load(filepath)};  unsigned const width = 600;  unsigned const height = 600;  Renderer app(width, height, filename);  std::thread thr([&]() { app.render(loaded); });  Window win(glm::ivec2(width,height));  while (!win.shouldClose()) {    if (win.isKeyPressed(GLFW_KEY_ESCAPE)) {      win.stop();    }    glDrawPixels( width, height, GL_RGB, GL_FLOAT                , app.colorbuffer().data());    win.update();  }  thr.join();  return 0;}
开发者ID:Khayet,项目名称:raytracer,代码行数:30,


示例12: accepted

 virtual void accepted(MessagingPort *mp) {     assert( grab == 0 );     grab = mp;     boost::thread thr(connThread);     while ( grab )         sleepmillis(1); }
开发者ID:zhuk,项目名称:mongo,代码行数:7,


示例13: TestEnqueue

void TestEnqueue( int p ) {    REMARK("Testing task::enqueue for %d threads/n", p);    for(int mode=0;mode<3;++mode) {        tbb::task_scheduler_init init(p);        EnqueuedTask::nCompletedPairs = EnqueuedTask::nOrderedPairs = 0;        for(int i=0; i<nTracks; ++i) {            TaskTracks[i] = -1; // to accomodate for the starting call            EnqueuedTask::FireTwoTasks(TaskTracks+i);        }        ProgressMonitor pm;        tbb::tbb_thread thr( pm );        if(mode==1) {            // do some parallel work in the meantime            for(int i=0; i<10; i++) {                TaskGenerator& g = *new( tbb::task::allocate_root() ) TaskGenerator(2,5);                tbb::task::spawn_root_and_wait(g);                TimedYield( 1E-6 );            }        }        if( mode==2 ) {            // Additionally enqueue a bunch of empty tasks. The goal is to test that tasks            // allocated and enqueued by a thread are safe to use after the thread leaves TBB.            tbb::task* root = new (tbb::task::allocate_root()) tbb::empty_task;            root->set_ref_count(100);            for( int i=0; i<100; ++i )                tbb::task::enqueue( *new (root->allocate_child()) tbb::empty_task );            init.terminate(); // master thread deregistered        }        thr.join();        ASSERT(EnqueuedTask::nCompletedPairs==nTracks*PairsPerTrack, NULL);        ASSERT(EnqueuedTask::nOrderedPairs<EnqueuedTask::nCompletedPairs,            "all task pairs executed in enqueue order; de facto guarantee is too strong?");    }}
开发者ID:jonarbo,项目名称:GREASY,代码行数:34,


示例14: WARN_LOG

bool AsyncShaderCompiler::StartWorkerThreads(u32 num_worker_threads){  if (num_worker_threads == 0)    return true;  for (u32 i = 0; i < num_worker_threads; i++)  {    void* thread_param = nullptr;    if (!WorkerThreadInitMainThread(&thread_param))    {      WARN_LOG(VIDEO, "Failed to initialize shader compiler worker thread.");      break;    }    m_worker_thread_start_result.store(false);    std::thread thr(&AsyncShaderCompiler::WorkerThreadEntryPoint, this, thread_param);    m_init_event.Wait();    if (!m_worker_thread_start_result.load())    {      WARN_LOG(VIDEO, "Failed to start shader compiler worker thread.");      thr.join();      break;    }    m_worker_threads.push_back(std::move(thr));  }  return HasWorkerThreads();}
开发者ID:MerryMage,项目名称:dolphin,代码行数:31,


示例15: main

int main(){    F f;    std::thread thr(a);    thr.join();    return 0;}
开发者ID:thisch,项目名称:StepperController,代码行数:7,


示例16: DENA_VERBOSE

std::stringhstcpsvr::start_listen(){    std::string err;    if (threads.size() != 0) {        return "start_listen: already running";    }    if (socket_bind(cshared.listen_fd, cshared.sockargs, err) != 0) {        return "bind: " + err;    }    DENA_VERBOSE(20, fprintf(stderr, "bind done/n"));    const size_t stack_size = std::max(                                  cshared.conf.get_int("stack_size", 1 * 1024LL * 1024), 8 * 1024LL * 1024);    for (long i = 0; i < cshared.num_threads; ++i) {        hstcpsvr_worker_arg arg;        arg.cshared = &cshared;        arg.vshared = &vshared;        arg.worker_id = i;        std::auto_ptr< thread<worker_throbj> > thr(            new thread<worker_throbj>(arg, stack_size));        threads.push_back_ptr(thr);    }    DENA_VERBOSE(20, fprintf(stderr, "threads created/n"));    for (size_t i = 0; i < threads.size(); ++i) {        threads[i]->start();    }    DENA_VERBOSE(20, fprintf(stderr, "threads started/n"));    return std::string();}
开发者ID:javacruft,项目名称:percona-server-5.6,代码行数:29,


示例17: runRulesAfterOutput

万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。