-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove static qualifier #1433
remove static qualifier #1433
Conversation
A new Pull Request was created by @gartung (Patrick Gartung) for CMSSW_7_0_X. remove static qualifier It involves the following packages: RecoTracker/MeasurementDet @nclopezo, @cmsbuild, @thspeer, @slava77 can you please review it and eventually sign? Thanks. |
std::vector<uint32_t> rawInactiveDetIds; | ||
if (!theInactivePixelDetectorLabels.empty()) { | ||
edm::Handle<DetIdCollection> detIds; | ||
bool iFailedAlready =false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every time this routine is called, it may print the LogError. That wasn't the intent of the code. I'd instead make this a
static std::atomic<bool> iFailedAlready{ false };
@@ -67,7 +66,7 @@ | |||
if (event.getByLabel(*itt, detIds)){ | |||
rawInactiveDetIds.insert(rawInactiveDetIds.end(), detIds->begin(), detIds->end()); | |||
}else{ | |||
static bool iFailedAlready=false; | |||
static std::atomic<bool> iFailedAlread{false}; | |||
if (!iFailedAlready){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you want to do
bool expected = false;
if(iFailedAlready.compare_exchange_strong(expected,true,std::memory_order_acq_rel) ) {
and then get rid of the iFailedAlready=true
. That code change will guarantee that the printout will happen once and only once.
+1 |
This pull request is fully signed and it will be integrated in one of the next IBs unless changes or unless it breaks tests. @ktf can you please take care of it? |
Multithreading fixes -- Make static atomic in RecoTracker/MeasurementDet
No description provided.