The Gaudi Framework  v30r3 (a5ef0a68)
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 {
15  using time_point = Clock::time_point;
16 
17  pthread_t thread;
18  size_t slot;
19  size_t event;
20 
22 
25 };
26 
27 class GAUDI_API ITimelineSvc : virtual public IService
28 {
29 
30 public:
33 
35  class TimelineRecorder final
36  {
37  public:
39 
40  TimelineRecorder() = default;
41  TimelineRecorder( TimelineEvent& record, std::string alg, const EventContext& ctx );
42 
43  TimelineRecorder( const TimelineRecorder& ) = delete;
44  TimelineRecorder( TimelineRecorder&& other ) : m_record{other.m_record} { other.m_record = nullptr; }
45 
47  {
48  std::swap( m_record, other.m_record );
49  return *this;
50  }
51 
53  {
54  if ( m_record ) m_record->end = Clock::now();
55  }
56 
57  private:
58  TimelineEvent* m_record = nullptr;
59  };
60 
61  virtual TimelineRecorder getRecorder( std::string alg, const EventContext& ctx ) = 0;
62  // Augment a partially pre-filled TimelineEvent object with matching info
63  virtual bool getTimelineEvent( TimelineEvent& ) const = 0;
64  virtual bool isEnabled() const = 0;
65 };
66 
67 #endif
pthread_t thread
Definition: ITimelineSvc.h:17
T swap(T...args)
std::string algorithm
Definition: ITimelineSvc.h:21
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
STL class.
std::chrono::high_resolution_clock Clock
Definition: ITimelineSvc.h:14
time_point end
Definition: ITimelineSvc.h:24
Clock::time_point time_point
Definition: ITimelineSvc.h:15
General service interface definition.
Definition: IService.h:18
#define DeclareInterfaceID(iface, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
Definition: IInterface.h:13
TimelineRecorder(TimelineRecorder &&other)
Definition: ITimelineSvc.h:44
time_point start
Definition: ITimelineSvc.h:23
TimelineRecorder & operator=(TimelineRecorder &&other)
Definition: ITimelineSvc.h:46
RAII helper to record timeline events.
Definition: ITimelineSvc.h:35
#define GAUDI_API
Definition: Kernel.h:104