| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 {
22 public:
24 TBBMessageSvc( const std::string& name, ISvcLocator* pSvcLocator );
25
26 ~TBBMessageSvc() override;
27
29 StatusCode initialize() override;
30
32 StatusCode finalize() override;
33
34 using MessageSvc::reportMessage;
35
37 void reportMessage( const Message& msg ) override;
38
40 void reportMessage( const Message& msg, int outputLevel ) override;
41
43 void reportMessage( const StatusCode& code, const std::string& source = "" ) override;
44
45 protected:
46 private:
47 // ============================================================================
48 // Helper tasks for message reporting.
49 // ============================================================================
51 class MessageTaskCommon : public Gaudi::SerialTaskQueue::WorkItem
52 {
53 public:
54 MessageTaskCommon( TBBMessageSvc& svc ) : m_svc( svc ), m_sender( std::this_thread::get_id() ) {}
55
56 protected:
57 TBBMessageSvc& m_svc;
58 std::thread::id m_sender;
59 };
60
62 class MessageWithLevel : public MessageTaskCommon
63 {
64 public:
65 MessageWithLevel( TBBMessageSvc& svc, Message msg, int level )
66 : MessageTaskCommon( svc ), m_msg( msg ), m_level( level )
67 {
68 }
69 virtual void run() override { m_svc.i_reportMessage( m_msg, m_level ); }
70
71 private:
72 Message m_msg;
73 int m_level;
74 };
75
77 class MessageWithoutLevel : public MessageTaskCommon
78 {
79 public:
80 MessageWithoutLevel( TBBMessageSvc& svc, Message msg ) : MessageTaskCommon( svc ), m_msg( msg ) {}
81 virtual void run() override
82 {
83 const int level = m_svc.outputLevel( m_msg.getSource() );
84 m_svc.i_reportMessage( m_msg, level );
85 }
86
87 private:
88 Message m_msg;
89 };
90
92 class StatusCodeMessage : public MessageTaskCommon
93 {
94 public:
95 StatusCodeMessage( TBBMessageSvc& svc, const StatusCode& sc, const std::string& source )
96 : MessageTaskCommon( svc ), m_sc( sc ), m_source( source )
97 {
98 }
99 virtual void run() override { m_svc.i_reportMessage( m_sc, m_source ); }
100
101 private:
102 StatusCode m_sc;
103 std::string m_source;
104 };
105
106 Gaudi::SerialTaskQueue m_messageQueue;
107 };
108
109 #endif // MESSAGESVC_TBBMESSAGESVC_H
TBBMessageSvc::m_messageQueue
Gaudi::SerialTaskQueue m_messageQueue
Definition: TBBMessageSvc.h:106
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:126
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
TBBMessageSvc::MessageWithLevel::run
virtual void run() override
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:69
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
TBBMessageSvc::MessageWithLevel::m_level
int m_level
Definition: TBBMessageSvc.h:73
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:366
TBBMessageSvc::reportMessage
void reportMessage(const Message &msg) override
Implementation of IMessageSvc::reportMessage()
Definition: TBBMessageSvc.cpp:49
Gaudi::SerialTaskQueue::WorkItem
Base class for the task to be executed by the serial queue.
Definition: SerialTaskQueue.h:38
std::thread::id
std
STL namespace.
Gaudi::SerialTaskQueue
Class for a generic serial queue of tasks (modeled on the Intel Threading Building Blocks Design Patt...
Definition: SerialTaskQueue.h:33
TBBMessageSvc::MessageWithoutLevel::MessageWithoutLevel
MessageWithoutLevel(TBBMessageSvc &svc, Message msg)
Definition: TBBMessageSvc.h:80
MessageSvc.h
TBBMessageSvc::TBBMessageSvc
TBBMessageSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: TBBMessageSvc.cpp:18
std::string
STL class.
TBBMessageSvc::MessageTaskCommon::m_sender
std::thread::id m_sender
Definition: TBBMessageSvc.h:58
TBBMessageSvc::MessageWithLevel
Specialized class to report a message with explicit output level.
Definition: TBBMessageSvc.h:62
TBBMessageSvc::StatusCodeMessage::run
virtual void run() override
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:99
TBBMessageSvc::StatusCodeMessage
Specialized class to report a StatusCode message.
Definition: TBBMessageSvc.h:92
TBBMessageSvc::MessageTaskCommon::m_svc
TBBMessageSvc & m_svc
Definition: TBBMessageSvc.h:57
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
CommonMessagingBase::m_level
boost::thread_specific_ptr< MSG::Level > m_level
Definition: CommonMessaging.h:152
MessageSvc::reportMessage
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:424
TBBMessageSvc
Definition: TBBMessageSvc.h:20
TBBMessageSvc::MessageWithoutLevel::run
virtual void run() override
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:81
TBBMessageSvc::StatusCodeMessage::StatusCodeMessage
StatusCodeMessage(TBBMessageSvc &svc, const StatusCode &sc, const std::string &source)
Definition: TBBMessageSvc.h:95
TBBMessageSvc::finalize
StatusCode finalize() override
Finalization of the service.
Definition: TBBMessageSvc.cpp:39
TBBMessageSvc::MessageWithLevel::m_msg
Message m_msg
Definition: TBBMessageSvc.h:72
Message
The Message class.
Definition: Message.h:15
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:592
TBBMessageSvc::MessageWithLevel::MessageWithLevel
MessageWithLevel(TBBMessageSvc &svc, Message msg, int level)
Definition: TBBMessageSvc.h:65
gaudirun.level
level
Definition: gaudirun.py:271
TBBMessageSvc::initialize
StatusCode initialize() override
Initialization of the service.
Definition: TBBMessageSvc.cpp:28
TBBMessageSvc::MessageTaskCommon::MessageTaskCommon
MessageTaskCommon(TBBMessageSvc &svc)
Definition: TBBMessageSvc.h:54
TBBMessageSvc::MessageTaskCommon
Common base class for the different reportMessage cases.
Definition: TBBMessageSvc.h:51
MessageSvc
Definition: MessageSvc.h:30
TBBMessageSvc::StatusCodeMessage::m_sc
StatusCode m_sc
Definition: TBBMessageSvc.h:102
SerialTaskQueue.h
TBBMessageSvc::StatusCodeMessage::m_source
std::string m_source
Definition: TBBMessageSvc.h:103
TBBMessageSvc::MessageWithoutLevel
Specialized class to report a message with implicit output level.
Definition: TBBMessageSvc.h:77
TBBMessageSvc::~TBBMessageSvc
~TBBMessageSvc() override
Destructor.
Definition: TBBMessageSvc.cpp:23
TBBMessageSvc::MessageWithoutLevel::m_msg
Message m_msg
Definition: TBBMessageSvc.h:88