CMS 3D CMS Logo

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 using namespace edm::service;
29 
30 namespace {
31  void runMessageLoggerScribe(std::shared_ptr<ThreadQueue> queue) {
32  sigset_t oldset;
33  edm::disableAllSigs(&oldset);
34  MessageLoggerScribe m(queue);
35  m.run();
36  // explicitly DO NOT reenableSigs(oldset) because -
37  // 1) When this terminates, the main thread may not yet have done a join() and we
38  // don't want to handle the sigs at that point in this thread
39  // 2) If we re-enable sigs, we will get the entire stack of accumulated ones (if any)
40  }
41 } // namespace
42 
43 namespace edm {
44  namespace service {
45 
47  : Presence(),
48  m_queue(new ThreadQueue),
49  m_scribeThread(((void)MessageLoggerQ::instance() // ensure Q's static data init'd
50  ,
51  std::bind(&runMessageLoggerScribe, queue())
52  // start a new thread, run rMLS(m_queue)
53  // ChangeLog 2
54  ))
55  // Note that m_scribeThread, which is a boost::thread, has a single-argument ctor -
56  // just the function to be run. But we need to do something first, namely,
57  // ensure that the MessageLoggerQ is in a valid state - and that requires
58  // a statement. So we bundle that statement in parenthesis, separated by
59  // a comma, with the argument we really want (runMessageLoggerScribe). This
60  // creates a single argument, wheich evaluates to runMessageLoggerScribe after
61  // first executing the before-the-comma statement.
62  {
64  std::shared_ptr<edm::service::AbstractMLscribe>(std::make_shared<MainThreadMLscribe>(queue())));
65  // change log 3
66  //std::cout << "MessageServicePresence ctor\n";
67  }
68 
71  m_scribeThread.join();
72  MessageLoggerQ::setMLscribe_ptr(std::shared_ptr<edm::service::AbstractMLscribe>()); // change log 3
73  }
74 
75  } // end of namespace service
76 } // end of namespace edm
void disableAllSigs(sigset_t *oldset)
static PFTauRenderPlugin instance
std::shared_ptr< ThreadQueue const > queue() const
static void MLqEND()
static void setMLscribe_ptr(std::shared_ptr< edm::service::AbstractMLscribe > m)
HLT enums.