Exemple #1
0
ResourceHolder::~ResourceHolder()
{
	if(_cleanupFunc)
		_cleanupFunc();
}
Exemple #2
0
void SipperProxyQueue::stopQueue(void)
{
   int oldstate;
   pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
   pthread_mutex_lock(&tEventQueueMutex);

   if(bQueueStopped)
   {
      pthread_mutex_unlock(&tEventQueueMutex);
      pthread_setcancelstate(oldstate, NULL);
      return;
   }

   bQueueStopped = true;

   pthread_cond_broadcast(&waitingFeederCond);
   pthread_cond_broadcast(&waitingConsumerCond);

   for(unsigned int idx = 0; idx < MAX_QUEUE_THR; idx++)
   {
      if(feederData[idx].count)
      {
         pthread_cond_signal(&feederData[idx].condition);
      }

      if(consumerData[idx].count)
      {
         pthread_cond_signal(&consumerData[idx].condition);
      }
   }

   while(ptHeadPtr != NULL)
   {
      t_EventQueueNodePtr currNode = ptHeadPtr;
      ptHeadPtr  = ptHeadPtr->ptNextNode;
      iQueueCount--;

      if(_cleanupFunc != NULL)
      {
         _cleanupFunc(currNode->_queueData);
      }

      if(iFreeNodes < highWaterMark)
      {
         currNode->ptNextNode = ptFreeList;
         ptFreeList = currNode;

         iFreeNodes++;
      }
      else
      {
         delete currNode;
      }

      if(ptHeadPtr == NULL)
      {
         ptTailPtr = NULL;
      }
   }

   pthread_mutex_unlock(&tEventQueueMutex);
   pthread_setcancelstate(oldstate, NULL);
}