Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 public:
32 
34  class TimelineRecorder final {
35  public:
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 
45  std::swap( m_record, other.m_record );
46  return *this;
47  }
48 
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
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:31
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:42
time_point start
Definition: ITimelineSvc.h:23
TimelineRecorder & operator=(TimelineRecorder &&other)
Definition: ITimelineSvc.h:44
RAII helper to record timeline events.
Definition: ITimelineSvc.h:34
#define GAUDI_API
Definition: Kernel.h:71