00001 // ---------------------------------------------------------------------- 00002 // 00003 // MessageService Presence.cc 00004 // 00005 // Changes: 00006 // 00007 // 1 - 2/11/07 mf Added a call to edm::disableAllSigs(&oldset) 00008 // to disable signals so that they are all handled 00009 // by the event processor thread 00010 // 00011 00012 #include "FWCore/MessageService/interface/MessageServicePresence.h" 00013 #include "FWCore/MessageService/interface/MessageLoggerScribe.h" 00014 00015 #include "FWCore/MessageLogger/interface/MessageLoggerQ.h" 00016 #include "FWCore/Utilities/interface/UnixSignalHandlers.h" 00017 00018 00019 using namespace edm::service; 00020 00021 00022 namespace { 00023 void 00024 runMessageLoggerScribe() 00025 { 00026 sigset_t oldset; 00027 edm::disableAllSigs(&oldset); 00028 MessageLoggerScribe m; 00029 m.run(); 00030 // explicitly DO NOT reenableSigs(oldset) because - 00031 // 1) When this terminates, the main thread may not yet have done a join() and we 00032 // don't want to handle the sigs at that point in this thread 00033 // 2) If we re-enable sigs, we will get the entire stack of accumulated ones (if any) 00034 } 00035 } // namespace 00036 00037 namespace edm { 00038 namespace service { 00039 00040 00041 MessageServicePresence::MessageServicePresence() 00042 : Presence() 00043 , scribe( ( (void) MessageLoggerQ::instance() // ensure Q's static data init'd 00044 , runMessageLoggerScribe // start a new thread 00045 ) ) 00046 // Note that scribe, which is a boost::thread, has a single-argument ctor - 00047 // just the function to be run. But we need to do something first, namely, 00048 // ensure that the MessageLoggerQ is in a valid state - and that requires 00049 // a statement. So we bundle that statement in parenthesis, separated by 00050 // a comma, with the argument we really want (runMessageLoggerScribe). This 00051 // creates a single argument, wheich evaluates to runMessageLoggerScribe after 00052 // first executing the before-the-comma statement. 00053 { 00054 //std::cout << "MessageServicePresence ctor\n"; 00055 } 00056 00057 00058 MessageServicePresence::~MessageServicePresence() 00059 { 00060 MessageLoggerQ::MLqEND(); 00061 scribe.join(); 00062 } 00063 00064 } // end of namespace service 00065 } // end of namespace edm