10 #include "tbb/task_scheduler_init.h" 36 fillTable(std::string
const& bpo_key,
38 bpo::variables_map
const& vm,
40 bool const flag_value)
42 if (vm.count(bpo_key)) {
43 config.
put(fhicl_key, vm[bpo_key].as<bool>());
45 config.
put(fhicl_key, flag_value);
52 bpo::options_description& desc,
53 bool const rethrowDefault)
54 : rethrowDefault_{rethrowDefault}
57 bpo::options_description processing_options{
"Processing options"};
58 auto options = processing_options.add_options();
62 bpo::value<int>()->default_value(1),
63 "Number of threads to use for event processing (default = 1, 0 = all " 67 "Some exceptions may be handled differently by default (e.g. " 69 add_opt(options,
"rethrow-default",
"All exceptions default to rethrow.");
72 "All exceptions overridden to rethrow (cf rethrow-default).");
75 "errorOnFailureToPut",
76 bpo::value<bool>()->implicit_value(
true,
"true"),
77 "Global flag that controls the behavior upon failure to 'put' a " 78 "product (declared by 'produces') onto the Event. If 'true', per-module " 79 "flags can override the value of the global flag.");
82 "errorOnMissingConsumes",
83 bpo::value<bool>()->implicit_value(
true,
"true"),
84 "If 'true', then an exception will be thrown if any module attempts " 85 "to retrieve a product via the 'getBy*' interface without specifying " 86 "the appropriate 'consumes<T>(...)' statement in the module constructor.");
90 bpo::value<bool>()->implicit_value(
true,
"true"),
91 "If 'true', a signal received from the user yields an art return code " 92 "corresponding to an error; otherwise return 0.");
93 desc.add(processing_options);
99 if ((vm.count(
"rethrow-all") + vm.count(
"rethrow-default") +
100 vm.count(
"no-rethrow-default")) > 1) {
102 <<
"Options --default-exceptions, --rethrow-all, and --rethrow-default " 104 <<
"are mutually incompatible.\n";
109 if (vm[
"nthreads"].as<int>() < 0) {
111 <<
"Option --nthreads must greater than or equal to 0.";
118 bpo::variables_map
const& vm,
121 std::string
const scheduler_key{
"services.scheduler"};
123 if (vm.count(
"rethrow-all") == 1 || vm.count(
"rethrow-default") == 1 ||
125 raw_config.
put(
fhicl_key(scheduler_key,
"defaultExceptions"),
false);
126 if (vm.count(
"rethrow-all") == 1) {
134 fillTable(
"errorOnFailureToPut",
135 fhicl_key(scheduler_key,
"errorOnFailureToPut"),
139 fillTable(
"errorOnMissingConsumes",
140 fhicl_key(scheduler_key,
"errorOnMissingConsumes"),
144 fillTable(
"errorOnSIGINT",
145 fhicl_key(scheduler_key,
"errorOnSIGINT"),
150 auto const nt = vm[
"nthreads"].as<
int>();
151 auto const nthreads =
152 (nt == 0) ? tbb::task_scheduler_init::default_num_threads() : nt;
153 raw_config.
put(
fhicl_key(scheduler_key,
"num_threads"), nthreads);
int doCheckOptions(bpo::variables_map const &vm) override
bool exists_outside_prolog(fhicl::intermediate_table const &config, std::string const &key)
void add_opt(T &t, Args &&...args)
std::enable_if_t< std::is_convertible< T, std::string >::value, std::string > fhicl_key(T const &name)
ProcessingOptionsHandler(bpo::options_description &desc, bool rethrowDefault)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
int doProcessOptions(bpo::variables_map const &vm, fhicl::intermediate_table &raw_config) override