Beispiel #1
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 ^ thread->getThreadControl().id());

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

    thread->_done();
   
    return 0;
}
Beispiel #2
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;
}