Commit ea29a7a6 authored by Aaryaman Sagar's avatar Aaryaman Sagar Committed by Facebook Github Bot

Remove const folly::Synchronized upgrade lock acquire

Summary: Users acquiring upgrade locks should only be allowed to lock the synchronized object when it is non-const.  Because an upgrade locks are permitted to transition to write locks when mutation is required.  At which point non-const access is often required on the Synchronized object.

Reviewed By: yfeldblum

Differential Revision: D8654360

fbshipit-source-id: c2a6574bd880db0d8e4c90166e288f5b83542ad6
parent 0aa15e94
...@@ -257,9 +257,6 @@ class SynchronizedBase<Subclass, detail::MutexLevel::UPGRADE> ...@@ -257,9 +257,6 @@ class SynchronizedBase<Subclass, detail::MutexLevel::UPGRADE>
UpgradeLockedPtr ulock() { UpgradeLockedPtr ulock() {
return UpgradeLockedPtr(static_cast<Subclass*>(this)); return UpgradeLockedPtr(static_cast<Subclass*>(this));
} }
ConstUpgradeLockedPtr ulock() const {
return ConstUpgradeLockedPtr(static_cast<const Subclass*>(this));
}
/** /**
* Attempts to acquire the lock in upgrade mode. If acquisition is * Attempts to acquire the lock in upgrade mode. If acquisition is
...@@ -271,9 +268,6 @@ class SynchronizedBase<Subclass, detail::MutexLevel::UPGRADE> ...@@ -271,9 +268,6 @@ class SynchronizedBase<Subclass, detail::MutexLevel::UPGRADE>
TryUpgradeLockedPtr tryULock() { TryUpgradeLockedPtr tryULock() {
return TryUpgradeLockedPtr{static_cast<Subclass*>(this)}; return TryUpgradeLockedPtr{static_cast<Subclass*>(this)};
} }
ConstTryUpgradeLockedPtr tryULock() const {
return ConstTryUpgradeLockedPtr{static_cast<const Subclass*>(this)};
}
/** /**
* Acquire an upgrade lock and return a LockedPtr that can be used to safely * Acquire an upgrade lock and return a LockedPtr that can be used to safely
...@@ -285,11 +279,6 @@ class SynchronizedBase<Subclass, detail::MutexLevel::UPGRADE> ...@@ -285,11 +279,6 @@ class SynchronizedBase<Subclass, detail::MutexLevel::UPGRADE>
UpgradeLockedPtr ulock(const std::chrono::duration<Rep, Period>& timeout) { UpgradeLockedPtr ulock(const std::chrono::duration<Rep, Period>& timeout) {
return UpgradeLockedPtr(static_cast<Subclass*>(this), timeout); return UpgradeLockedPtr(static_cast<Subclass*>(this), timeout);
} }
template <class Rep, class Period>
UpgradeLockedPtr ulock(
const std::chrono::duration<Rep, Period>& timeout) const {
return ConstUpgradeLockedPtr(static_cast<const Subclass*>(this), timeout);
}
/** /**
* Invoke a function while holding the lock. * Invoke a function while holding the lock.
...@@ -312,7 +301,7 @@ class SynchronizedBase<Subclass, detail::MutexLevel::UPGRADE> ...@@ -312,7 +301,7 @@ class SynchronizedBase<Subclass, detail::MutexLevel::UPGRADE>
* moveFromUpgradeToWrite() method) * moveFromUpgradeToWrite() method)
*/ */
template <class Function> template <class Function>
auto withULock(Function&& function) const { auto withULock(Function&& function) {
return function(*ulock()); return function(*ulock());
} }
...@@ -332,10 +321,6 @@ class SynchronizedBase<Subclass, detail::MutexLevel::UPGRADE> ...@@ -332,10 +321,6 @@ class SynchronizedBase<Subclass, detail::MutexLevel::UPGRADE>
auto withULockPtr(Function&& function) { auto withULockPtr(Function&& function) {
return function(ulock()); return function(ulock());
} }
template <class Function>
auto withULockPtr(Function&& function) const {
return function(ulock());
}
}; };
/** /**
...@@ -1566,10 +1551,6 @@ auto ulock(Synchronized<D, M>& synchronized, Args&&... args) { ...@@ -1566,10 +1551,6 @@ auto ulock(Synchronized<D, M>& synchronized, Args&&... args) {
return detail::ulock(synchronized, std::forward<Args>(args)...); return detail::ulock(synchronized, std::forward<Args>(args)...);
} }
template <typename D, typename M, typename... Args> template <typename D, typename M, typename... Args>
auto ulock(const Synchronized<D, M>& synchronized, Args&&... args) {
return detail::ulock(synchronized, std::forward<Args>(args)...);
}
template <typename D, typename M, typename... Args>
auto lock(Synchronized<D, M>& synchronized, Args&&... args) { auto lock(Synchronized<D, M>& synchronized, Args&&... args) {
return detail::lock(synchronized, std::forward<Args>(args)...); return detail::lock(synchronized, std::forward<Args>(args)...);
} }
......
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