Skip to content

Commit

Permalink
Merge pull request facebook#176 from bgrainger/mutexrw-unlock
Browse files Browse the repository at this point in the history
Add separate Read/WriteUnlock methods in MutexRW.
  • Loading branch information
igorcanadi committed Jun 17, 2014
2 parents e6e259b + 2d02ec6 commit 4f18bfe
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion db/memtable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ static bool SaveValue(void* arg, const char* entry) {
s->value->assign(v.data(), v.size());
}
if (s->inplace_update_support) {
s->mem->GetLock(s->key->user_key())->Unlock();
s->mem->GetLock(s->key->user_key())->ReadUnlock();
}
*(s->found_final_value) = true;
return false;
Expand Down
4 changes: 3 additions & 1 deletion port/port_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ void RWMutex::ReadLock() { PthreadCall("read lock", pthread_rwlock_rdlock(&mu_))

void RWMutex::WriteLock() { PthreadCall("write lock", pthread_rwlock_wrlock(&mu_)); }

void RWMutex::Unlock() { PthreadCall("unlock", pthread_rwlock_unlock(&mu_)); }
void RWMutex::ReadUnlock() { PthreadCall("read unlock", pthread_rwlock_unlock(&mu_)); }

void RWMutex::WriteUnlock() { PthreadCall("write unlock", pthread_rwlock_unlock(&mu_)); }

void InitOnce(OnceType* once, void (*initializer)()) {
PthreadCall("once", pthread_once(once, initializer));
Expand Down
3 changes: 2 additions & 1 deletion port/port_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ class RWMutex {

void ReadLock();
void WriteLock();
void Unlock();
void ReadUnlock();
void WriteUnlock();
void AssertHeld() { }

private:
Expand Down
4 changes: 2 additions & 2 deletions util/mutexlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ReadLock {
explicit ReadLock(port::RWMutex *mu) : mu_(mu) {
this->mu_->ReadLock();
}
~ReadLock() { this->mu_->Unlock(); }
~ReadLock() { this->mu_->ReadUnlock(); }

private:
port::RWMutex *const mu_;
Expand All @@ -66,7 +66,7 @@ class WriteLock {
explicit WriteLock(port::RWMutex *mu) : mu_(mu) {
this->mu_->WriteLock();
}
~WriteLock() { this->mu_->Unlock(); }
~WriteLock() { this->mu_->WriteUnlock(); }

private:
port::RWMutex *const mu_;
Expand Down
2 changes: 1 addition & 1 deletion util/vectorrep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void VectorRep::Get(const LookupKey& k, void* callback_args,
bucket.reset(new Bucket(*bucket_)); // make a copy
}
VectorRep::Iterator iter(vector_rep, immutable_ ? bucket_ : bucket, compare_);
rwlock_.Unlock();
rwlock_.ReadUnlock();

for (iter.Seek(k.user_key(), k.memtable_key().data());
iter.Valid() && callback_func(callback_args, iter.key()); iter.Next()) {
Expand Down

0 comments on commit 4f18bfe

Please sign in to comment.