The Gaudi Framework  master (37c0b60a)
ITimelineSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_ITIMELINESVC_H
12 #define GAUDIKERNEL_ITIMELINESVC_H
13 
14 #include <GaudiKernel/IService.h>
15 
16 #include <pthread.h>
17 #include <string>
18 
19 #include <chrono>
20 
21 class EventContext;
22 
23 struct TimelineEvent final {
25  using time_point = Clock::time_point;
26 
27  pthread_t thread;
28  size_t slot;
29  size_t event;
30 
32 
35 };
36 
37 class GAUDI_API ITimelineSvc : virtual public IService {
38 
39 public:
42 
44  class TimelineRecorder final {
45  public:
47 
48  TimelineRecorder() = default;
50 
51  TimelineRecorder( const TimelineRecorder& ) = delete;
52  TimelineRecorder( TimelineRecorder&& other ) : m_record{ other.m_record } { other.m_record = nullptr; }
53 
55  std::swap( m_record, other.m_record );
56  return *this;
57  }
58 
60  if ( m_record ) m_record->end = Clock::now();
61  }
62 
63  private:
64  TimelineEvent* m_record = nullptr;
65  };
66 
68  // Augment a partially pre-filled TimelineEvent object with matching info
69  virtual bool getTimelineEvent( TimelineEvent& ) const = 0;
70  virtual bool isEnabled() const = 0;
71 };
72 
73 #endif
IService
Definition: IService.h:28
TimelineEvent::time_point
Clock::time_point time_point
Definition: ITimelineSvc.h:25
ITimelineSvc::getTimelineEvent
virtual bool getTimelineEvent(TimelineEvent &) const =0
ITimelineSvc::TimelineRecorder::TimelineRecorder
TimelineRecorder(TimelineRecorder &&other)
Definition: ITimelineSvc.h:52
IService.h
std::string
STL class.
ITimelineSvc::TimelineRecorder::~TimelineRecorder
~TimelineRecorder()
Definition: ITimelineSvc.h:59
TimelineEvent::start
time_point start
Definition: ITimelineSvc.h:33
ITimelineSvc::isEnabled
virtual bool isEnabled() const =0
TimelineEvent::event
size_t event
Definition: ITimelineSvc.h:29
std::chrono::high_resolution_clock
TimelineEvent::slot
size_t slot
Definition: ITimelineSvc.h:28
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:81
TimelineEvent
Definition: ITimelineSvc.h:23
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:578
ITimelineSvc
Definition: ITimelineSvc.h:37
ITimelineSvc::DeclareInterfaceID
DeclareInterfaceID(ITimelineSvc, 2, 0)
InterfaceID.
ITimelineSvc::TimelineRecorder
RAII helper to record timeline events.
Definition: ITimelineSvc.h:44
ITimelineSvc::getRecorder
virtual TimelineRecorder getRecorder(std::string alg, const EventContext &ctx)=0
ITimelineSvc::TimelineRecorder::TimelineRecorder
TimelineRecorder(const TimelineRecorder &)=delete
ITimelineSvc::TimelineRecorder::TimelineRecorder
TimelineRecorder()=default
std::swap
T swap(T... args)
TimelineEvent::thread
pthread_t thread
Definition: ITimelineSvc.h:27
ITimelineSvc::TimelineRecorder::operator=
TimelineRecorder & operator=(TimelineRecorder &&other)
Definition: ITimelineSvc.h:54
EventContext
Definition: EventContext.h:34
TimelineEvent::algorithm
std::string algorithm
Definition: ITimelineSvc.h:31
TimelineEvent::Clock
std::chrono::high_resolution_clock Clock
Definition: ITimelineSvc.h:24
TimelineEvent::end
time_point end
Definition: ITimelineSvc.h:34
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81