ensure_only_one_thread.cc
Go to the documentation of this file.
5 
6 namespace {
8  maybe_s(unsigned const i, std::string const& word)
9  {
10  return i == 1u ? word : word + "s";
11  }
12 }
13 
14 void
16 {
17  auto const& globals = *Globals::instance();
18  auto const nschedules = globals.nschedules();
19  auto const nthreads = globals.nthreads();
20  if (nschedules == 1u && nthreads == 1u)
21  return;
22 
23  auto const service_type = service_pset.get<std::string>("service_type");
25  e << "The service '" << service_type << '\'';
27  if (service_pset.get_if_present("service_provider", provider)) {
28  e << " (provider: '" << provider << "')";
29  }
30  e << " is a legacy service,\n"
31  << "which can be used with only one schedule and one thread.\n"
32  << "This job uses " << nschedules << maybe_s(nschedules, " schedule")
33  << " and " << nthreads << maybe_s(nthreads, " thread") << ".\n"
34  << "Please reconfigure your job to use only one schedule/thread.\n";
35  throw e;
36 }
std::string string
Definition: nybbler.cc:12
virtual const provider_type * provider() const override
const std::string instance
const double e
T get(std::string const &key) const
Definition: ParameterSet.h:271
void ensure_only_one_thread(fhicl::ParameterSet const &service_pset)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< T > get_if_present(std::string const &key) const
Definition: ParameterSet.h:224
union ptb::content::word::word word