Logo Search packages:      
Sourcecode: poco version File versions  Download package

Notification * Poco::NotificationQueue::waitDequeueNotification ( long  milliseconds  ) 

Dequeues the next pending notification. If no notification is available, waits for a notification to be enqueued. The caller gains ownership of the notification and is expected to release it when done with it. This method returns 0 (null) if wakeUpWaitingThreads() has been called by another thread.

Definition at line 119 of file NotificationQueue.cpp.

References dequeueOne().

{
      Notification* pNf = 0;
      WaitInfo*     pWI = 0;
      {
            FastMutex::ScopedLock lock(_mutex);
            pNf = dequeueOne();
            if (pNf) return pNf;
            pWI = new WaitInfo;
            pWI->pNf = 0;
            _waitQueue.push_back(pWI);
      }
      if (pWI->nfAvailable.tryWait(milliseconds))
      {
            pNf = pWI->pNf;
      }
      else
      {
            FastMutex::ScopedLock lock(_mutex);
            pNf = pWI->pNf;
            for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
            {
                  if (*it == pWI)
                  {
                        _waitQueue.erase(it);
                        break;
                  }
            }
      }
      delete pWI;
      return pNf;
}


Generated by  Doxygen 1.6.0   Back to index