CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MessageServicePresence.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 //
3 // MessageService Presence.cc
4 //
5 // Changes:
6 //
7 // 1 - 2/11/07 mf Added a call to edm::disableAllSigs(&oldset)
8 // to disable signals so that they are all handled
9 // by the event processor thread
10 //
11 // 2 - 8/10/09 mf Mods to support the use of abstract scribes
12 // cdj so that standalones can work easily
13 //
14 //
15 // 2 - 8/12/09 mf Mods to get ownership of mlscribe better
16 // cdj
17 //
18 //
19 
24 
27 
28 #include <boost/bind.hpp>
29 
30 using namespace edm::service;
31 
32 
33 namespace {
34 void
35  runMessageLoggerScribe(boost::shared_ptr<ThreadQueue> queue)
36 {
37  sigset_t oldset;
38  edm::disableAllSigs(&oldset);
39  MessageLoggerScribe m(queue);
40  m.run();
41  // explicitly DO NOT reenableSigs(oldset) because -
42  // 1) When this terminates, the main thread may not yet have done a join() and we
43  // don't want to handle the sigs at that point in this thread
44  // 2) If we re-enable sigs, we will get the entire stack of accumulated ones (if any)
45 }
46 } // namespace
47 
48 namespace edm {
49 namespace service {
50 
51 
53  : Presence()
54  , m_queue (new ThreadQueue)
55  , m_scribeThread
56  ( ( (void) MessageLoggerQ::instance() // ensure Q's static data init'd
57  , boost::bind(&runMessageLoggerScribe, m_queue)
58  // start a new thread, run rMLS(m_queue)
59  // ChangeLog 2
60  ) )
61  // Note that m_scribeThread, which is a boost::thread, has a single-argument ctor -
62  // just the function to be run. But we need to do something first, namely,
63  // ensure that the MessageLoggerQ is in a valid state - and that requires
64  // a statement. So we bundle that statement in parenthesis, separated by
65  // a comma, with the argument we really want (runMessageLoggerScribe). This
66  // creates a single argument, wheich evaluates to runMessageLoggerScribe after
67  // first executing the before-the-comma statement.
68 {
70  boost::shared_ptr<edm::service::AbstractMLscribe>
71  (new MainThreadMLscribe(m_queue)));
72  // change log 3
73  //std::cout << "MessageServicePresence ctor\n";
74 }
75 
76 
78 {
80  m_scribeThread.join();
82  (boost::shared_ptr<edm::service::AbstractMLscribe>()); // change log 3
83 }
84 
85 } // end of namespace service
86 } // end of namespace edm
static void setMLscribe_ptr(boost::shared_ptr< edm::service::AbstractMLscribe > m)
void disableAllSigs(sigset_t *oldset)
static PFTauRenderPlugin instance
boost::shared_ptr< ThreadQueue > m_queue
static void MLqEND()