Skip to content

Commit

Permalink
Marked statics as thread-safe since update only at library load
Browse files Browse the repository at this point in the history
The singletons VertexRecoManager and VertexFitterManager are only
updated while the library in which they are embedded is loaded.
Therefore access to these singletons is thread-safe. By marking them
with our C++11 attribute, the static analyzer will no longer complain
about them.
  • Loading branch information
Dr15Jones committed Jun 27, 2014
1 parent 4da854f commit e27bac5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion RecoVertex/ConfigurableVertexReco/src/VertexFitterManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ VertexFitterManager::VertexFitterManager ( const VertexFitterManager & o )

VertexFitterManager & VertexFitterManager::Instance()
{
static VertexFitterManager singleton;
//The singleton's internal structure only changes while
// this library is being loaded. All other methods are const.

[[cms::thread_safe]] static VertexFitterManager singleton;
return singleton;
}

Expand Down
4 changes: 3 additions & 1 deletion RecoVertex/ConfigurableVertexReco/src/VertexRecoManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ VertexRecoManager::VertexRecoManager ( const VertexRecoManager & o )

VertexRecoManager & VertexRecoManager::Instance()
{
static VertexRecoManager singleton;
//The singleton's internal structure only changes while
// this library is being loaded. All other methods are const.
[[cms::thread_safe]] static VertexRecoManager singleton;
return singleton;
}

Expand Down

0 comments on commit e27bac5

Please sign in to comment.