#include <Utilities/Threads/interface/TSqueue.h>
Public Types | |
typedef TSqueueConsumer< X, C > | self |
typedef TSqueue< X > | Xqueue |
Public Member Functions | |
void | interactive () |
void | push (const X &x) |
void | reset () |
size_t | size () const |
TSqueueConsumer (size_t imax=1000, size_t imin=900) | |
void | wait () |
~TSqueueConsumer () | |
Protected Attributes | |
Xqueue | inqueue |
bool | interactive_ |
Private Member Functions | |
virtual void | abort () |
called if exception trapped; | |
void | run () |
body (in its own thread) | |
virtual void | terminate () |
called if Terminate trapped |
Definition at line 131 of file TSqueue.h.
typedef TSqueueConsumer<X,C> TSqueueConsumer< X, C >::self |
typedef TSqueue<X> TSqueueConsumer< X, C >::Xqueue |
TSqueueConsumer< X, C >::TSqueueConsumer | ( | size_t | imax = 1000 , |
|
size_t | imin = 900 | |||
) | [inline, explicit] |
Definition at line 234 of file TSqueue.h.
References Thread::initialize().
00234 : 00235 inqueue(imax,imin), interactive_(false) { 00236 initialize(); 00237 }
TSqueueConsumer< X, C >::~TSqueueConsumer | ( | ) | [inline] |
Definition at line 239 of file TSqueue.h.
References Thread::finalize(), TSqueueConsumer< X, C >::inqueue, and TSqueue< X >::terminate().
virtual void TSqueueConsumer< X, C >::abort | ( | void | ) | [inline, private, virtual] |
called if exception trapped;
Implements Thread.
Definition at line 226 of file TSqueue.h.
References TSqueue< X >::abort(), GeneralUtilities::cout, lat::endl(), TSqueueConsumer< X, C >::inqueue, ClassName< T >::name(), EnvVerbosity< Tag >::silent(), and thread_self_tid().
Referenced by TSqueueConsumer< X, C >::run().
00226 { 00227 if (!GeneralVerbosity::silent()) 00228 GeneralUtilities::cout << ">>>>> consumer " << ClassName<C>::name() 00229 << " thread aborts.." << thread_self_tid() << std::endl; 00230 inqueue.abort(); 00231 }
void TSqueueConsumer< X, C >::interactive | ( | ) | [inline] |
Definition at line 246 of file TSqueue.h.
References TSqueueConsumer< X, C >::interactive_.
00246 { interactive_=true;}
void TSqueueConsumer< X, C >::push | ( | const X & | x | ) | [inline] |
Definition at line 255 of file TSqueue.h.
References TSqueueConsumer< X, C >::inqueue, and TSqueue< X >::push().
void TSqueueConsumer< X, C >::reset | ( | void | ) | [inline] |
Definition at line 244 of file TSqueue.h.
References TSqueueConsumer< X, C >::inqueue, and TSqueue< X >::reset().
void TSqueueConsumer< X, C >::run | ( | ) | [inline, private, virtual] |
body (in its own thread)
Implements Thread.
Definition at line 143 of file TSqueue.h.
References TSqueueConsumer< X, C >::abort(), funct::C, ce, className(), GeneralUtilities::cout, Genexception::dump(), lat::endl(), TSqueueConsumer< X, C >::inqueue, TSqueueConsumer< X, C >::interactive_, ClassName< T >::name(), TSqueue< X >::pop(), Thread::self_tid(), EnvVerbosity< Tag >::silent(), TSqueue< X >::size(), thread_self_tid(), and cms::Exception::what().
00143 { 00144 if (!GeneralVerbosity::silent()) 00145 GeneralUtilities::cout << ">>>>> consumer " << ClassName<C>::name() 00146 << " thread starts.." << thread_self_tid() << std::endl; 00147 00148 #ifdef __linux__ 00149 // now outside... 00150 // string mess("Thread "); mess += boost::lexical_cast<string>(thread_self_tid()); 00151 // LinuxElapsedTime totaltime(mess,cout); 00152 #endif // __linux__ 00153 00154 if (!GeneralVerbosity::silent()) 00155 GeneralUtilities::cout << thread_self_tid() << " queue size is "<< inqueue.size() << std::endl; 00156 00157 C consumer; 00158 00159 try{ // this try logic is here to avoid double throw from consumer destructor... 00160 for(;;) { 00161 try { 00162 consumer(inqueue.pop()); 00163 } 00164 catch ( Thread::Terminate ) { 00165 throw; 00166 } 00167 catch ( GenTerminate ) { 00168 if (!interactive_) throw; 00169 abort(); 00170 } 00171 catch (...) { 00172 if (!interactive_) throw; 00173 if (!GeneralVerbosity::silent()) { 00174 GeneralUtilities::cout << "thread " 00175 << self_tid() << " caught exception " << std::endl; 00176 } 00177 abort(); 00178 } 00179 } 00180 } 00181 catch ( Thread::Terminate ) { 00182 throw; 00183 } 00184 catch ( GenTerminate ) { 00185 throw; 00186 } 00187 catch ( cms::Exception & cexp) { 00188 if (!GeneralVerbosity::silent()) { 00189 GeneralUtilities::cout << "thread " 00190 << self_tid() << " caught CMS/SEAL exception (" 00191 << className(cexp) 00192 << ") :" << std::endl; 00193 Genexception * ce = dynamic_cast<Genexception *>(&cexp); 00194 if (ce) ce->dump(GeneralUtilities::cout, true); 00195 else GeneralUtilities::cout << cexp.what() << std::endl; 00196 GeneralUtilities::cout << " inform producer...." << std::endl; 00197 } 00198 UncatchedException uce(cexp); 00199 assert(&uce != 0); // Avoids warning message for unused variable uce. 00200 abort(); 00201 } 00202 catch (...) { 00203 if (!GeneralVerbosity::silent()) { 00204 GeneralUtilities::cout << "thread " 00205 << self_tid() << " caught unknown exception " << std::endl; 00206 GeneralUtilities::cout << " inform producer...." << std::endl; 00207 } 00208 UncatchedException uce; 00209 assert(&uce != 0); // Avoids warning message for unused variable uce. 00210 abort(); 00211 } 00212 00213 if (!GeneralVerbosity::silent()) 00214 GeneralUtilities::cout << ">>>>> consumer " << ClassName<C>::name() 00215 << " thread ends.." << thread_self_tid() << std::endl; 00216 }
size_t TSqueueConsumer< X, C >::size | ( | void | ) | const [inline] |
Definition at line 257 of file TSqueue.h.
References TSqueueConsumer< X, C >::inqueue, and TSqueue< X >::size().
virtual void TSqueueConsumer< X, C >::terminate | ( | void | ) | [inline, private, virtual] |
called if Terminate trapped
Implements Thread.
Definition at line 219 of file TSqueue.h.
References GeneralUtilities::cout, lat::endl(), ClassName< T >::name(), EnvVerbosity< Tag >::silent(), and thread_self_tid().
00219 { 00220 if (!GeneralVerbosity::silent()) 00221 GeneralUtilities::cout << ">>>>> consumer " << ClassName<C>::name() 00222 << " thread terminate.." << thread_self_tid() << std:: endl; 00223 }
void TSqueueConsumer< X, C >::wait | ( | void | ) | [inline] |
Definition at line 249 of file TSqueue.h.
References GeneralUtilities::cout, TSqueue< X >::drain(), lat::endl(), TSqueueConsumer< X, C >::inqueue, and EnvVerbosity< Tag >::silent().
00249 { 00250 if (!GeneralVerbosity::silent()) 00251 GeneralUtilities::cout << "wait queue to drain" << std::endl; 00252 inqueue.drain(); 00253 }
Xqueue TSqueueConsumer< X, C >::inqueue [protected] |
Definition at line 263 of file TSqueue.h.
Referenced by TSqueueConsumer< X, C >::abort(), TSqueueConsumer< X, C >::push(), TSqueueConsumer< X, C >::reset(), TSqueueConsumer< X, C >::run(), TSqueueConsumer< X, C >::size(), TSqueueConsumer< X, C >::wait(), and TSqueueConsumer< X, C >::~TSqueueConsumer().
bool TSqueueConsumer< X, C >::interactive_ [protected] |
Definition at line 264 of file TSqueue.h.
Referenced by TSqueueConsumer< X, C >::interactive(), and TSqueueConsumer< X, C >::run().