Commit a9ade34f authored by Jon Maltiel Swenson's avatar Jon Maltiel Swenson Committed by Facebook Github Bot

Rename unique_lock variables in `TimedMutex` in order to avoid shadowing

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
parent 6d012519
...@@ -26,7 +26,7 @@ namespace fibers { ...@@ -26,7 +26,7 @@ namespace fibers {
template <typename WaitFunc> template <typename WaitFunc>
TimedMutex::LockResult TimedMutex::lockHelper(WaitFunc&& waitFunc) { TimedMutex::LockResult TimedMutex::lockHelper(WaitFunc&& waitFunc) {
std::unique_lock<folly::SpinLock> lock(lock_); std::unique_lock<folly::SpinLock> ulock(lock_);
if (!locked_) { if (!locked_) {
locked_ = true; locked_ = true;
return LockResult::SUCCESS; return LockResult::SUCCESS;
...@@ -53,7 +53,7 @@ TimedMutex::LockResult TimedMutex::lockHelper(WaitFunc&& waitFunc) { ...@@ -53,7 +53,7 @@ TimedMutex::LockResult TimedMutex::lockHelper(WaitFunc&& waitFunc) {
threadWaiters_.push_back(waiter); threadWaiters_.push_back(waiter);
} }
lock.unlock(); ulock.unlock();
if (!waitFunc(waiter)) { if (!waitFunc(waiter)) {
return LockResult::TIMEOUT; return LockResult::TIMEOUT;
...@@ -155,11 +155,11 @@ inline void TimedMutex::unlock() { ...@@ -155,11 +155,11 @@ inline void TimedMutex::unlock() {
template <typename BatonType> template <typename BatonType>
void TimedRWMutex<BatonType>::read_lock() { void TimedRWMutex<BatonType>::read_lock() {
std::unique_lock<folly::SpinLock> lock{lock_}; std::unique_lock<folly::SpinLock> ulock{lock_};
if (state_ == State::WRITE_LOCKED) { if (state_ == State::WRITE_LOCKED) {
MutexWaiter waiter; MutexWaiter waiter;
read_waiters_.push_back(waiter); read_waiters_.push_back(waiter);
lock.unlock(); ulock.unlock();
waiter.baton.wait(); waiter.baton.wait();
assert(state_ == State::READ_LOCKED); assert(state_ == State::READ_LOCKED);
return; return;
...@@ -176,11 +176,11 @@ template <typename BatonType> ...@@ -176,11 +176,11 @@ template <typename BatonType>
template <typename Rep, typename Period> template <typename Rep, typename Period>
bool TimedRWMutex<BatonType>::timed_read_lock( bool TimedRWMutex<BatonType>::timed_read_lock(
const std::chrono::duration<Rep, Period>& duration) { 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) { if (state_ == State::WRITE_LOCKED) {
MutexWaiter waiter; MutexWaiter waiter;
read_waiters_.push_back(waiter); read_waiters_.push_back(waiter);
lock.unlock(); ulock.unlock();
if (!waiter.baton.timed_wait(duration)) { if (!waiter.baton.timed_wait(duration)) {
// We timed out. Two cases: // We timed out. Two cases:
...@@ -222,7 +222,7 @@ bool TimedRWMutex<BatonType>::try_read_lock() { ...@@ -222,7 +222,7 @@ bool TimedRWMutex<BatonType>::try_read_lock() {
template <typename BatonType> template <typename BatonType>
void TimedRWMutex<BatonType>::write_lock() { void TimedRWMutex<BatonType>::write_lock() {
std::unique_lock<folly::SpinLock> lock{lock_}; std::unique_lock<folly::SpinLock> ulock{lock_};
if (state_ == State::UNLOCKED) { if (state_ == State::UNLOCKED) {
verify_unlocked_properties(); verify_unlocked_properties();
state_ = State::WRITE_LOCKED; state_ = State::WRITE_LOCKED;
...@@ -230,7 +230,7 @@ void TimedRWMutex<BatonType>::write_lock() { ...@@ -230,7 +230,7 @@ void TimedRWMutex<BatonType>::write_lock() {
} }
MutexWaiter waiter; MutexWaiter waiter;
write_waiters_.push_back(waiter); write_waiters_.push_back(waiter);
lock.unlock(); ulock.unlock();
waiter.baton.wait(); waiter.baton.wait();
} }
...@@ -238,7 +238,7 @@ template <typename BatonType> ...@@ -238,7 +238,7 @@ template <typename BatonType>
template <typename Rep, typename Period> template <typename Rep, typename Period>
bool TimedRWMutex<BatonType>::timed_write_lock( bool TimedRWMutex<BatonType>::timed_write_lock(
const std::chrono::duration<Rep, Period>& duration) { 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) { if (state_ == State::UNLOCKED) {
verify_unlocked_properties(); verify_unlocked_properties();
state_ = State::WRITE_LOCKED; state_ = State::WRITE_LOCKED;
...@@ -246,7 +246,7 @@ bool TimedRWMutex<BatonType>::timed_write_lock( ...@@ -246,7 +246,7 @@ bool TimedRWMutex<BatonType>::timed_write_lock(
} }
MutexWaiter waiter; MutexWaiter waiter;
write_waiters_.push_back(waiter); write_waiters_.push_back(waiter);
lock.unlock(); ulock.unlock();
if (!waiter.baton.timed_wait(duration)) { if (!waiter.baton.timed_wait(duration)) {
// We timed out. Two cases: // We timed out. Two cases:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment