CMS 3D CMS Logo

SonicClientBase.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_SonicCore_SonicClientBase
2 #define HeterogeneousCore_SonicCore_SonicClientBase
3 
10 
11 #include <string>
12 #include <chrono>
13 #include <exception>
14 #include <memory>
15 #include <optional>
16 
17 enum class SonicMode { Sync = 1, Async = 2, PseudoAsync = 3 };
18 
20 public:
21  //constructor
23 
24  //destructor
25  virtual ~SonicClientBase() = default;
26 
27  void setDebugName(const std::string& debugName);
28  const std::string& debugName() const { return debugName_; }
29  const std::string& clientName() const { return clientName_; }
30  SonicMode mode() const { return mode_; }
31 
32  //main operation
33  virtual void dispatch(edm::WaitingTaskWithArenaHolder holder) { dispatcher_->dispatch(std::move(holder)); }
34 
35  //alternate operation when ExternalWork is not used
36  virtual void dispatch() { dispatcher_->dispatch(); }
37 
38  //helper: does nothing by default
39  virtual void reset() {}
40 
41  //provide base params
42  static void fillBasePSetDescription(edm::ParameterSetDescription& desc, bool allowRetry = true);
43 
44 protected:
45  virtual void evaluate() = 0;
46 
48 
49  void start();
50 
51  void finish(bool success, std::exception_ptr eptr = std::exception_ptr{});
52 
53  //members
55  std::unique_ptr<SonicDispatcher> dispatcher_;
56  unsigned allowedTries_, tries_;
57  std::optional<edm::WaitingTaskWithArenaHolder> holder_;
58 
59  //for logging/debugging
61  std::chrono::time_point<std::chrono::high_resolution_clock> t0_;
62 
63  friend class SonicDispatcher;
65 };
66 
67 #endif
SonicClientBase::fillBasePSetDescription
static void fillBasePSetDescription(edm::ParameterSetDescription &desc, bool allowRetry=true)
Definition: SonicClientBase.cc:71
MessageLogger.h
SonicClientBase::dispatch
virtual void dispatch()
Definition: SonicClientBase.h:36
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
SonicClientBase::~SonicClientBase
virtual ~SonicClientBase()=default
SonicMode
SonicMode
Definition: SonicClientBase.h:17
SonicDispatcherPseudoAsync.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
SonicClientBase::finish
void finish(bool success, std::exception_ptr eptr=std::exception_ptr{})
Definition: SonicClientBase.cc:42
SonicClientBase::debugName
const std::string & debugName() const
Definition: SonicClientBase.h:28
SonicClientBase::tries_
unsigned tries_
Definition: SonicClientBase.h:56
SonicClientBase
Definition: SonicClientBase.h:19
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:31
SonicDispatcherPseudoAsync
Definition: SonicDispatcherPseudoAsync.h:16
SonicClientBase::clientName
const std::string & clientName() const
Definition: SonicClientBase.h:29
summarizeEdmComparisonLogfiles.success
success
Definition: summarizeEdmComparisonLogfiles.py:115
SonicClientBase::evaluate
virtual void evaluate()=0
ParameterSetDescription.h
SonicClientBase::reset
virtual void reset()
Definition: SonicClientBase.h:39
SonicMode::PseudoAsync
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SonicDispatcher
Definition: SonicDispatcher.h:8
SonicMode::Sync
SonicClientBase::setDebugName
void setDebugName(const std::string &debugName)
Definition: SonicClientBase.cc:24
SonicClientBase::mode_
SonicMode mode_
Definition: SonicClientBase.h:54
SonicClientBase::SonicClientBase
SonicClientBase(const edm::ParameterSet &params)
Definition: SonicClientBase.cc:5
edm::ParameterSet
Definition: ParameterSet.h:47
SonicMode::Async
SonicClientBase::fullDebugName_
std::string fullDebugName_
Definition: SonicClientBase.h:60
WaitingTaskWithArenaHolder.h
SonicClientBase::debugName_
std::string debugName_
Definition: SonicClientBase.h:60
SonicDispatcher.h
SonicClientBase::allowedTries_
unsigned allowedTries_
Definition: SonicClientBase.h:56
SonicClientBase::dispatcher_
std::unique_ptr< SonicDispatcher > dispatcher_
Definition: SonicClientBase.h:55
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
SonicClientBase::t0_
std::chrono::time_point< std::chrono::high_resolution_clock > t0_
Definition: SonicClientBase.h:61
SonicClientBase::start
void start()
Definition: SonicClientBase.cc:36
SonicClientBase::dispatch
virtual void dispatch(edm::WaitingTaskWithArenaHolder holder)
Definition: SonicClientBase.h:33
ParameterSet.h
SonicClientBase::mode
SonicMode mode() const
Definition: SonicClientBase.h:30
SonicClientBase::clientName_
std::string clientName_
Definition: SonicClientBase.h:60
SonicClientBase::holder_
std::optional< edm::WaitingTaskWithArenaHolder > holder_
Definition: SonicClientBase.h:57