#include <Utilities/Threads/interface/Thread.h>
Public Member Functions | |
Thread () | |
constructor (in main thread) | |
unsigned int | tid () const |
virtual | ~Thread () |
destructor (in main thread) | |
Static Public Member Functions | |
static unsigned int | self_tid () |
static void | verboseOff () |
static void | verboseOn () |
Public Attributes | |
std::ostream | cout |
ostream | |
Protected Member Functions | |
void | finalize () |
void | initialize () |
Private Member Functions | |
virtual void | abort ()=0 |
called if exception trapped; | |
void | operator() () |
the thread main. | |
virtual void | run ()=0 |
body (in its own thread) | |
virtual void | terminate ()=0 |
called if Terminate trapped | |
Private Attributes | |
boost::thread * | t1 |
unsigned int | tid_ |
Static Private Attributes | |
static bool | verbose = false |
Friends | |
struct | Me |
Classes | |
struct | Me |
struct | Terminate |
thrown to terminate thread More... |
Definition at line 11 of file Thread.h.
Thread::Thread | ( | ) |
Thread::~Thread | ( | ) | [virtual] |
destructor (in main thread)
Definition at line 34 of file Thread.cc.
References GeneralUtilities::cout, lat::endl(), t1, and tid().
00034 { 00035 if (t1) 00036 GeneralUtilities::cout << " thread " << tid() << "still active??? " << std::endl; 00037 delete t1; t1=0; 00038 }
virtual void Thread::abort | ( | ) | [private, pure virtual] |
Definition at line 40 of file Thread.cc.
References GeneralUtilities::cout, lat::endl(), t1, tid(), and verbose.
Referenced by TSqueueConsumer< X, C >::~TSqueueConsumer().
00040 { 00041 if (Thread::verbose) GeneralUtilities::cout << "wait for thread " << tid() << std::endl; 00042 (*t1).join(); 00043 delete t1; t1=0; 00044 }
the thread main.
Definition at line 46 of file Thread.cc.
References abort(), className(), GeneralUtilities::cout, cout, Genexception::dump(), lat::endl(), run(), self_tid(), terminate(), tid_, and CMSexception::what().
00046 { 00047 tid_ = self_tid(); 00048 if (verbose) 00049 GeneralUtilities::cout << " thread starts.." << self_tid() << std::endl; 00050 00051 try{ 00052 #ifdef __linux__ 00053 LinuxElapsedTime lt(string("in Thread ")+toa()(tid_)); 00054 #endif 00055 run(); 00056 } 00057 catch ( Terminate ) { 00058 if (verbose) 00059 GeneralUtilities::cout << "thread " 00060 << self_tid() << " terminates " << std::endl; 00061 terminate(); 00062 } 00063 catch ( GenTerminate & cexp ) { 00064 GeneralUtilities::cout << "thread " 00065 << self_tid() << " termination triggered by " << std::endl; 00066 cexp.dump(cout,true); 00067 terminate(); 00068 } 00069 catch ( CMSexception & cexp) { 00070 GeneralUtilities::cout << "thread " 00071 << self_tid() << " caught CMS exception (" 00072 << className(cexp) 00073 << ") :" << endl; 00074 GeneralUtilities::cout << cexp.what() << std::endl; 00075 GeneralUtilities::cout << " inform producer...." << std::endl; 00076 UncatchedException uce; 00077 assert(&uce != 0); // Avoids warning message for unused variable uce. 00078 abort(); 00079 } 00080 catch (...) { 00081 GeneralUtilities::cout << "thread " 00082 << self_tid() << " caught unknown exception " << std::endl; 00083 GeneralUtilities::cout << " inform producer...." << std::endl; 00084 UncatchedException uce; 00085 assert(&uce != 0); // Avoids warning message for unused variable uce. 00086 abort(); 00087 } 00088 00089 }
virtual void Thread::run | ( | ) | [private, pure virtual] |
unsigned int Thread::self_tid | ( | ) | [static] |
Definition at line 25 of file Thread.cc.
Referenced by operator()(), and TSqueueConsumer< X, C >::run().
virtual void Thread::terminate | ( | ) | [private, pure virtual] |
unsigned int Thread::tid | ( | ) | const [inline] |
void Thread::verboseOff | ( | ) | [static] |
std::ostream Thread::cout |
boost::thread* Thread::t1 [private] |
unsigned int Thread::tid_ [private] |
bool Thread::verbose = false [static, private] |