CMS 3D CMS Logo

TSqueue< X > Class Template Reference

internal class More...

#include <Utilities/Threads/interface/TSqueue.h>

List of all members.

Public Types

typedef TSqueue< X > self

Public Member Functions

void abort ()
 abort (called by a consumer to inform producer)
void clear ()
void drain ()
 drain queue (wait for) (run in producer)
pop ()
 (run in consumer)
void push (const X &x)
 (run in producer)
void reset ()
size_t size () const
void terminate ()
 terminate (called by producer to inform consumer)
 TSqueue (size_t imax=1000, size_t imin=900)

Private Attributes

bool abort_
std::queue< X, std::deque< X > > cont
boost::condition dodrain
bool draining_
SimpleLockMutex::Mutex genLock
size_t maxSize
size_t minSize
boost::condition notEmpty
boost::condition notFull
bool terminate_


Detailed Description

template<class X>
class TSqueue< X >

internal class

Definition at line 24 of file TSqueue.h.


Member Typedef Documentation

template<class X>
typedef TSqueue<X> TSqueue< X >::self

Definition at line 28 of file TSqueue.h.


Constructor & Destructor Documentation

template<class X>
TSqueue< X >::TSqueue ( size_t  imax = 1000,
size_t  imin = 900 
) [inline, explicit]

Definition at line 32 of file TSqueue.h.

00032                                                       : 
00033     maxSize(imax), minSize(imin),
00034     draining_(false), terminate_(false), abort_(false) {
00035     if (minSize<1) minSize=1;
00036   }


Member Function Documentation

template<class X>
void TSqueue< X >::abort ( void   )  [inline]

abort (called by a consumer to inform producer)

Definition at line 76 of file TSqueue.h.

Referenced by TSqueueConsumer< X, C >::abort().

00076                {
00077     SimpleLockMutex gl(genLock);
00078     abort_ = true;
00079     clear();
00080     notFull.notify_all(); 
00081     if (draining_) dodrain.notify_all();
00082   }

template<class X>
void TSqueue< X >::clear ( void   )  [inline]

Definition at line 101 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::abort().

00101                {
00102     while(!cont.empty()) cont.pop();
00103   }

template<class X>
void TSqueue< X >::drain (  )  [inline]

drain queue (wait for) (run in producer)

Definition at line 85 of file TSqueue.h.

Referenced by TSqueueConsumer< X, C >::wait().

00085                {
00086     SimpleLockMutex gl(genLock);
00087     if (cont.empty()) return;
00088     draining_=true;
00089     notEmpty.notify_all();
00090     while(!cont.empty()) {
00091       dodrain.wait(gl());
00092       if (abort_) throw TSqueue_termination();
00093     }
00094   }

template<class X>
X TSqueue< X >::pop ( void   )  [inline]

(run in consumer)

Definition at line 55 of file TSqueue.h.

Referenced by VisQueueProcessor::process(), and TSqueueConsumer< X, C >::run().

00055           {
00056     SimpleLockMutex gl(genLock);
00057     while(cont.empty()) {
00058       if (draining_) dodrain.notify_all();
00059       if (terminate_) throw TSqueue_termination();
00060       notEmpty.wait(gl());
00061     }
00062     X x = cont.front();
00063     cont.pop();
00064     if (cont.size()<minSize) notFull.notify_all(); 
00065     return x;
00066   }

template<class X>
void TSqueue< X >::push ( const X &  x  )  [inline]

(run in producer)

Definition at line 43 of file TSqueue.h.

Referenced by TSqueueConsumer< X, C >::push().

00043                         {
00044     SimpleLockMutex gl(genLock);
00045     if (abort_) throw TSqueue_termination();
00046     while(cont.size()>maxSize) {
00047       notFull.wait(gl());
00048       if (abort_) throw TSqueue_termination();
00049     }
00050     cont.push(x);    
00051     if ( !(cont.size()<minSize )) { notEmpty.notify_all(); } 
00052   }

template<class X>
void TSqueue< X >::reset ( void   )  [inline]

Definition at line 38 of file TSqueue.h.

Referenced by TSqueueConsumer< X, C >::reset().

00038                {
00039     draining_=terminate_=abort_=false;
00040   }

template<class X>
size_t TSqueue< X >::size ( void   )  const [inline]

Definition at line 96 of file TSqueue.h.

Referenced by TSqueueConsumer< X, C >::run(), and TSqueueConsumer< X, C >::size().

00096                       {
00097     SimpleLockMutex gl(genLock);
00098     return cont.size();
00099   }

template<class X>
void TSqueue< X >::terminate ( void   )  [inline]

terminate (called by producer to inform consumer)

Definition at line 69 of file TSqueue.h.

Referenced by TSqueueConsumer< X, C >::~TSqueueConsumer().

00069                    {
00070     SimpleLockMutex gl(genLock);
00071     terminate_ = true;
00072     notEmpty.notify_all();
00073   }


Member Data Documentation

template<class X>
bool TSqueue< X >::abort_ [private]

Definition at line 124 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::abort(), TSqueue< lat::Callback >::drain(), TSqueue< lat::Callback >::push(), and TSqueue< lat::Callback >::reset().

template<class X>
std::queue<X,std::deque<X> > TSqueue< X >::cont [private]

Definition at line 110 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::clear(), TSqueue< lat::Callback >::drain(), TSqueue< lat::Callback >::pop(), TSqueue< lat::Callback >::push(), and TSqueue< lat::Callback >::size().

template<class X>
boost::condition TSqueue< X >::dodrain [private]

Definition at line 118 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::abort(), TSqueue< lat::Callback >::drain(), and TSqueue< lat::Callback >::pop().

template<class X>
bool TSqueue< X >::draining_ [private]

Definition at line 121 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::abort(), TSqueue< lat::Callback >::drain(), TSqueue< lat::Callback >::pop(), and TSqueue< lat::Callback >::reset().

template<class X>
SimpleLockMutex::Mutex TSqueue< X >::genLock [mutable, private]

Definition at line 115 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::abort(), TSqueue< lat::Callback >::drain(), TSqueue< lat::Callback >::pop(), TSqueue< lat::Callback >::push(), TSqueue< lat::Callback >::size(), and TSqueue< lat::Callback >::terminate().

template<class X>
size_t TSqueue< X >::maxSize [private]

Definition at line 112 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::push().

template<class X>
size_t TSqueue< X >::minSize [private]

Definition at line 113 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::pop(), TSqueue< lat::Callback >::push(), and TSqueue< lat::Callback >::TSqueue().

template<class X>
boost::condition TSqueue< X >::notEmpty [private]

Definition at line 116 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::drain(), TSqueue< lat::Callback >::pop(), TSqueue< lat::Callback >::push(), and TSqueue< lat::Callback >::terminate().

template<class X>
boost::condition TSqueue< X >::notFull [private]

Definition at line 117 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::abort(), TSqueue< lat::Callback >::pop(), and TSqueue< lat::Callback >::push().

template<class X>
bool TSqueue< X >::terminate_ [private]

Definition at line 123 of file TSqueue.h.

Referenced by TSqueue< lat::Callback >::pop(), TSqueue< lat::Callback >::reset(), and TSqueue< lat::Callback >::terminate().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:34:39 2009 for CMSSW by  doxygen 1.5.4