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