Add scope guard

Summary: Small change: replace mutex_.Lock/mutex_.Unlock() with scope guard

Test Plan: make all check

Reviewers: igor, sdong

Reviewed By: sdong

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D21609
main
Stanislau Hlebik 11 years ago
parent 06a52bda64
commit 2fa643466d
  1. 30
      db/db_impl.cc

@ -1865,21 +1865,23 @@ Status DBImpl::FlushMemTable(ColumnFamilyData* cfd,
w.done = false; w.done = false;
w.timeout_hint_us = kNoTimeOut; w.timeout_hint_us = kNoTimeOut;
WriteContext context; Status s;
mutex_.Lock(); {
Status s = BeginWrite(&w, 0); WriteContext context;
assert(s.ok() && !w.done); // No timeout and nobody should do our job MutexLock guard_lock(&mutex_);
s = BeginWrite(&w, 0);
// SetNewMemtableAndNewLogFile() will release and reacquire mutex assert(s.ok() && !w.done); // No timeout and nobody should do our job
// during execution
s = SetNewMemtableAndNewLogFile(cfd, &context); // SetNewMemtableAndNewLogFile() will release and reacquire mutex
cfd->imm()->FlushRequested(); // during execution
MaybeScheduleFlushOrCompaction(); s = SetNewMemtableAndNewLogFile(cfd, &context);
cfd->imm()->FlushRequested();
MaybeScheduleFlushOrCompaction();
assert(!writers_.empty()); assert(!writers_.empty());
assert(writers_.front() == &w); assert(writers_.front() == &w);
EndWrite(&w, &w, s); EndWrite(&w, &w, s);
mutex_.Unlock(); }
if (s.ok() && options.wait) { if (s.ok() && options.wait) {

Loading…
Cancel
Save