Commit 168d50be authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

let proxy-lockable unlock pass the state by const&

Summary: Avoid questions of what may the mutex unlock method do to the passed state: nothing.

Reviewed By: aary

Differential Revision: D28895552

fbshipit-source-id: 8b73e76711bb553a344d958c80dcf14d56e74ffd
parent 1bc5dd9d
......@@ -83,7 +83,7 @@ ProxyLockableUniqueLock<Mutex>& ProxyLockableUniqueLock<Mutex>::operator=(
template <typename Mutex>
ProxyLockableUniqueLock<Mutex>::ProxyLockableUniqueLock(
mutex_type& mutex, std::adopt_lock_t, state_type state)
mutex_type& mutex, std::adopt_lock_t, const state_type& state)
: mutex_{std::addressof(mutex)}, state_{state} {
proxylockable_detail::throwIfNotLocked(state_);
}
......@@ -123,7 +123,9 @@ void ProxyLockableUniqueLock<Mutex>::unlock() {
proxylockable_detail::throwIfNoMutex(mutex_);
proxylockable_detail::throwIfNotLocked(state_);
mutex_->unlock(std::exchange(state_, state_type{}));
const auto& state = state_;
mutex_->unlock(state);
state_ = state_type{};
}
template <typename Mutex>
......
......@@ -78,7 +78,7 @@ class ProxyLockableUniqueLock {
* converts to true if the lock was successful
*/
ProxyLockableUniqueLock(
mutex_type& mutex, std::adopt_lock_t, state_type state);
mutex_type& mutex, std::adopt_lock_t, const state_type& state);
ProxyLockableUniqueLock(mutex_type& mutex, std::defer_lock_t) noexcept;
ProxyLockableUniqueLock(mutex_type& mutex, std::try_to_lock_t);
......
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