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


C++ OsEvent::wait方法代码示例

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


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

示例1: stop

// Disarm the timer
OsStatus OsTimer::stop(UtlBoolean synchronous)
{
#ifndef NDEBUG
   CHECK_VALIDITY(this);
#endif

   OsStatus result;
   UtlBoolean sendMessage = FALSE;

   // Update members.
   {
      OsLock lock(mBSem);

#ifndef NDEBUG
      assert(!mDeleting);
#endif

      // Determine whether the call is successful.
      if (isStarted(mApplicationState))
      {
         mWasFired = FALSE;
         // Update state to stopped.
         mApplicationState++;
         result = OS_SUCCESS;
         if (mOutstandingMessages == 0)
         {
            // We will send a message.
            sendMessage = TRUE;
            mOutstandingMessages++;
         }
      }
      else
      {
         result = OS_FAILED;
      }
   }

   // If we need to, send an UPDATE message to the timer task.
   if (sendMessage)
   {
      if (synchronous) {
         // Send message and wait.
         OsEvent event;
         OsTimerMsg msg(OsTimerMsg::OS_TIMER_UPDATE_SYNC, this, &event);
         OsStatus res = OsTimerTask::getTimerTask()->postMessage(msg);
         assert(res == OS_SUCCESS);
         event.wait();
      }
      else
      {
         // Send message.
         OsTimerMsg msg(OsTimerMsg::OS_TIMER_UPDATE, this, NULL);
         OsStatus res = OsTimerTask::getTimerTask()->postMessage(msg);
         assert(res == OS_SUCCESS);
      }
   }

   return result;
}
开发者ID:John-Chan,项目名称:sipXtapi,代码行数:60,代码来源:OsTimer.cpp

示例2: testTimedEvent

    void testTimedEvent()
    {
        OsTime   eventTimeout(2,0);
        OsEvent* pEvent;

        pEvent = new OsEvent(12345);
        time_t epochTime = time(NULL);
        CPPUNIT_ASSERT(pEvent->wait(eventTimeout) != OS_SUCCESS);
        pEvent->signal(67890);
        CPPUNIT_ASSERT_EQUAL(OS_SUCCESS, pEvent->wait(eventTimeout));
        pEvent->reset();
        CPPUNIT_ASSERT(pEvent->wait(eventTimeout) != OS_SUCCESS);
        epochTime = time(NULL) - epochTime;
   
        // Make sure we waited (approximately) 2 seconds each time.
        CPPUNIT_ASSERT(epochTime > 2 && epochTime < 6);
   
        delete pEvent;
    }
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:19,代码来源:OsEventTest.cpp

示例3: unmanageFlowGraph

// Directs the media processing task to remove the flow graph from its 
// set of managed flow graphs.
// If the flow graph is not already in the MpFlowGraphBase::STOPPED state,
// then the flow graph will be stopped before it is removed from the set
// of managed flow graphs.
// Returns OS_SUCCESS to indicate that the media task will stop managing
// the indicated flow graph at the start of the next frame processing
// interval.
OsStatus MpMediaTask::unmanageFlowGraph(MpFlowGraphBase& rFlowGraph)
{
   OsEvent event;
   MpMediaTaskMsg msg(MpMediaTaskMsg::UNMANAGE, &rFlowGraph, &event);
   OsStatus res;

   res = postMessage(msg, OsTime::NO_WAIT_TIME);
   assert(res == OS_SUCCESS);
   // wait until flowgraph is unmanaged
   event.wait();

   return OS_SUCCESS;
}
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:21,代码来源:MpMediaTask.cpp

示例4: msg

// Destructor
OsTimerTask::~OsTimerTask()
{
   if (sInstance.isStarted())
   {
      // Shut down the task.
      OsEvent event;
      OsTimerTaskCommandMsg msg(OsTimerTaskCommandMsg::OS_TIMER_SHUTDOWN, NULL, &event);
      // Send the OS_TIMER_SHUTDOWN message.
      OsStatus res = OsTimerTask::getTimerTask()->postMessage(msg);
      assert(res == OS_SUCCESS);
      // Wait for the response.
      event.wait();
   }
}
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:15,代码来源:OsTimerTask.cpp

示例5: testThreadedMultipleFire

    void testThreadedMultipleFire()
    {
        OsEvent event;
        MultipleFireThread fireThread(-1, &event);

        fireThread.start();

        for (int i=0; i<10000; i++)
        {
           CPPUNIT_ASSERT_EQUAL(OS_SUCCESS, event.wait(500));
           CPPUNIT_ASSERT_EQUAL(OS_SUCCESS, event.reset());
        }

        fireThread.requestShutdown();
    }
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:15,代码来源:OsEventTest.cpp

示例6: lock

// Destructor
OsTimer::~OsTimer()
{
#ifndef NDEBUG
   CHECK_VALIDITY(this);
#endif

   // Update members and determine whether we need to send an UPDATE_SYNC
   // to stop the timer or ensure that the timer task has no queued message
   // about this timer.
   UtlBoolean sendMessage = FALSE;
   {
      OsLock lock(mBSem);

#ifndef NDEBUG
      assert(!mDeleting);
      // Lock out all further application methods.
      mDeleting = TRUE;
#endif

      // Check if the timer needs to be stopped.
      if (isStarted(mApplicationState)) {
         sendMessage = TRUE;
         mApplicationState++;
      }
      // Check if there are outstanding messages that have to be waited for.
      if (mOutstandingMessages > 0) {
         sendMessage = TRUE;
      }
      // If we have to send a message, make note of it.
      if (sendMessage) {
         mOutstandingMessages++;
      }
   }

   // Send a message to the timer task if we need to.
   if (sendMessage) {
      OsEvent event;
      OsTimerMsg msg(OsTimerMsg::OS_TIMER_UPDATE_SYNC, this, &event);
      OsStatus res = OsTimerTask::getTimerTask()->postMessage(msg);
      assert(res == OS_SUCCESS);
      event.wait();
   }
   
   // If mbManagedNotifier, free *mpNotifier.
   if (mbManagedNotifier) {
      delete mpNotifier;
   }
}
开发者ID:John-Chan,项目名称:sipXtapi,代码行数:49,代码来源:OsTimer.cpp

示例7: destroyTimerTask

// Destroy the singleton instance of the timer task.
void OsTimerTask::destroyTimerTask(void)
{
    OsSysLog::add(FAC_KERNEL, PRI_DEBUG,
                  "OsTimerTask::destroyTimerTask entered");

    if (sInstance.isStarted())
    {
       OsEvent event;
       OsTimerTaskCommandMsg msg(OsTimerTaskCommandMsg::OS_TIMER_SHUTDOWN, NULL, &event);
       // Send the OS_TIMER_SHUTDOWN message.
       OsStatus res = OsTimerTask::getTimerTask()->postMessage(msg);
       assert(res == OS_SUCCESS);
       // Wait for the response.
       event.wait();
    }
}
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:17,代码来源:OsTimerTask.cpp

示例8: manageFlowGraph

// Directs the media processing task to add the flow graph to its 
// set of managed flow graphs.  The flow graph must be in the 
// MpFlowGraphBase::STOPPED state when this method is invoked.
// Returns OS_INVALID_ARGUMENT if the flow graph is not in the STOPPED state.
// Otherwise returns OS_SUCCESS to indicate that the flow graph will be added
// to the set of managed flow graphs at the start of the next frame
// processing interval.
OsStatus MpMediaTask::manageFlowGraph(MpFlowGraphBase& rFlowGraph)
{
   OsEvent event;
   MpMediaTaskMsg msg(MpMediaTaskMsg::MANAGE, &rFlowGraph, &event);
   OsStatus       res;

   if (rFlowGraph.getState() != MpFlowGraphBase::STOPPED) {
      // PRINTF("MpMediaTask::manageFlowGraph: error!\n", 0,0,0,0,0,0);
      return OS_INVALID_ARGUMENT;
   }

   res = postMessage(msg, OsTime::NO_WAIT_TIME);
   assert(res == OS_SUCCESS);
   // wait until flowgraph is managed
   event.wait();

   return OS_SUCCESS;
}
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:25,代码来源:MpMediaTask.cpp

示例9: main


//.........这里部分代码省略.........
      delete pMsgQ2;
   }
   catch (const OsExcept* exc)
   {

      UtlString txt;
      cout << "Exception:" << endl;
      cout << "  Major Code: " << exc->getMajorCode() << endl;
      cout << "  Minor Code: " << exc->getMinorCode() << endl;
      txt = exc->getText();
      cout << "  Text:       " << txt.data()    << endl;
      txt = exc->getContext();
      cout << "  Context:    " << txt.data() << endl;

      delete exc;
   }
#endif

   delete pMsgQ1;

/* ============================ OsCallback ================================ */

   OsCallback* pCallback;

   pCallback = new OsCallback(12345, handleTimerEvent);
   pCallback->signal(67890);
   delete pCallback;

/* ============================ OsEvent =================================== */

   OsTime   eventTimeout(2,0);
   OsEvent* pEvent;

   cout << "Testing OsEvent, please wait..." << endl;
   pEvent = new OsEvent(12345);
   int epochTime = time(NULL);
   assert(pEvent->wait(eventTimeout) != OS_SUCCESS);
   pEvent->signal(67890);
   assert(pEvent->wait(eventTimeout) == OS_SUCCESS);
   pEvent->reset();
   assert(pEvent->wait(eventTimeout) != OS_SUCCESS);
   epochTime = time(NULL) - epochTime;

   // Make sure we waited (approximately) 2 seconds each time.
   assert(epochTime > 2 && epochTime < 6);

   delete pEvent;
   cout << "Done testing OsEvent." << endl;

/* ============================ OsConfigDb ================================ */

   OsConfigDb* pConfigDb;

   pConfigDb = new OsConfigDb();
   delete pConfigDb;

/* ============================ OsTimerTask =============================== */

   OsTimerTask* pTimerTask;
   pTimerTask = OsTimerTask::getTimerTask();
   OsTask::delay(500);    // wait 1/2 second
   osPrintf("Going to delete the timer task.\n");
   delete pTimerTask;

/* ============================ OsTimer =================================== */
开发者ID:ClydeFroq,项目名称:sipxecs,代码行数:66,代码来源:main.cpp

示例10: waitUntilAvailable

UtlBoolean SipTransactionList::waitUntilAvailable(SipTransaction* transaction,
                                                 const UtlString& hash)
{
    UtlBoolean exists;
    UtlBoolean busy = FALSE;
    int numTries = 0;

    do
    {
        numTries++;

        lock();
        exists = transactionExists(transaction, hash);

        if(exists)
        {
            busy =  transaction->isBusy();
            if(!busy)
            {
                transaction->markBusy();
                unlock();
//#ifdef TEST_PRINT
                OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipTransactionList::waitUntilAvailable %p locked after %d tries\n",
                    transaction, numTries);
//#endif
            }
            else
            {
                // We set an event to be signaled when a
                // transaction is released.
                OsEvent* waitEvent = new OsEvent;
                transaction->notifyWhenAvailable(waitEvent);

                // Must unlock while we wait or there is a dead lock
                unlock();

//#ifdef TEST_PRINT
                OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipTransactionList::waitUntilAvailable %p waiting on: %p after %d tries\n",
                    transaction, waitEvent, numTries);
//#endif

                OsStatus waitStatus;
                OsTime transBusyTimeout(1, 0);
                int waitTime = 0;
                do
                {
                    if(waitTime > 0)
                        OsSysLog::add(FAC_SIP, PRI_WARNING, "SipTransactionList::waitUntilAvailable %p still waiting: %d",
                            transaction, waitTime);

                    waitStatus = waitEvent->wait(transBusyTimeout);
                    waitTime+=1;
                }
                while(waitStatus != OS_SUCCESS && waitTime < 30);

                // If we were never signaled, then we signal the
                // event so the other side knows that it has to
                // free up the event
                if(waitEvent->signal(-1) == OS_ALREADY_SIGNALED)
                {
                    delete waitEvent;
                    waitEvent = NULL;
                }

                // If we bailed out before the event was signaled
                // pretend the transaction does not exist.
                if(waitStatus != OS_SUCCESS)
                {
                    exists = FALSE;
                }

                if(waitTime > 1)
                {
                    if (OsSysLog::willLog(FAC_SIP, PRI_WARNING))
                    {
                        UtlString transTree;
                        UtlString waitingTaskName;
                        OsTask* waitingTask = OsTask::getCurrentTask();
                        if(waitingTask) waitingTaskName = waitingTask->getName();
                        transaction->dumpTransactionTree(transTree, FALSE);
                        OsSysLog::add(FAC_SIP, PRI_WARNING, "SipTransactionList::waitUntilAvailable status: %d wait time: %d transaction: %p task: %s transaction tree: %s",
                            waitStatus, waitTime, transaction, waitingTaskName.data(), transTree.data());
                    }
                }

//#ifdef TEST_PRINT
                OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipTransactionList::waitUntilAvailable %p done waiting after %d tries\n",
                    transaction, numTries);
//#endif
            }
        }
        else
        {
            unlock();
//#ifdef TEST_PRINT
            OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipTransactionList::waitUntilAvailable %p gone after %d tries\n",
                    transaction, numTries);
//#endif
        }
    }
//.........这里部分代码省略.........
开发者ID:John-Chan,项目名称:sipXtapi,代码行数:101,代码来源:SipTransactionList.cpp

示例11: testThreadedEvent

    void testThreadedEvent()
    {
        // Seed the random number generator
        srand(OsDateTime::getSecsSinceEpoch());

        int numTries = 100;
        int* rightResults = new int[numTries];
        int* leftResults = new int[numTries];

        // Create the Right thread.  This context will be the
        // Left thread.
        RightEventThread rightThread(rightResults, numTries);
        rightThread.start();

        int index;
        for(index = 0; index < numTries; index++)
        {
            OsEvent* event = new OsEvent(index);
            OsRpcMsg eventMsg(OsMsg::USER_START,0,*event);
            rightThread.postMessage(eventMsg);

            int waitTimeMsec = (rand() % 3) * 110;
            OsTime time(0, waitTimeMsec * 1000);
            event->wait(time);

            OsStatus eventStat = event->signal(index);
            if(eventStat == OS_ALREADY_SIGNALED)
            {
                // We (Left) lost the other side is done
                int eventData;
                event->getEventData(eventData);
                CPPUNIT_ASSERT(eventData == index);

                // This/Left side deletes the event
                delete event;
                event = NULL;
               leftResults[index] = TRUE;
            }
            else
            {
                // The other/Right side lost
                // Do nothing
                leftResults[index] = FALSE;
                //osPrintf("Left: %d\n", eventStat);
            }
        }

        OsTask::delay(1000);

        int leftDeletes = 0;
        int rightDeletes = 0;
        for(index = 0; index < numTries; index++)
        {
            if(leftResults[index] == TRUE)
            {
                leftDeletes++;
            }
            if(rightResults[index] == TRUE)
            {
                rightDeletes++;
            }
            if(rightResults[index] == leftResults[index])
            {
               //osPrintf("Left deleted: %d Right deleted: %d\n",
               //           leftDeletes, rightDeletes);
               //osPrintf("[%d]: Both sides %s\n", index, 
               //        rightResults[index] ? "Deleted" : "Did not delete");
            }
            CPPUNIT_ASSERT(rightResults[index] != leftResults[index]);
        }

        //osPrintf("Left deleted: %d Right deleted: %d\n",
        //        leftDeletes, rightDeletes);

        CPPUNIT_ASSERT(leftDeletes + rightDeletes == numTries);
    }
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:76,代码来源:OsEventTest.cpp

示例12: realize

// Realizes the player by initiating a connection to the target, allocates
// buffers, etc.
OsStatus MpStreamPlayer::realize(UtlBoolean bBlock /* = TRUE */)
{
   OsStatus status = OS_FAILED ;
   OsEvent eventHandle ;
   intptr_t eventData ;

   // Only proceed if we have a flow graph and the player is unrealized.
   if (getState() == PlayerUnrealized)
   {
      // Create an mpQueueEvent object to signal state changes in from
      // the MpStreamFeeder
      mpQueueEvent =  new OsQueuedEvent(*getMessageQueue(), 0);

      // Realize the stream
      if (mSourceType == SourceUrl)
      {
         if (mpMsgQ != NULL)
         {
            MpStreamMsg msg(MpStreamMsg::STREAM_REALIZE_URL, mTarget, NULL,
                  &eventHandle, mpQueueEvent, mFlags, (intptr_t) new Url(mUrl)) ;
            status = mpMsgQ->send(msg) ;
         }
      }
      else if (mSourceType == SourceBuffer)
      {

         if (mpMsgQ != NULL)
         {
            MpStreamMsg msg(MpStreamMsg::STREAM_REALIZE_BUFFER, mTarget, NULL,
                  &eventHandle, mpQueueEvent, mFlags, (intptr_t) mpBuffer) ;
            status = mpMsgQ->send(msg) ;
         }
      }

      if (status == OS_SUCCESS)
      {
         // Wait for a response
         status = eventHandle.wait(OsTime(MAX_REALIZE_WAIT, 0)) ;
         if (status == OS_SUCCESS)
         {
            if (eventHandle.getEventData(eventData) == OS_SUCCESS)
            {
               mHandle = (StreamHandle) eventData ;
			   if (mHandle != 0)
			      mbRealized = TRUE ;
            }
            else
            {
               mHandle = NULL ;
            }
         }
         else
         {
            mHandle = NULL ;
         }
      }
   }

   if (mHandle == 0)
   {
      mState = PlayerDestroyed ;
      status = OS_FAILED ;
      mSemStateChange.release() ;
   }

   if (status == OS_SUCCESS)
   {
      // Start Server task if successfull
      if (start() == TRUE)
      {
         // Block while waiting for prefetch (if requested)
         if (bBlock)
         {
            while (getState() == PlayerUnrealized)
            {
               mSemStateChange.acquire();
            }
         }
         else
         {
            // Wait for task to startup
            while (!isStarted())
            {
               OsTask::yield() ;
            }
         }
      }
      else
      {
         syslog(FAC_STREAMING, PRI_CRIT, "Failed to create thread for MpStreamPlayer") ;

         // Unable to create thread; attempt to clean up
         status = OS_FAILED ;

         MpStreamMsg msgStop(MpStreamMsg::STREAM_STOP, mTarget, mHandle);
         mpMsgQ->send(msgStop) ;
         MpStreamMsg msgDestroy(MpStreamMsg::STREAM_DESTROY, mTarget, mHandle);
         mpMsgQ->send(msgDestroy) ;
//.........这里部分代码省略.........
开发者ID:astubbs,项目名称:sipxecs,代码行数:101,代码来源:MpStreamPlayer.cpp

示例13: waitForClientToWrite

UtlBoolean SipProtocolServerBase::waitForClientToWrite(SipClient* client)
{
    UtlBoolean exists;
    UtlBoolean busy = FALSE;
    int numTries = 0;

    do
    {
        numTries++;

        mClientLock.acquireWrite();
        exists = clientExists(client);

        if(exists)
        {
            busy =  client->isInUseForWrite();
            if(!busy)
            {
                client->markInUseForWrite();
                mClientLock.releaseWrite();
                if(numTries > 1)
                {
                   OsSysLog::add(FAC_SIP, PRI_DEBUG,
                                 "Sip%sServerBase::waitForClientToWrite %p locked after %d tries",
                                 mProtocolString.data(), client, numTries);
                }
            }
            else
            {
                // We set an event to be signaled when a
                // transaction is released.
                OsEvent* waitEvent = new OsEvent();
                client->notifyWhenAvailableForWrite(*waitEvent);

                // Must unlock while we wait or there is a dead lock
                mClientLock.releaseWrite();
#ifdef TEST_PRINT
                OsSysLog::add(FAC_SIP, PRI_DEBUG,
                              "Sip%sServerBase::waitForClientToWrite %p "
                              "waiting on: %p after %d tries",
                              mProtocolString.data(), client, waitEvent, numTries);
#endif

                // Do not block forever
                OsTime maxWaitTime(0, 500000);

                // If the other side signaled
                if(waitEvent->wait(maxWaitTime)  == OS_SUCCESS)
                {
                    // The other side is no longer referencing
                    // the event.  This side must clean it up
                    delete waitEvent;
                    waitEvent = NULL;
                }
                // A timeout occurred and the other side did not signal yet
                else
                {
                    // Signal the other side to indicate we are done
                    // with the event.  If already signaled, we lost
                    // a race and the other side was done first.
                    if(waitEvent->signal(0) == OS_ALREADY_SIGNALED)
                    {
                        delete waitEvent;
                        waitEvent = NULL;
                    }
                }

#ifdef TEST_PRINT
                OsSysLog::add(FAC_SIP, PRI_DEBUG,
                              "Sip%sServerBase::waitForClientToWrite %p done waiting after %d tries",
                              mProtocolString.data(), client, numTries);
#endif
            }
        }
        else
        {
            mClientLock.releaseWrite();

            OsSysLog::add(FAC_SIP, PRI_ERR,
                          "Sip%sServerBase::waitForClientToWrite %p gone after %d tries",
                          mProtocolString.data(), client, numTries);
        }
    }
    while(exists && busy);

    return(exists && !busy);
}
开发者ID:John-Chan,项目名称:sipXtapi,代码行数:87,代码来源:SipProtocolServerBase.cpp

示例14: realize

// Realizes the player by initiating a connection to the target, allocates
// buffers, etc.
OsStatus MpStreamPlaylistPlayer::realize(UtlBoolean bBlock)
{
   OsStatus status = OS_FAILED;
   PlayListEntry* e;

   if (mAggregateState == PlayerFailed)
   {
      OsSysLog::add(FAC_MP, PRI_ERR, "MpStreamPlaylistPlayer::realize failure, mAggregateState == PlayerFailed");
      return status;
   }

   // Start prefetching all of the elements
   UtlSListIterator playListDbIterator(*mPlayListDb) ;
   while((e = (PlayListEntry*)playListDbIterator()))
   {
//      OsSysLog::add(FAC_MP, PRI_DEBUG, "MpStreamPlaylistPlayer::realize entry[%d] state %d", e->index, e->state);

      if (e->state == PlayerUnrealized)
      {
         OsEvent eventHandle;

         // Realize the stream
         if (e->sourceType == SourceUrl)
         {
            MpStreamMsg msg(MpStreamMsg::STREAM_REALIZE_URL,
                            mTarget,
                            NULL,
                            &eventHandle,
                            e->pQueuedEvent,
                            e->flags,
                            (intptr_t) new Url(e->url));
            status = mpMsgQ->send(msg);
            if (status != OS_SUCCESS)
            {
               setEntryState(e, PlayerFailed);
               e->handle = NULL;
               OsSysLog::add(FAC_MP, PRI_ERR, "MpStreamPlaylistPlayer::realize failed on send of MpStreamMsg::STREAM_REALIZE_URL message");
            }
         }
         else if (e->sourceType == SourceBuffer)
         {
            MpStreamMsg msg(MpStreamMsg::STREAM_REALIZE_BUFFER,
                            mTarget,
                            NULL,
                            &eventHandle,
                            e->pQueuedEvent,
                            e->flags,
                            (intptr_t) e->pBuffer);
            status = mpMsgQ->send(msg);
            if (status != OS_SUCCESS)
            {
               setEntryState(e, PlayerFailed);
               e->handle = NULL;
               delete e->pBuffer;
               e->pBuffer = NULL;
               OsSysLog::add(FAC_MP, PRI_ERR, "MpStreamPlaylistPlayer::realize failed on send of MpStreamMsg::STREAM_REALIZE_BUFFER message");
            }
         }

         if (status == OS_SUCCESS)
         {
            // Wait for a response
            intptr_t eventData;
            status = eventHandle.wait(mRealizeTimeout);
            if (status == OS_SUCCESS)
               status = eventHandle.getEventData(eventData);
            if (status == OS_SUCCESS)
            {
               e->handle = (StreamHandle) eventData;
            }
            else
            {
               setEntryState(e, PlayerFailed);
               e->handle = NULL;
               if (e->sourceType == SourceBuffer)
               {
                  delete e->pBuffer;
                  e->pBuffer = NULL;
               }
               OsSysLog::add(FAC_MP, PRI_ERR, "MpStreamPlaylistPlayer::realize STREAM_REALIZE_ request failed");
            }
         }
      }
   }

   // Block if requested
   playListDbIterator.reset();
   if ((status == OS_SUCCESS) && bBlock)
   {
      while((e = (PlayListEntry*)playListDbIterator()) != NULL &&
               (mAggregateState != PlayerFailed))
      {
         while (e->state == PlayerUnrealized)
         {
            status = mSemStateChange.acquire(mRealizeTimeout);
            if (status == OS_WAIT_TIMEOUT)
            {
               setEntryState(e, PlayerFailed);
//.........这里部分代码省略.........
开发者ID:astubbs,项目名称:sipxecs,代码行数:101,代码来源:MpStreamPlaylistPlayer.cpp

示例15: main

int main(int argc, char* argv[])
{
   parseArgs(argc, argv);
   initLogger(argv);
   OsEvent taskDone;

   Url url(xmlrpcURI);
    
   if (MemCheckDelay)
   {
      // Delay 45 seconds to allow memcheck start
      printf("Wating %d seconds for start of memcheck ...", MemCheckDelay);
      OsTask::delay(MemCheckDelay * 1000);
      printf("starting\n");
   }
   
   // If an input file was specified we start up the number
   // of specified threads to execute that input file. If number
   // of threads wasn't specified we start up 1 thread.
   if (bInputFile)
   {
      int signaled = 0;
      
      for (int i=0; i<numThreads; i++)
      {
         ClientTask* pTask = new ClientTask(&taskDone);
         pTask->start();
      }

      // Wait for threads to shut down
      while (signaled < numThreads)
      {
         taskDone.wait();
         taskDone.reset();
         ++signaled;
      }
      exit(0);
   }

   switch (Method)
   {
   case Version: // --version <xmlrpc URI> <dataset>
   {
      if (optind < argc)
      {
         fprintf(stderr, "Too many arguments: '%s'\n", argv[optind]);
         showHelp(argv);
         exit(1);
      }

      requestVersion(url);

      break;
   }
   case Get: // --get <xmlrpc URI> <dataset> <name> ...
   {
      UtlSList names;
      // copy remaining arguments into the names list
      while (optind < argc)
      {
         names.append(new UtlString(argv[optind++]));
      }
      
      requestGet(url, names);

      break;
   }
   case Set: // --set <xmlrpc URI> <dataset> <name> <value> [ <name> <value> ] ... 
   {
      UtlHashMap parameters;
      // copy remaining arguments into the names list
      while (optind + 1 < argc)
      {
         UtlString* setName = new UtlString(argv[optind++]);
         UtlString* setValue = new UtlString(argv[optind++]);
         parameters.insertKeyAndValue(setName, setValue);
      }
      if (optind < argc)
      {
         fprintf(stderr, "name '%s' without a value\n", argv[optind]);
         showHelp(argv);
         exit(1);
      }
      
      if (parameters.isEmpty())
      {
         fprintf(stderr, "must specify at least one name and value\n");
         showHelp(argv);
         exit(1);
      }
      else
      {
        requestSet(url, parameters);
        parameters.destroyAll();
      }

      break;
   }
   case Delete: // --delete <xmlrpc URI> <dataset> <name> ... 
   {
//.........这里部分代码省略.........
开发者ID:mranga,项目名称:sipxecs,代码行数:101,代码来源:configrpc.cpp


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