File indexing completed on 2024-04-06 12:12:38
0001 #include "WaitingService.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
0004 #include "FWCore/ServiceRegistry/interface/ServiceMaker.h"
0005
0006 namespace edmtest {
0007 namespace test_acquire {
0008
0009 WaitingService::WaitingService(edm::ParameterSet const& pset, edm::ActivityRegistry& iRegistry)
0010 : count_(0),
0011 numberOfStreamsToAccumulate_(pset.getUntrackedParameter<unsigned int>("streamsToAccumulate", 8)),
0012 secondsToWaitForWork_(pset.getUntrackedParameter<unsigned int>("secondsToWaitForWork", 1)) {
0013 iRegistry.watchPreallocate(this, &WaitingService::preallocate);
0014 iRegistry.watchPostEndJob(this, &WaitingService::postEndJob);
0015 }
0016
0017 WaitingService::~WaitingService() {
0018 if (server_) {
0019 server_->stop();
0020 }
0021 }
0022
0023 void WaitingService::preallocate(edm::service::SystemBounds const&) {
0024 caches_.resize(count_.load());
0025 server_ = std::make_unique<test_acquire::WaitingServer>(
0026 count_.load(), numberOfStreamsToAccumulate_, secondsToWaitForWork_);
0027 server_->start();
0028 }
0029
0030 void WaitingService::postEndJob() {
0031 if (server_) {
0032 server_->stop();
0033 }
0034 server_.reset();
0035 }
0036 }
0037 }
0038
0039 using edmtest::test_acquire::WaitingService;
0040 DEFINE_FWK_SERVICE(WaitingService);