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


C++ ThreadPtr::run方法代码示例

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


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

示例1: catch

static void*
startHook(void* arg)
{
    //
    // Ensure that the thread doesn't go away until run() has
    // completed.
    //
    IceUtil::ThreadPtr thread;

    try
    {
        IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);

        thread = rawThread;

        //
        // See the comment in IceUtil::Thread::start() for details.
        //
        rawThread->__decRef();
        thread->run();
    }
    catch(...)
    {
        if(!thread->name().empty())
        {
            consoleErr << thread->name() << " terminating" << endl;
        }
        std::terminate();
    }

    thread->_done();

    return 0;
}
开发者ID:zeroc-ice,项目名称:ice-debian-packaging,代码行数:34,代码来源:Thread.cpp

示例2: catch

static void*
startHook(void* arg)
{
  //
  // Ensure that the thread doesn't go away until run() has
  // completed.
  //
  IceUtil::ThreadPtr thread;

  try {
    IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*> (arg);

    thread = rawThread;

    //
    // See the comment in IceUtil::Thread::start() for details.
    //
    rawThread->__decRef();
    thread->run();
  } catch (const IceUtil::Exception& e) {
    cerr << "IceUtil::Thread::run(): uncaught exception: ";
    cerr << e << endl;
  } catch (...) {
    cerr << "IceUtil::Thread::run(): uncaught exception" << endl;
  }
  thread->_done();

  return 0;
}
开发者ID:wuhua988,项目名称:icm,代码行数:29,代码来源:Thread.cpp

示例3: startHook

static unsigned int
WINAPI startHook(void* arg)
{
    // Ensure that the thread doesn't go away until run() has
    // completed.
    //
    IceUtil::ThreadPtr thread;

    try
    {
        IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);

        //
        // Ensure that the thread doesn't go away until run() has
        // completed.
        //
        thread = rawThread;

        //
        // Initialize the random number generator in each thread on
        // Windows (the rand() seed is thread specific).
        //
        unsigned int seed = static_cast<unsigned int>(IceUtil::Time::now().toMicroSeconds());
        srand(seed ^ static_cast<unsigned int>(hash<thread::id>()(thread->getThreadControl().id())));

        //
        // See the comment in IceUtil::Thread::start() for details.
        //
        rawThread->__decRef();
        pthread_setname_np(thread->name().c_str());
        thread->run();
    }
    catch(...)
    {
        if(!thread->name().empty())
        {
            cerr << thread->name() << " terminating" << endl;
        }
        std::terminate();
    }

    thread->_done();
   
    return 0;
}
开发者ID:lgdiy1982,项目名称:SDLAudioPlayer,代码行数:45,代码来源:Thread.cpp

示例4: startHook

static unsigned int
WINAPI startHook(void* arg)
{
  // Ensure that the thread doesn't go away until run() has
  // completed.
  //
  IceUtil::ThreadPtr thread;

  try
  {
    IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);

    //
    // Initialize the random number generator in each thread.
    //
    unsigned int seed = static_cast<unsigned int>(IceUtil::Time::now().toMicroSeconds());
    srand(seed);

    //
    // Ensure that the thread doesn't go away until run() has
    // completed.
    //
    thread = rawThread;

    //
    // See the comment in IceUtil::Thread::start() for details.
    //
    rawThread->__decRef();
    thread->run();
  }
  catch(const IceUtil::Exception& e)
  {
    cerr << "IceUtil::Thread::run(): uncaught exception: ";
    cerr << e << endl;
  }
  catch(...)
  {
    cerr << "IceUtil::Thread::run(): uncaught exception" << endl;
  }
  thread->_done();

  return 0;
}
开发者ID:wuhua988,项目名称:icm,代码行数:43,代码来源:Thread.cpp


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