예제 #1
0
// Core send message logic.
OsStatus OsMsgQShared::doSendCore(OsMsg* pMsg,
                                  const OsTime& rTimeout,
                                  UtlBoolean isUrgent,
                                  UtlBoolean deleteWhenDone)
{
   if (mSendHookFunc != NULL)
   {
      if (mSendHookFunc(*pMsg))
      {
         // by returning TRUE, the mSendHookFunc indicates that it has handled
         // the message and there is no need to queue the message.
         if (deleteWhenDone)
         {
            // Delete *pMsg, since we are done with it.
            delete pMsg;
         }
         return OS_SUCCESS;
      }
   }

   enqueue(pMsg);

   int count = numMsgs();
   
   if (_reportFull && 2 * count > mMaxMsgs)
   {
     OS_LOG_WARNING(FAC_KERNEL,
                   "OsMsgQShared::doSendCore message queue '" << mName.data()
                   << "' is over half full - count = " << count
                   << " max = " << mMaxMsgs);
   }

   system_tap_queue_enqueue(mName.data(), 0, _queue.size());
   return OS_SUCCESS;
}
예제 #2
0
void OsMsgQShared::show(void)
{
   osPrintf("* OsMsgQShared: OsMsgQ=%p, options=%d, limitMsgs=%d, maxMsgs=%d, numMsgs=%d\n",
            (void *) this, mOptions, mMaxMsgs, mHighCnt, numMsgs());

   osPrintf("* OsMsgQShared: mEmpty counting semaphore information\n");
   mEmpty.OsCSemShow();

   osPrintf("* OsMsgQShared: mFull counting semaphore information\n");
   mFull.OsCSemShow();
}
예제 #3
0
// Helper function for removing a message from the head of the queue
OsStatus OsMsgQShared::doReceive(OsMsg*& rpMsg, const OsTime& rTimeout)
{
   OsStatus ret;

#ifdef MSGQ_IS_VALID_CHECK /* [ */
   ret = mGuard.acquire();         // start critical section
   assert(ret == OS_SUCCESS);

   testMessageQ();
   mNumRemoveEntry++;

   ret = mGuard.release();         // exit critical section
   assert(ret == OS_SUCCESS);
#endif /* MSGQ_IS_VALID_CHECK ] */

   ret = mFull.acquire(rTimeout);  // wait for a message to be available
   if (ret != OS_SUCCESS)
   {
      if (ret == OS_BUSY || ret == OS_WAIT_TIMEOUT)
         ret = OS_WAIT_TIMEOUT;   // receive timed out
      else
      {
         assert(FALSE);
         ret = OS_UNSPECIFIED;
      }
   }
   else
   {
      ret = mGuard.acquire();         // start critical section
      assert(ret == OS_SUCCESS);

      assert(numMsgs() > 0);
      rpMsg = (OsMsg*) mDlist.get();  // get the first message

      if (rpMsg == NULL)              // was there a message?
      {
         assert(FALSE);
         ret = OS_UNSPECIFIED;
      }
      else
      {
         ret = mEmpty.release();         // the remove operation succeeded, signal
         assert(ret == OS_SUCCESS);      //  senders that there is an available
                                         //  message slot.
      }

      (void)mGuard.release();         // exit critical section
   }

#ifdef MSGQ_IS_VALID_CHECK /* [ */
   OsStatus rc = mGuard.acquire();         // start critical section
   assert(rc == OS_SUCCESS);

   if (ret == OS_SUCCESS)
      mNumRemoveExitOk++;
   else
      mNumRemoveExitFail++;

   testMessageQ();

   rc = mGuard.release();         // exit critical section
   assert(rc == OS_SUCCESS);
#endif /* MSGQ_IS_VALID_CHECK ] */

   system_tap_queue_dequeue(mName.data(), 0, mDlist.entries());

   return ret;
}
예제 #4
0
// Destructor
OsMsgQShared::~OsMsgQShared()
{
    if (numMsgs())
        flush();    // get rid of any messages in the queue
}
예제 #5
0
파일: OsMsgQ.cpp 프로젝트: LordGaav/sipxecs
// Return TRUE if the message queue is empty, FALSE otherwise
UtlBoolean OsMsgQBase::isEmpty(void)
{
   return (numMsgs() == 0);
}