(file) Return to AsyncQueue.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/AsyncQueue.h between version 1.7 and 1.8

version 1.7, 2008/09/16 18:37:03 version 1.8, 2008/09/17 18:47:22
Line 37 
Line 37 
 #include <Pegasus/Common/Linkage.h> #include <Pegasus/Common/Linkage.h>
 #include <Pegasus/Common/List.h> #include <Pegasus/Common/List.h>
 #include <Pegasus/Common/Condition.h> #include <Pegasus/Common/Condition.h>
 #include <Pegasus/Common/IPCExceptions.h>  
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 56 
Line 55 
     */     */
     virtual ~AsyncQueue();     virtual ~AsyncQueue();
  
     /** Close the queue so that subsequent enqueue() and dequeue() requests      /** Close the queue.
         result in ListClosed() exceptions.  
     */     */
     void close();     void close();
  
     /** Enqueue an element at the back of queue.     /** Enqueue an element at the back of queue.
           @param element The element to enqueue.
           @return True if the element is successfully enqueued, false if the
               queue is closed.
     */     */
     void enqueue(ElemType *element);      Boolean enqueue(ElemType *element);
  
     /** Dequeue an element from the front of the queue. Return null immediately     /** Dequeue an element from the front of the queue. Return null immediately
         if queue is empty.          if queue is empty or closed.
           @return A pointer to the element that was dequeued, or null if the
               queue is empty or closed.
     */     */
     ElemType *dequeue();     ElemType *dequeue();
  
     /** Dequeue an element from the front of the queue (wait if the queue is     /** Dequeue an element from the front of the queue (wait if the queue is
         empty).         empty).
           @return A pointer to the element that was dequeued, or null if the
               queue is closed (either before or while waiting for an element).
     */     */
     ElemType *dequeue_wait();     ElemType *dequeue_wait();
  
Line 125 
Line 130 
 } }
  
 template<class ElemType> template<class ElemType>
 void AsyncQueue<ElemType>::enqueue(ElemType *element)  Boolean AsyncQueue<ElemType>::enqueue(ElemType *element)
 { {
     if (element)     if (element)
     {     {
         AutoMutex auto_mutex(_mutex);         AutoMutex auto_mutex(_mutex);
  
         if (is_closed())         if (is_closed())
             throw ListClosed();          {
               return false;
           }
  
         _rep.insert_back(element);         _rep.insert_back(element);
         _not_empty.signal();         _not_empty.signal();
     }     }
   
       return true;
 } }
  
 template<class ElemType> template<class ElemType>
Line 152 
Line 161 
     AutoMutex auto_mutex(_mutex);     AutoMutex auto_mutex(_mutex);
  
     if (is_closed())     if (is_closed())
         throw ListClosed();      {
           return 0;
       }
  
     return _rep.remove_front();     return _rep.remove_front();
 } }
Line 165 
Line 176 
     while (is_empty())     while (is_empty())
     {     {
         if (is_closed())         if (is_closed())
             throw ListClosed();          {
               return 0;
           }
  
         _not_empty.wait(_mutex);         _not_empty.wait(_mutex);
     }     }
  
     if (is_closed())     if (is_closed())
         throw ListClosed();      {
           return 0;
       }
  
     ElemType* p = _rep.remove_front();     ElemType* p = _rep.remove_front();
     PEGASUS_DEBUG_ASSERT(p != 0);     PEGASUS_DEBUG_ASSERT(p != 0);


Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2