Rename unique_lock variables in `TimedMutex` in order to avoid shadowing
authorJon Maltiel Swenson <jmswen@fb.com>
Mon, 23 Oct 2017 17:16:53 +0000 (10:16 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 23 Oct 2017 17:20:36 +0000 (10:20 -0700)
Summary: Rename `std::unique_lock` variables named `lock` to `ulock` in `folly::fibers::TimedMutex` member functions in order to avoid shadowing.

Reviewed By: andreazevedo

Differential Revision: D6123449

fbshipit-source-id: 5fa331bb1541ac995d9b69360ee09923c14f6698

folly/fibers/TimedMutex-inl.h

index 07adf7b458e36173d9776615e56687d770e4ef0a..a6db21ab9e4a1ec790547fbf3556247939b4e279 100644 (file)
@@ -26,7 +26,7 @@ namespace fibers {
 
 template <typename WaitFunc>
 TimedMutex::LockResult TimedMutex::lockHelper(WaitFunc&& waitFunc) {
-  std::unique_lock<folly::SpinLock> lock(lock_);
+  std::unique_lock<folly::SpinLock> ulock(lock_);
   if (!locked_) {
     locked_ = true;
     return LockResult::SUCCESS;
@@ -53,7 +53,7 @@ TimedMutex::LockResult TimedMutex::lockHelper(WaitFunc&& waitFunc) {
     threadWaiters_.push_back(waiter);
   }
 
-  lock.unlock();
+  ulock.unlock();
 
   if (!waitFunc(waiter)) {
     return LockResult::TIMEOUT;
@@ -155,11 +155,11 @@ inline void TimedMutex::unlock() {
 
 template <typename BatonType>
 void TimedRWMutex<BatonType>::read_lock() {
-  std::unique_lock<folly::SpinLock> lock{lock_};
+  std::unique_lock<folly::SpinLock> ulock{lock_};
   if (state_ == State::WRITE_LOCKED) {
     MutexWaiter waiter;
     read_waiters_.push_back(waiter);
-    lock.unlock();
+    ulock.unlock();
     waiter.baton.wait();
     assert(state_ == State::READ_LOCKED);
     return;
@@ -176,11 +176,11 @@ template <typename BatonType>
 template <typename Rep, typename Period>
 bool TimedRWMutex<BatonType>::timed_read_lock(
     const std::chrono::duration<Rep, Period>& duration) {
-  std::unique_lock<folly::SpinLock> lock{lock_};
+  std::unique_lock<folly::SpinLock> ulock{lock_};
   if (state_ == State::WRITE_LOCKED) {
     MutexWaiter waiter;
     read_waiters_.push_back(waiter);
-    lock.unlock();
+    ulock.unlock();
 
     if (!waiter.baton.timed_wait(duration)) {
       // We timed out. Two cases:
@@ -222,7 +222,7 @@ bool TimedRWMutex<BatonType>::try_read_lock() {
 
 template <typename BatonType>
 void TimedRWMutex<BatonType>::write_lock() {
-  std::unique_lock<folly::SpinLock> lock{lock_};
+  std::unique_lock<folly::SpinLock> ulock{lock_};
   if (state_ == State::UNLOCKED) {
     verify_unlocked_properties();
     state_ = State::WRITE_LOCKED;
@@ -230,7 +230,7 @@ void TimedRWMutex<BatonType>::write_lock() {
   }
   MutexWaiter waiter;
   write_waiters_.push_back(waiter);
-  lock.unlock();
+  ulock.unlock();
   waiter.baton.wait();
 }
 
@@ -238,7 +238,7 @@ template <typename BatonType>
 template <typename Rep, typename Period>
 bool TimedRWMutex<BatonType>::timed_write_lock(
     const std::chrono::duration<Rep, Period>& duration) {
-  std::unique_lock<folly::SpinLock> lock{lock_};
+  std::unique_lock<folly::SpinLock> ulock{lock_};
   if (state_ == State::UNLOCKED) {
     verify_unlocked_properties();
     state_ = State::WRITE_LOCKED;
@@ -246,7 +246,7 @@ bool TimedRWMutex<BatonType>::timed_write_lock(
   }
   MutexWaiter waiter;
   write_waiters_.push_back(waiter);
-  lock.unlock();
+  ulock.unlock();
 
   if (!waiter.baton.timed_wait(duration)) {
     // We timed out. Two cases: