| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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 public:
23 TBBMessageSvc(const std::string& name, ISvcLocator* pSvcLocator);
24
25 ~TBBMessageSvc() override;
26
28 StatusCode initialize() override;
29
31 StatusCode finalize() override;
32
33 using MessageSvc::reportMessage;
34
36 void reportMessage(const Message& msg) override;
37
39 void reportMessage(const Message& msg, int outputLevel) override;
40
42 void reportMessage(const StatusCode& code, const std::string& source = "") override;
43
44 protected:
45 private:
46
47 // ============================================================================
48 // Helper tasks for message reporting.
49 // ============================================================================
51 class MessageTaskCommon: public Gaudi::SerialTaskQueue::WorkItem {
52 public:
53 MessageTaskCommon(TBBMessageSvc& svc):
54 m_svc(svc),
55 m_sender(std::this_thread::get_id()) {}
56 protected:
57 TBBMessageSvc& m_svc;
58 std::thread::id m_sender;
59 };
60
62 class MessageWithLevel: public MessageTaskCommon {
63 public:
64 MessageWithLevel(TBBMessageSvc& svc, Message msg, int level):
65 MessageTaskCommon(svc),
66 m_msg(msg), m_level(level) {}
67 virtual void run() override {
68 m_svc.i_reportMessage(m_msg, m_level);
69 }
70 private:
71 Message m_msg;
72 int m_level;
73 };
74
76 class MessageWithoutLevel: public MessageTaskCommon {
77 public:
78 MessageWithoutLevel(TBBMessageSvc& svc, Message msg):
79 MessageTaskCommon(svc),
80 m_msg(msg) {}
81 virtual void run() override {
82 const int level = m_svc.outputLevel(m_msg.getSource());
83 m_svc.i_reportMessage(m_msg, level);
84 }
85 private:
86 Message m_msg;
87 };
88
90 class StatusCodeMessage: public MessageTaskCommon {
91 public:
92 StatusCodeMessage(TBBMessageSvc& svc, const StatusCode &sc, const std::string& source):
93 MessageTaskCommon(svc),
94 m_sc(sc),
95 m_source(source) {}
96 virtual void run() override {
97 m_svc.i_reportMessage(m_sc, m_source);
98 }
99 private:
100 StatusCode m_sc;
101 std::string m_source;
102 };
103
104 Gaudi::SerialTaskQueue m_messageQueue;
105 };
106
107 #endif // MESSAGESVC_TBBMESSAGESVC_H
TBBMessageSvc::m_messageQueue
Gaudi::SerialTaskQueue m_messageQueue
Definition: TBBMessageSvc.h:104
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:132
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:67
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:72
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:350
TBBMessageSvc::reportMessage
void reportMessage(const Message &msg) override
Implementation of IMessageSvc::reportMessage()
Definition: TBBMessageSvc.cpp:50
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.
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:78
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
CommonMessagingBase::m_level
MSG::Level m_level
Definition: CommonMessaging.h:152
TBBMessageSvc::StatusCodeMessage::run
virtual void run() override
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:96
TBBMessageSvc::StatusCodeMessage
Specialized class to report a StatusCode message.
Definition: TBBMessageSvc.h:90
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:26
MessageSvc::reportMessage
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:408
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:92
TBBMessageSvc::finalize
StatusCode finalize() override
Finalization of the service.
Definition: TBBMessageSvc.cpp:42
TBBMessageSvc::MessageWithLevel::m_msg
Message m_msg
Definition: TBBMessageSvc.h:71
Message
The Message class.
Definition: Message.h:15
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:576
TBBMessageSvc::MessageWithLevel::MessageWithLevel
MessageWithLevel(TBBMessageSvc &svc, Message msg, int level)
Definition: TBBMessageSvc.h:64
gaudirun.level
level
Definition: gaudirun.py:261
TBBMessageSvc::initialize
StatusCode initialize() override
Initialization of the service.
Definition: TBBMessageSvc.cpp:32
TBBMessageSvc::MessageTaskCommon::MessageTaskCommon
MessageTaskCommon(TBBMessageSvc &svc)
Definition: TBBMessageSvc.h:53
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:100
SerialTaskQueue.h
TBBMessageSvc::StatusCodeMessage::m_source
std::string m_source
Definition: TBBMessageSvc.h:101
TBBMessageSvc::MessageWithoutLevel
Specialized class to report a message with implicit output level.
Definition: TBBMessageSvc.h:76
TBBMessageSvc::~TBBMessageSvc
~TBBMessageSvc() override
Destructor.
Definition: TBBMessageSvc.cpp:26
TBBMessageSvc::MessageWithoutLevel::m_msg
Message m_msg
Definition: TBBMessageSvc.h:86