Skip to content

Commit

Permalink
Merge pull request #44902 from Dr15Jones/noexceptFramework
Browse files Browse the repository at this point in the history
Added noexcept to methods called by async functions
  • Loading branch information
cmsbuild authored May 10, 2024
2 parents 4bc6f1c + 5b1d5a1 commit 6083e0e
Show file tree
Hide file tree
Showing 94 changed files with 723 additions and 661 deletions.
2 changes: 1 addition & 1 deletion CondCore/CondHDF5ESSource/plugins/HDF5ProductResolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void HDF5ProductResolver::prefetchAsyncImpl(edm::WaitingTaskHolder iTask,
edm::eventsetup::DataKey const& iKey,
edm::EventSetupImpl const*,
edm::ServiceToken const&,
edm::ESParentContext const& iParent) {
edm::ESParentContext const& iParent) noexcept {
prefetchAsyncImplTemplate(
[this, iov = iRecord.validityInterval(), iParent, &iRecord](auto& iGroup, auto iActivity) {
queue_->push(iGroup, [this, &iGroup, act = std::move(iActivity), iov, iParent, &iRecord] {
Expand Down
2 changes: 1 addition & 1 deletion CondCore/CondHDF5ESSource/plugins/HDF5ProductResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class HDF5ProductResolver : public edm::eventsetup::ESSourceProductResolverBase
edm::eventsetup::DataKey const& iKey,
edm::EventSetupImpl const*,
edm::ServiceToken const&,
edm::ESParentContext const&) final;
edm::ESParentContext const&) noexcept final;

void invalidateCache() final;
void prefetch(edm::eventsetup::DataKey const& iKey, edm::EventSetupRecordDetails) final;
Expand Down
10 changes: 5 additions & 5 deletions FWCore/Concurrency/interface/TaskBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ namespace edm {
friend class TaskSentry;

///Constructor
TaskBase() : m_refCount{0} {}
virtual ~TaskBase() = default;
TaskBase() noexcept : m_refCount{0} {}
virtual ~TaskBase() noexcept = default;

virtual void execute() = 0;

void increment_ref_count() { ++m_refCount; }
unsigned int decrement_ref_count() { return --m_refCount; }
void increment_ref_count() noexcept { ++m_refCount; }
unsigned int decrement_ref_count() noexcept { return --m_refCount; }

private:
virtual void recycle() { delete this; }
Expand All @@ -49,7 +49,7 @@ namespace edm {

class TaskSentry {
public:
TaskSentry(TaskBase* iTask) : m_task{iTask} {}
TaskSentry(TaskBase* iTask) noexcept : m_task{iTask} {}
~TaskSentry() { m_task->recycle(); }
TaskSentry() = delete;
TaskSentry(TaskSentry const&) = delete;
Expand Down
10 changes: 5 additions & 5 deletions FWCore/Concurrency/interface/WaitingTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ namespace edm {
friend class WaitingTaskWithArenaHolder;

///Constructor
WaitingTask() : m_ptr{} {}
~WaitingTask() override{};
WaitingTask() noexcept : m_ptr{} {}
~WaitingTask() noexcept override{};

// ---------- const member functions ---------------------------

///Returns exception thrown by dependent task
/** If the value evalutes to true then the dependent task failed.
*/
std::exception_ptr exceptionPtr() const {
std::exception_ptr exceptionPtr() const noexcept {
if (m_ptrSet == static_cast<unsigned char>(State::kSet)) {
return m_ptr;
}
return std::exception_ptr{};
}

protected:
std::exception_ptr const& uncheckedExceptionPtr() const { return m_ptr; }
std::exception_ptr const& uncheckedExceptionPtr() const noexcept { return m_ptr; }

private:
enum class State : unsigned char { kUnset = 0, kSetting = 1, kSet = 2 };
Expand All @@ -65,7 +65,7 @@ namespace edm {
* moved to another thread.
* This method should only be called by WaitingTaskList
*/
void dependentTaskFailed(std::exception_ptr iPtr) {
void dependentTaskFailed(std::exception_ptr iPtr) noexcept {
unsigned char isSet = static_cast<unsigned char>(State::kUnset);
if (iPtr and m_ptrSet.compare_exchange_strong(isSet, static_cast<unsigned char>(State::kSetting))) {
m_ptr = iPtr;
Expand Down
16 changes: 8 additions & 8 deletions FWCore/Concurrency/interface/WaitingTaskHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,32 @@ namespace edm {

WaitingTaskHolder() : m_task(nullptr), m_group(nullptr) {}

explicit WaitingTaskHolder(oneapi::tbb::task_group& iGroup, edm::WaitingTask* iTask)
explicit WaitingTaskHolder(oneapi::tbb::task_group& iGroup, edm::WaitingTask* iTask) noexcept
: m_task(iTask), m_group(&iGroup) {
m_task->increment_ref_count();
}
~WaitingTaskHolder() {
~WaitingTaskHolder() noexcept {
if (m_task) {
doneWaiting(std::exception_ptr{});
}
}

WaitingTaskHolder(const WaitingTaskHolder& iHolder) : m_task(iHolder.m_task), m_group(iHolder.m_group) {
WaitingTaskHolder(const WaitingTaskHolder& iHolder) noexcept : m_task(iHolder.m_task), m_group(iHolder.m_group) {
m_task->increment_ref_count();
}

WaitingTaskHolder(WaitingTaskHolder&& iOther) : m_task(iOther.m_task), m_group(iOther.m_group) {
WaitingTaskHolder(WaitingTaskHolder&& iOther) noexcept : m_task(iOther.m_task), m_group(iOther.m_group) {
iOther.m_task = nullptr;
}

WaitingTaskHolder& operator=(const WaitingTaskHolder& iRHS) {
WaitingTaskHolder& operator=(const WaitingTaskHolder& iRHS) noexcept {
WaitingTaskHolder tmp(iRHS);
std::swap(m_task, tmp.m_task);
std::swap(m_group, tmp.m_group);
return *this;
}

WaitingTaskHolder& operator=(WaitingTaskHolder&& iRHS) {
WaitingTaskHolder& operator=(WaitingTaskHolder&& iRHS) noexcept {
WaitingTaskHolder tmp(std::move(iRHS));
std::swap(m_task, tmp.m_task);
std::swap(m_group, tmp.m_group);
Expand All @@ -85,13 +85,13 @@ namespace edm {
a different, but related failure. You must later call doneWaiting
in the same thread passing the same exceptoin.
*/
void presetTaskAsFailed(std::exception_ptr iExcept) {
void presetTaskAsFailed(std::exception_ptr iExcept) noexcept {
if (iExcept) {
m_task->dependentTaskFailed(iExcept);
}
}

void doneWaiting(std::exception_ptr iExcept) {
void doneWaiting(std::exception_ptr iExcept) noexcept {
if (iExcept) {
m_task->dependentTaskFailed(iExcept);
}
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/Callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace edm {
EventSetupRecordImpl const* iRecord,
EventSetupImpl const* iEventSetupImpl,
ServiceToken const& token,
ESParentContext const& iParent) {
ESParentContext const& iParent) noexcept {
return Base::prefetchAsyncImpl(
[this](auto&& group, auto&& token, auto&& record, auto&& es) {
constexpr bool emitPostPrefetchingSignal = true;
Expand Down
20 changes: 10 additions & 10 deletions FWCore/Framework/interface/CallbackBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace edm {
EventSetupRecordImpl const* iRecord,
EventSetupImpl const* iEventSetupImpl,
ServiceToken const& token,
ESParentContext const& iParent) {
ESParentContext const& iParent) noexcept {
bool expected = false;
auto doPrefetch = wasCalledForThisRecord_.compare_exchange_strong(expected, true);
taskList_.add(iTask);
Expand Down Expand Up @@ -221,16 +221,16 @@ namespace edm {
taskList_.reset();
}

unsigned int transitionID() const { return id_; }
ESResolverIndex const* getTokenIndices() const { return producer_->getTokenIndices(id_); }
unsigned int transitionID() const noexcept { return id_; }
ESResolverIndex const* getTokenIndices() const noexcept { return producer_->getTokenIndices(id_); }

std::optional<std::vector<ESResolverIndex>> const& postMayGetResolvers() const { return postMayGetResolvers_; }
T* producer() { return producer_.get(); }
ESModuleCallingContext& callingContext() { return callingContext_; }
WaitingTaskList& taskList() { return taskList_; }
std::shared_ptr<TProduceFunc> const& produceFunction() { return produceFunction_; }
TDecorator const& decorator() const { return decorator_; }
SerialTaskQueueChain& queue() { return producer_->queue(); }
T* producer() noexcept { return producer_.get(); }
ESModuleCallingContext& callingContext() noexcept { return callingContext_; }
WaitingTaskList& taskList() noexcept { return taskList_; }
std::shared_ptr<TProduceFunc> const& produceFunction() noexcept { return produceFunction_; }
TDecorator const& decorator() const noexcept { return decorator_; }
SerialTaskQueueChain& queue() noexcept { return producer_->queue(); }

protected:
~CallbackBase() = default;
Expand All @@ -244,7 +244,7 @@ namespace edm {
void prefetchNeededDataAsync(WaitingTaskHolder task,
EventSetupImpl const* iImpl,
ESResolverIndex const* proxies,
ServiceToken const& token) const {
ServiceToken const& token) const noexcept {
auto recs = producer_->getTokenRecordIndices(id_);
auto n = producer_->numberOfTokenIndices(id_);
for (size_t i = 0; i != n; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/CallbackExternalWork.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace edm {
EventSetupRecordImpl const* iRecord,
EventSetupImpl const* iEventSetupImpl,
ServiceToken const& token,
ESParentContext const& iParent) {
ESParentContext const& iParent) noexcept {
return Base::prefetchAsyncImpl(
[this](auto&& group, auto&& token, auto&& record, auto&& es) {
constexpr bool emitPostPrefetchingSignal = false;
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/CallbackProductResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace edm::eventsetup {
const DataKey&,
EventSetupImpl const* iEventSetupImpl,
ServiceToken const& iToken,
edm::ESParentContext const& iParent) final {
edm::ESParentContext const& iParent) noexcept final {
assert(iRecord.key() == RecordT::keyForClass());
callback_->prefetchAsync(iWaitTask, &iRecord, iEventSetupImpl, iToken, iParent);
}
Expand Down
8 changes: 5 additions & 3 deletions FWCore/Framework/interface/EDLooperBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ namespace edm {
ServiceToken const& token,
Transition iTrans,
Principal const& iPrincipal,
EventSetupImpl const& iImpl) const;
EventSetupImpl const& iImpl) const noexcept;

void esPrefetchAsync(WaitingTaskHolder iTask,
EventSetupImpl const& iImpl,
Transition iTrans,
ServiceToken const& iToken) const;
ServiceToken const& iToken) const noexcept;

///Override this method if you need to monitor the state of the processing
virtual void attachTo(ActivityRegistry&);
Expand Down Expand Up @@ -159,7 +159,9 @@ namespace edm {
///Called after all event modules have processed the end of a LuminosityBlock
virtual void endLuminosityBlock(LuminosityBlock const&, EventSetup const&);

void edPrefetchAsync(WaitingTaskHolder iTask, ServiceToken const& token, Principal const& iPrincipal) const;
void edPrefetchAsync(WaitingTaskHolder iTask,
ServiceToken const& token,
Principal const& iPrincipal) const noexcept;

unsigned int iCounter_;
ExceptionToActionTable const* act_table_;
Expand Down
4 changes: 2 additions & 2 deletions FWCore/Framework/interface/ESProductResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace edm {
DataKey const&,
EventSetupImpl const*,
ServiceToken const&,
ESParentContext const&) const;
ESParentContext const&) const noexcept;

void const* getAfterPrefetch(const EventSetupRecordImpl& iRecord, const DataKey& iKey, bool iTransiently) const;

Expand Down Expand Up @@ -83,7 +83,7 @@ namespace edm {
DataKey const& iKey,
EventSetupImpl const*,
ServiceToken const&,
ESParentContext const&) = 0;
ESParentContext const&) noexcept = 0;

/** indicates that the Resolver should invalidate any cached information
as that information has 'expired' (i.e. we have moved to a new IOV)
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/ESProductResolverTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace edm {
const DataKey& iKey,
EventSetupImpl const* iEventSetupImpl,
edm::ServiceToken const& iToken,
edm::ESParentContext const& iParent) override {
edm::ESParentContext const& iParent) noexcept override {
assert(iRecord.key() == RecordT::keyForClass());
bool expected = false;
bool doPrefetch = prefetching_.compare_exchange_strong(expected, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace edm::eventsetup {
edm::eventsetup::DataKey const& iKey,
edm::EventSetupImpl const*,
edm::ServiceToken const&,
edm::ESParentContext const&) final;
edm::ESParentContext const&) noexcept final;

// ---------- member data --------------------------------
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace edm::eventsetup {
edm::eventsetup::DataKey const& iKey,
edm::EventSetupImpl const*,
edm::ServiceToken const&,
edm::ESParentContext const&) final;
edm::ESParentContext const&) noexcept final;

// ---------- member data --------------------------------

Expand Down
4 changes: 2 additions & 2 deletions FWCore/Framework/interface/EventForTransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ namespace edm {

class EventForTransformer {
public:
EventForTransformer(EventPrincipal const&, ModuleCallingContext);
EventForTransformer(EventPrincipal const&, ModuleCallingContext) noexcept;

BasicHandle get(edm::TypeID const& iTypeID, ProductResolverIndex iIndex) const;

void put(ProductResolverIndex index, std::unique_ptr<WrapperBase> edp, BasicHandle const& iGetHandle);

ModuleCallingContext const& moduleCallingContext() const { return mcc_; }
ModuleCallingContext const& moduleCallingContext() const noexcept { return mcc_; }

private:
EventPrincipal const& eventPrincipal_;
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/EventSetupRecordImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace edm {
ESResolverIndex iResolverIndex,
EventSetupImpl const*,
ServiceToken const&,
ESParentContext) const;
ESParentContext) const noexcept;

/**returns true only if someone has already requested data for this key
and the data was retrieved
Expand Down
6 changes: 3 additions & 3 deletions FWCore/Framework/interface/OutputModuleCommunicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ namespace edm {
virtual void writeProcessBlockAsync(WaitingTaskHolder iTask,
ProcessBlockPrincipal const&,
ProcessContext const*,
ActivityRegistry*) = 0;
ActivityRegistry*) noexcept = 0;

virtual void writeRunAsync(WaitingTaskHolder iTask,
RunPrincipal const&,
ProcessContext const*,
ActivityRegistry*,
MergeableRunProductMetadata const*) = 0;
MergeableRunProductMetadata const*) noexcept = 0;

virtual void writeLumiAsync(WaitingTaskHolder iTask,
LuminosityBlockPrincipal const&,
ProcessContext const*,
ActivityRegistry*) = 0;
ActivityRegistry*) noexcept = 0;

///\return true if OutputModule has reached its limit on maximum number of events it wants to see
virtual bool limitReached() const = 0;
Expand Down
8 changes: 4 additions & 4 deletions FWCore/Framework/interface/OutputModuleCommunicatorT.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ namespace edm {
void writeProcessBlockAsync(WaitingTaskHolder iTask,
ProcessBlockPrincipal const&,
ProcessContext const*,
ActivityRegistry*) override;
ActivityRegistry*) noexcept override;

void writeRunAsync(WaitingTaskHolder iTask,
edm::RunPrincipal const& rp,
ProcessContext const*,
ActivityRegistry*,
MergeableRunProductMetadata const*) override;
MergeableRunProductMetadata const*) noexcept override;

void writeLumiAsync(WaitingTaskHolder iTask,
edm::LuminosityBlockPrincipal const& lbp,
ProcessContext const*,
ActivityRegistry*) override;
ActivityRegistry*) noexcept override;

///\return true if OutputModule has reached its limit on maximum number of events it wants to see
bool limitReached() const override;
Expand All @@ -81,7 +81,7 @@ namespace edm {
}

private:
inline T& module() const { return *module_; }
inline T& module() const noexcept { return *module_; }
T* module_;
};
} // namespace edm
Expand Down
6 changes: 3 additions & 3 deletions FWCore/Framework/interface/OutputModuleCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ namespace edm {

void registerProductsAndCallbacks(OutputModuleCore const*, ProductRegistry*);

bool needToRunSelection() const;
std::vector<ProductResolverIndexAndSkipBit> productsUsedBySelection() const;
bool needToRunSelection() const noexcept;
std::vector<ProductResolverIndexAndSkipBit> productsUsedBySelection() const noexcept;
bool prePrefetchSelection(StreamID id, EventPrincipal const&, ModuleCallingContext const*);

// Do the end-of-file tasks; this is only called internally, after
Expand Down Expand Up @@ -247,7 +247,7 @@ namespace edm {

virtual void setProcessesWithSelectedMergeableRunProducts(std::set<std::string> const&) {}

bool hasAccumulator() const { return false; }
bool hasAccumulator() const noexcept { return false; }

void keepThisBranch(BranchDescription const& desc,
std::map<BranchID, BranchDescription const*>& trueBranchIDToKeptBranchDesc,
Expand Down
4 changes: 2 additions & 2 deletions FWCore/Framework/interface/ProductProvenanceRetriever.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace edm {
virtual void readProvenanceAsync(WaitingTaskHolder task,
ModuleCallingContext const* moduleCallingContext,
unsigned int transitionIndex,
std::atomic<const std::set<ProductProvenance>*>& writeTo) const = 0;
std::atomic<const std::set<ProductProvenance>*>& writeTo) const noexcept = 0;
};

class ProductProvenanceRetriever : public ProductProvenanceLookup {
Expand All @@ -50,7 +50,7 @@ namespace edm {

void reset();

void readProvenanceAsync(WaitingTaskHolder task, ModuleCallingContext const* moduleCallingContext) const;
void readProvenanceAsync(WaitingTaskHolder task, ModuleCallingContext const* moduleCallingContext) const noexcept;

private:
std::unique_ptr<const std::set<ProductProvenance>> readProvenance() const final;
Expand Down
Loading

0 comments on commit 6083e0e

Please sign in to comment.