File indexing completed on 2024-04-06 12:15:47
0001 #ifndef HeterogeneousCore_SonicCore_test_DummyClient
0002 #define HeterogeneousCore_SonicCore_test_DummyClient
0003
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 #include "HeterogeneousCore/SonicCore/interface/SonicClient.h"
0007
0008 #include <vector>
0009 #include <thread>
0010 #include <chrono>
0011
0012 class DummyClient : public SonicClient<int> {
0013 public:
0014
0015 DummyClient(const edm::ParameterSet& params, const std::string& debugName)
0016 : SonicClient<int>(params, debugName, "DummyClient"),
0017 factor_(params.getParameter<int>("factor")),
0018 wait_(params.getParameter<int>("wait")),
0019 fails_(params.getParameter<unsigned>("fails")) {}
0020
0021
0022 static void fillPSetDescription(edm::ParameterSetDescription& iDesc) {
0023 edm::ParameterSetDescription descClient;
0024 fillBasePSetDescription(descClient);
0025 descClient.add<int>("factor", -1);
0026 descClient.add<int>("wait", 10);
0027 descClient.add<unsigned>("fails", 0);
0028 iDesc.add<edm::ParameterSetDescription>("Client", descClient);
0029 }
0030
0031 protected:
0032 void evaluate() override {
0033
0034 std::this_thread::sleep_for(std::chrono::seconds(wait_));
0035
0036 this->output_ = this->input_ * factor_;
0037
0038
0039 if (this->tries_ < fails_)
0040 this->finish(false);
0041 else
0042 this->finish(true);
0043 }
0044
0045
0046 int factor_;
0047 int wait_;
0048 unsigned fails_;
0049 };
0050
0051 #endif