LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ensure_only_one_thread.cc
Go to the documentation of this file.
5 
6 namespace {
7  std::string
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 << '\'';
26  if (auto provider =
27  service_pset.get_if_present<std::string>("service_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 }
const std::string instance
T get(std::string const &key) const
Definition: ParameterSet.h:314
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:267
Float_t e
Definition: plot.C:35