void ossimPlanetClientThread::run()
{
   if(theStartedFlag) return;

   ossim_uint32 idx = 0;
   theStartedFlag = true;
   theDoneFlag    = false;
   while(!theDoneFlag)
   {
      theBlock->block();
      if(theDoneFlag) return;
      bool hasMessages = false;
      theConnectionListMutex.lock();
      for(idx = 0; idx < theClientConnectionList.size(); ++idx)
      {
         if(theClientConnectionList[idx]->hasMessages())
         {
            theClientConnectionList[idx]->sendNextMessage();
            hasMessages = true;
         }
      }
      if(!hasMessages)
      {
         theBlock->set(false);
      }
      theConnectionListMutex.unlock();
      YieldCurrentThread();
   }
   
   theStartedFlag = false;
}
Exemplo n.º 2
0
void
PhysicsThread::pause( bool pause )
{
    if( _stopped )
        return;

    bool block( false );
    bool unblock( false );
    {
        OpenThreads::ScopedLock< OpenThreads::Mutex > lock( _pauseMutex );
        if( pause )
        {
            _pauseCount++;
            block = ( _pauseCount == 1 );
        }
        else
        {
            _pauseCount--;
            unblock = ( _pauseCount == 0 );
        }
    }

    if( block )
    {
        // Give physics thread a change to hit the gate.
        YieldCurrentThread();

        // Block until physics thread hits the gate.
        while( !( isPaused() ) )
            OpenThreads::Thread::microSleep( 10 );
    }
    else if( unblock )
        _pauseGate.release();
}