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  const std::string& debugName() const { return debugName_; }
28  const std::string& clientName() const { return clientName_; }
29  SonicMode mode() const { return mode_; }
30 
31  //main operation
32  virtual void dispatch(edm::WaitingTaskWithArenaHolder holder) { dispatcher_->dispatch(std::move(holder)); }
33 
34  //alternate operation when ExternalWork is not used
35  virtual void dispatch() { dispatcher_->dispatch(); }
36 
37  //helper: does nothing by default
38  virtual void reset() {}
39 
40  //provide base params
41  static void fillBasePSetDescription(edm::ParameterSetDescription& desc, bool allowRetry = true);
42 
43 protected:
44  void setMode(SonicMode mode);
45 
46  virtual void evaluate() = 0;
47 
49 
50  void start();
51 
52  void finish(bool success, std::exception_ptr eptr = std::exception_ptr{});
53 
54  //members
56  std::unique_ptr<SonicDispatcher> dispatcher_;
57  unsigned allowedTries_, tries_;
58  std::optional<edm::WaitingTaskWithArenaHolder> holder_;
59 
60  //for logging/debugging
62  std::chrono::time_point<std::chrono::high_resolution_clock> t0_;
63 
64  friend class SonicDispatcher;
66 };
67 
68 #endif
SonicClientBase::fillBasePSetDescription
static void fillBasePSetDescription(edm::ParameterSetDescription &desc, bool allowRetry=true)
Definition: SonicClientBase.cc:78
MessageLogger.h
SonicClientBase::dispatch
virtual void dispatch()
Definition: SonicClientBase.h:35
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:49
SonicClientBase::debugName
const std::string & debugName() const
Definition: SonicClientBase.h:27
SonicClientBase::tries_
unsigned tries_
Definition: SonicClientBase.h:57
SonicClientBase
Definition: SonicClientBase.h:19
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:34
SonicDispatcherPseudoAsync
Definition: SonicDispatcherPseudoAsync.h:16
SonicClientBase::clientName
const std::string & clientName() const
Definition: SonicClientBase.h:28
summarizeEdmComparisonLogfiles.success
success
Definition: summarizeEdmComparisonLogfiles.py:115
SonicClientBase::SonicClientBase
SonicClientBase(const edm::ParameterSet &params, const std::string &debugName, const std::string &clientName)
Definition: SonicClientBase.cc:5
SonicClientBase::evaluate
virtual void evaluate()=0
ParameterSetDescription.h
SonicClientBase::reset
virtual void reset()
Definition: SonicClientBase.h:38
SonicMode::PseudoAsync
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SonicDispatcher
Definition: SonicDispatcher.h:8
SonicMode::Sync
SonicClientBase::mode_
SonicMode mode_
Definition: SonicClientBase.h:55
edm::ParameterSet
Definition: ParameterSet.h:47
SonicMode::Async
SonicClientBase::fullDebugName_
std::string fullDebugName_
Definition: SonicClientBase.h:61
WaitingTaskWithArenaHolder.h
SonicClientBase::debugName_
std::string debugName_
Definition: SonicClientBase.h:61
SonicDispatcher.h
SonicClientBase::allowedTries_
unsigned allowedTries_
Definition: SonicClientBase.h:57
SonicClientBase::dispatcher_
std::unique_ptr< SonicDispatcher > dispatcher_
Definition: SonicClientBase.h:56
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:62
SonicClientBase::start
void start()
Definition: SonicClientBase.cc:43
SonicClientBase::dispatch
virtual void dispatch(edm::WaitingTaskWithArenaHolder holder)
Definition: SonicClientBase.h:32
ParameterSet.h
SonicClientBase::mode
SonicMode mode() const
Definition: SonicClientBase.h:29
SonicClientBase::clientName_
std::string clientName_
Definition: SonicClientBase.h:61
SonicClientBase::holder_
std::optional< edm::WaitingTaskWithArenaHolder > holder_
Definition: SonicClientBase.h:58
SonicClientBase::setMode
void setMode(SonicMode mode)
Definition: SonicClientBase.cc:26