CMS 3D CMS Logo

AsyncService.cc
Go to the documentation of this file.
6 
7 #include <atomic>
8 
9 namespace edm::service {
10  class AsyncService : public Async {
11  public:
12  AsyncService(ParameterSet const& iConfig, ActivityRegistry& iRegistry);
13 
14  static void fillDescriptions(ConfigurationDescriptions& descriptions);
15 
16  private:
17  void ensureAllowed() const final;
18 
19  std::atomic<bool> allowed_ = true;
20  };
21 
23  iRegistry.watchPreSourceEarlyTermination([this](TerminationOrigin) { allowed_ = false; });
24  iRegistry.watchPreGlobalEarlyTermination([this](GlobalContext const&, TerminationOrigin) { allowed_ = false; });
25  iRegistry.watchPreStreamEarlyTermination([this](StreamContext const&, TerminationOrigin) { allowed_ = false; });
26  iRegistry.watchPostEndJob([this]() { allowed_ = false; });
27  }
28 
31  descriptions.addDefault(desc);
32  }
33 
35  if (not allowed_) {
36  cms::Exception ex("AsyncCallNotAllowed");
37  ex.addContext("Calling Async::run()");
38  ex << "Framework is shutting down, further run() calls are not allowed";
39  throw ex;
40  }
41  }
42 } // namespace edm::service
43 
45 
void watchPreStreamEarlyTermination(PreStreamEarlyTermination::slot_type const &iSlot)
#define DEFINE_FWK_SERVICE_MAKER(concrete, maker)
Definition: ServiceMaker.h:102
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: AsyncService.cc:29
void watchPreSourceEarlyTermination(PreSourceEarlyTermination::slot_type const &iSlot)
void addDefault(ParameterSetDescription const &psetDescription)
void watchPreGlobalEarlyTermination(PreGlobalEarlyTermination::slot_type const &iSlot)
std::atomic< bool > allowed_
Definition: AsyncService.cc:19
void ensureAllowed() const final
Definition: AsyncService.cc:34
AsyncService(ParameterSet const &iConfig, ActivityRegistry &iRegistry)
Definition: AsyncService.cc:22
void addContext(std::string const &context)
Definition: Exception.cc:169