Skip to content

Commit

Permalink
Use CMS_SA_ALLOW for classes not used across threads
Browse files Browse the repository at this point in the history
Added the CMS_SA_ALLOW to silence static analysis warnings about mutable.
  • Loading branch information
Dr15Jones committed Dec 12, 2019
1 parent 471040b commit 5705c5c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
6 changes: 4 additions & 2 deletions DataFormats/Common/interface/ProductData.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ is the storage unit of such information.
----------------------------------------------------------------------*/

#include "DataFormats/Provenance/interface/Provenance.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
#include <memory>

namespace edm {
Expand Down Expand Up @@ -65,8 +66,9 @@ namespace edm {
// the effort to make the Framework multithread capable ...

private:
// "non-const data" (updated every event)
mutable std::shared_ptr<WrapperBase const> wrapper_;
// "non-const data" (updated every event).
// The mutating function begin with 'unsafe_'
CMS_SA_ALLOW mutable std::shared_ptr<WrapperBase const> wrapper_;
Provenance prov_;
};

Expand Down
4 changes: 3 additions & 1 deletion DataFormats/Provenance/interface/FileIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ FileIndex.h

#include "DataFormats/Provenance/interface/RunID.h"
#include "DataFormats/Provenance/interface/EventID.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"

#include <cassert>
#include <iosfwd>
Expand Down Expand Up @@ -117,7 +118,8 @@ namespace edm {
SortState& sortState() const { return transient_.sortState_; }

std::vector<Element> entries_;
mutable Transients transient_;
//Only used within source's serial code
CMS_SA_ALLOW mutable Transients transient_;
};

bool operator<(FileIndex::Element const& lh, FileIndex::Element const& rh);
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/Provenance/src/IndexIntoFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ namespace edm {
resetEventFinder();
}

void IndexIntoFile::doneFileInitialization() { std::vector<EventNumber_t>().swap(unsortedEventNumbers()); }
void IndexIntoFile::doneFileInitialization() { std::vector<EventNumber_t>().swap(unsortedEventNumbers()); }

void IndexIntoFile::reduceProcessHistoryIDs(ProcessHistoryRegistry const& processHistoryRegistry) {
std::vector<ProcessHistoryID> reducedPHIDs;
Expand Down
4 changes: 3 additions & 1 deletion FWCore/Framework/interface/LuminosityBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ For its usage, see "FWCore/Framework/interface/PrincipalGetAdapter.h"
#include "FWCore/Utilities/interface/LuminosityBlockIndex.h"
#include "FWCore/Utilities/interface/propagate_const.h"
#include "FWCore/Utilities/interface/Likely.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"

#include <memory>
#include <string>
Expand Down Expand Up @@ -180,7 +181,8 @@ namespace edm {
PrincipalGetAdapter provRecorder_;
ProductPtrVec putProducts_;
LuminosityBlockAuxiliary const& aux_;
mutable std::optional<Run> run_;
//This class is intended to be used by only one thread
CMS_SA_ALLOW mutable std::optional<Run> run_;
ModuleCallingContext const* moduleCallingContext_;

static const std::string emptyString_;
Expand Down
7 changes: 5 additions & 2 deletions FWCore/MessageLogger/src/MessageDrop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

// user include files
#include "FWCore/MessageLogger/interface/MessageDrop.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"

// Change Log
//
Expand Down Expand Up @@ -114,8 +115,10 @@ namespace edm {
std::string const* label_;
const char* phasePtr_;
unsigned int moduleID_;
mutable std::string cache_;
mutable std::map<unsigned int, std::string> idLabelMap_;

//This class is only used within a thread local object
CMS_SA_ALLOW mutable std::string cache_;
CMS_SA_ALLOW mutable std::map<unsigned int, std::string> idLabelMap_;
};

class StringProducerPath : public StringProducer {
Expand Down

0 comments on commit 5705c5c

Please sign in to comment.