| The Gaudi Framework v32r1 (f65d50dc)

ITimelineSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_ITIMELINESVC_H
2 #define GAUDIKERNEL_ITIMELINESVC_H
3
4 #include "GaudiKernel/IService.h"
5
6 #include <pthread.h>
7 #include <string>
8
9 #include <chrono>
10
11 class EventContext;
12
13 struct TimelineEvent final {
14 using Clock = std::chrono::high_resolution_clock;
15 using time_point = Clock::time_point;
16
17 pthread_t thread;
18 size_t slot;
19 size_t event;
20
21 std::string algorithm;
22
23 time_point start;
24 time_point end;
25 };
26
27 class GAUDI_API ITimelineSvc : virtual public IService {
28
29 public:
31 DeclareInterfaceID( ITimelineSvc, 2, 0 );
32
34 class TimelineRecorder final {
35 public:
36 using Clock = TimelineEvent::Clock;
37
38 TimelineRecorder() = default;
39 TimelineRecorder( TimelineEvent& record, std::string alg, const EventContext& ctx );
40
41 TimelineRecorder( const TimelineRecorder& ) = delete;
42 TimelineRecorder( TimelineRecorder&& other ) : m_record{other.m_record} { other.m_record = nullptr; }
43
44 TimelineRecorder& operator=( TimelineRecorder&& other ) {
45 std::swap( m_record, other.m_record );
46 return *this;
47 }
48
49 ~TimelineRecorder() {
50 if ( m_record ) m_record->end = Clock::now();
51 }
52
53 private:
54 TimelineEvent* m_record = nullptr;
55 };
56
57 virtual TimelineRecorder getRecorder( std::string alg, const EventContext& ctx ) = 0;
58 // Augment a partially pre-filled TimelineEvent object with matching info
59 virtual bool getTimelineEvent( TimelineEvent& ) const = 0;
60 virtual bool isEnabled() const = 0;
61 };
62
63 #endif
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:69
TimelineEvent::thread
pthread_t thread
Definition: ITimelineSvc.h:17
std::swap
T swap(T... args)
TimelineEvent::algorithm
std::string algorithm
Definition: ITimelineSvc.h:21
TimelineEvent
Definition: ITimelineSvc.h:13
EventContext
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
std::string
STL class.
TimelineEvent::Clock
std::chrono::high_resolution_clock Clock
Definition: ITimelineSvc.h:14
TimelineEvent::end
time_point end
Definition: ITimelineSvc.h:24
std::chrono::high_resolution_clock
TimelineEvent::time_point
Clock::time_point time_point
Definition: ITimelineSvc.h:15
ITimelineSvc::TimelineRecorder::~TimelineRecorder
~TimelineRecorder()
Definition: ITimelineSvc.h:49
IService
General service interface definition.
Definition: IService.h:18
ITimelineSvc::TimelineRecorder::TimelineRecorder
TimelineRecorder(TimelineRecorder &&other)
Definition: ITimelineSvc.h:42
ITimelineSvc
Definition: ITimelineSvc.h:27
IService.h
TimelineEvent::start
time_point start
Definition: ITimelineSvc.h:23
ITimelineSvc::TimelineRecorder::operator=
TimelineRecorder & operator=(TimelineRecorder &&other)
Definition: ITimelineSvc.h:44
TimelineEvent::event
size_t event
Definition: ITimelineSvc.h:19
ITimelineSvc::TimelineRecorder
RAII helper to record timeline events.
Definition: ITimelineSvc.h:34
TimelineEvent::slot
size_t slot
Definition: ITimelineSvc.h:18
IService::DeclareInterfaceID
DeclareInterfaceID(IService, 4, 0)
InterfaceID.
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71