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;
}
Example #2
0
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;
}
Example #3
0
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;
}
Example #4
0
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;
}