Skip to content

Commit

Permalink
Replace use of boost::mutex
Browse files Browse the repository at this point in the history
Since the C++11 standard now has a full array of thread related classes
we no longer need to use the boost equivalent. Switching to the appropriate
std class should allow for easier maintenance.
  • Loading branch information
Dr15Jones committed Nov 14, 2014
1 parent 4a80e5b commit 296cb95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions CondFormats/PhysicsToolsObjects/src/MVAComputer.cc
Expand Up @@ -21,7 +21,7 @@
#include <cstring>
#include <cstddef>

#include <boost/thread.hpp>
#include <atomic>

#include <Reflex/Reflex.h>

Expand Down Expand Up @@ -129,10 +129,8 @@ std::string ProcExternal::getInstanceName() const

static MVAComputer::CacheId getNextMVAComputerCacheId()
{
static boost::mutex mutex;
static MVAComputer::CacheId nextCacheId = 0;
static std::atomic<MVAComputer::CacheId> nextCacheId{0};

boost::mutex::scoped_lock scoped_lock(mutex);
return ++nextCacheId;
}

Expand Down
8 changes: 4 additions & 4 deletions PhysicsTools/MVAComputer/src/AtomicId.cc
Expand Up @@ -4,7 +4,7 @@
#include <cstring>
#include <set>

#include <boost/thread.hpp>
#include <mutex>

#include "PhysicsTools/MVAComputer/interface/AtomicId.h"

Expand All @@ -25,7 +25,7 @@ namespace { // anonymous

IdSet idSet;
static std::allocator<char> stringAllocator;
mutable boost::mutex mutex;
mutable std::mutex mutex;
};
} // anonymous namespace

Expand All @@ -41,7 +41,7 @@ IdCache::~IdCache()

const char *IdCache::findOrInsert(const char *string) throw()
{
boost::mutex::scoped_lock scoped_lock(mutex);
std::lock_guard<std::mutex> scoped_lock(mutex);

IdSet::iterator pos = idSet.lower_bound(string);
if (pos != idSet.end() && std::strcmp(*pos, string) == 0)
Expand All @@ -60,7 +60,7 @@ namespace PhysicsTools {

static IdCache &getAtomicIdCache()
{
static IdCache atomicIdCache;
[[cms::thread_safe]] static IdCache atomicIdCache;
return atomicIdCache;
}

Expand Down

0 comments on commit 296cb95

Please sign in to comment.