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 <exception>
13 #include <memory>
14 #include <optional>
15 
16 enum class SonicMode { Sync = 1, Async = 2, PseudoAsync = 3 };
17 
19 public:
20  //constructor
22 
23  //destructor
24  virtual ~SonicClientBase() = default;
25 
26  const std::string& debugName() const { return debugName_; }
27  const std::string& clientName() const { return clientName_; }
28  SonicMode mode() const { return mode_; }
29 
30  //main operation
31  virtual void dispatch(edm::WaitingTaskWithArenaHolder holder) { dispatcher_->dispatch(std::move(holder)); }
32 
33  //alternate operation when ExternalWork is not used
34  virtual void dispatch() { dispatcher_->dispatch(); }
35 
36  //helper: does nothing by default
37  virtual void reset() {}
38 
39  //provide base params
40  static void fillBasePSetDescription(edm::ParameterSetDescription& desc, bool allowRetry = true);
41 
42 protected:
43  void setMode(SonicMode mode);
44 
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  bool verbose_;
56  std::unique_ptr<SonicDispatcher> dispatcher_;
57  unsigned allowedTries_, tries_;
58  std::optional<edm::WaitingTaskWithArenaHolder> holder_;
59 
60  //for logging/debugging
62 
63  friend class SonicDispatcher;
65 };
66 
67 #endif
const std::string & debugName() const
const std::string & clientName() const
SonicClientBase(const edm::ParameterSet &params, const std::string &debugName, const std::string &clientName)
SonicMode
virtual void dispatch(edm::WaitingTaskWithArenaHolder holder)
virtual void evaluate()=0
SonicMode mode() const
virtual void dispatch()
void setMode(SonicMode mode)
std::string debugName_
void finish(bool success, std::exception_ptr eptr=std::exception_ptr{})
virtual ~SonicClientBase()=default
std::optional< edm::WaitingTaskWithArenaHolder > holder_
static void fillBasePSetDescription(edm::ParameterSetDescription &desc, bool allowRetry=true)
std::string clientName_
std::unique_ptr< SonicDispatcher > dispatcher_
std::string fullDebugName_
unsigned allowedTries_
virtual void reset()
def move(src, dest)
Definition: eostools.py:511