| The Gaudi Framework v32r1 (f65d50dc)

TBBMessageSvc.h
Go to the documentation of this file.
1 #ifndef MESSAGESVC_TBBMESSAGESVC_H
2 #define MESSAGESVC_TBBMESSAGESVC_H 1
3 // Include files
4 #include "MessageSvc.h"
5
6 #include "GaudiKernel/SerialTaskQueue.h"
7
8 // just needed for the thread id
9 #include <thread>
10
11 #include <thread>
12
20 class TBBMessageSvc : public MessageSvc {
21 public:
22 using MessageSvc::MessageSvc;
23
24 using MessageSvc::reportMessage;
25
27 void reportMessage( const Message& msg ) override;
28
30 void reportMessage( const Message& msg, int outputLevel ) override;
31
33 void reportMessage( const StatusCode& code, const std::string& source = "" ) override;
34
35 private:
36 // ============================================================================
37 // Helper tasks for message reporting.
38 // ============================================================================
40 class MessageTaskCommon : public Gaudi::SerialTaskQueue::WorkItem {
41 public:
42 MessageTaskCommon( TBBMessageSvc& svc ) : m_svc( svc ), m_sender( std::this_thread::get_id() ) {}
43
44 protected:
45 TBBMessageSvc& m_svc;
46 std::thread::id m_sender;
47 };
48
50 class MessageWithLevel : public MessageTaskCommon {
51 public:
52 MessageWithLevel( TBBMessageSvc& svc, Message msg, int level )
53 : MessageTaskCommon( svc ), m_msg( msg ), m_level( level ) {}
54 void run() override { m_svc.i_reportMessage( m_msg, m_level ); }
55
56 private:
57 Message m_msg;
58 int m_level;
59 };
60
62 class MessageWithoutLevel : public MessageTaskCommon {
63 public:
64 MessageWithoutLevel( TBBMessageSvc& svc, Message msg ) : MessageTaskCommon( svc ), m_msg( msg ) {}
65 void run() override {
66 const int level = m_svc.outputLevel( m_msg.getSource() );
67 m_svc.i_reportMessage( m_msg, level );
68 }
69
70 private:
71 Message m_msg;
72 };
73
75 class StatusCodeMessage : public MessageTaskCommon {
76 public:
77 StatusCodeMessage( TBBMessageSvc& svc, const StatusCode& sc, const std::string& source )
78 : MessageTaskCommon( svc ), m_sc( sc ), m_source( source ) {}
79 void run() override { m_svc.i_reportMessage( m_sc, m_source ); }
80
81 private:
82 StatusCode m_sc;
83 std::string m_source;
84 };
85
86 Gaudi::SerialTaskQueue m_messageQueue;
87 };
88
89 #endif // MESSAGESVC_TBBMESSAGESVC_H
TBBMessageSvc::m_messageQueue
Gaudi::SerialTaskQueue m_messageQueue
Definition: TBBMessageSvc.h:86
TBBMessageSvc::StatusCodeMessage::run
void run() override
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:79
TBBMessageSvc::MessageWithLevel::m_level
int m_level
Definition: TBBMessageSvc.h:58
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:356
TBBMessageSvc::MessageWithoutLevel::run
void run() override
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:65
TBBMessageSvc::reportMessage
void reportMessage(const Message &msg) override
Implementation of IMessageSvc::reportMessage()
Definition: TBBMessageSvc.cpp:14
Gaudi::SerialTaskQueue::WorkItem
Base class for the task to be executed by the serial queue.
Definition: SerialTaskQueue.h:36
std::thread::id
std
STL namespace.
MessageSvc::MessageSvc
MessageSvc(const std::string &name, ISvcLocator *svcloc)
Definition: MessageSvc.cpp:78
Gaudi::SerialTaskQueue
Class for a generic serial queue of tasks (modeled on the Intel Threading Building Blocks Design Patt...
Definition: SerialTaskQueue.h:32
TBBMessageSvc::MessageWithoutLevel::MessageWithoutLevel
MessageWithoutLevel(TBBMessageSvc &svc, Message msg)
Definition: TBBMessageSvc.h:64
MessageSvc.h
Message::getSource
const std::string & getSource() const
Get the message source.
Definition: Message.cpp:78
std::string
STL class.
TBBMessageSvc::MessageTaskCommon::m_sender
std::thread::id m_sender
Definition: TBBMessageSvc.h:46
TBBMessageSvc::MessageWithLevel
Specialized class to report a message with explicit output level.
Definition: TBBMessageSvc.h:50
TBBMessageSvc::StatusCodeMessage
Specialized class to report a StatusCode message.
Definition: TBBMessageSvc.h:75
TBBMessageSvc::MessageTaskCommon::m_svc
TBBMessageSvc & m_svc
Definition: TBBMessageSvc.h:45
TBBMessageSvc::MessageWithLevel::run
void run() override
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:54
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
MessageSvc::reportMessage
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:409
TBBMessageSvc
Definition: TBBMessageSvc.h:20
TBBMessageSvc::StatusCodeMessage::StatusCodeMessage
StatusCodeMessage(TBBMessageSvc &svc, const StatusCode &sc, const std::string &source)
Definition: TBBMessageSvc.h:77
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:113
TBBMessageSvc::MessageWithLevel::m_msg
Message m_msg
Definition: TBBMessageSvc.h:57
Message
The Message class.
Definition: Message.h:17
TBBMessageSvc::MessageWithLevel::MessageWithLevel
MessageWithLevel(TBBMessageSvc &svc, Message msg, int level)
Definition: TBBMessageSvc.h:52
gaudirun.level
level
Definition: gaudirun.py:334
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:566
TBBMessageSvc::MessageTaskCommon::MessageTaskCommon
MessageTaskCommon(TBBMessageSvc &svc)
Definition: TBBMessageSvc.h:42
TBBMessageSvc::MessageTaskCommon
Common base class for the different reportMessage cases.
Definition: TBBMessageSvc.h:40
MessageSvc
Definition: MessageSvc.h:30
TBBMessageSvc::StatusCodeMessage::m_sc
StatusCode m_sc
Definition: TBBMessageSvc.h:82
SerialTaskQueue.h
TBBMessageSvc::StatusCodeMessage::m_source
std::string m_source
Definition: TBBMessageSvc.h:83
TBBMessageSvc::MessageWithoutLevel
Specialized class to report a message with implicit output level.
Definition: TBBMessageSvc.h:62
TBBMessageSvc::MessageWithoutLevel::m_msg
Message m_msg
Definition: TBBMessageSvc.h:71