Skip to content

Commit

Permalink
code format (OpenAtomFoundation#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
Axlgrep authored Jul 25, 2018
1 parent 0c79d77 commit eb2d2c7
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/lock_mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,23 @@ struct LockMap {
size_t GetStripe(const std::string& key) const;
};

LockMgr::LockMgr(size_t default_num_stripes,
int64_t max_num_locks,
std::shared_ptr<MutexFactory> mutex_factory)
: default_num_stripes_(default_num_stripes),
max_num_locks_(max_num_locks),
mutex_factory_(mutex_factory),
lock_map_(std::shared_ptr<LockMap>(
new LockMap(default_num_stripes,
mutex_factory))) {}

LockMgr::~LockMgr() {}

size_t LockMap::GetStripe(const std::string& key) const {
assert(num_stripes_ > 0);
static murmur_hash hash;
size_t stripe = hash(key) % num_stripes_;
return stripe;
}

LockMgr::LockMgr(size_t default_num_stripes,
int64_t max_num_locks,
std::shared_ptr<MutexFactory> mutex_factory)
: default_num_stripes_(default_num_stripes),
max_num_locks_(max_num_locks),
mutex_factory_(mutex_factory),
lock_map_(std::shared_ptr<LockMap>(new LockMap(default_num_stripes, mutex_factory))) {}

LockMgr::~LockMgr() {}

Status LockMgr::TryLock(const std::string& key) {
#ifdef LOCKLESS
return Status::OK();
Expand All @@ -99,8 +97,8 @@ Status LockMgr::TryLock(const std::string& key) {
}

// Helper function for TryLock().
Status LockMgr::Acquire(
LockMapStripe* stripe, const std::string& key) {
Status LockMgr::Acquire(LockMapStripe* stripe,
const std::string& key) {
Status result;

// we wait indefinitely to acquire the lock
Expand Down

0 comments on commit eb2d2c7

Please sign in to comment.