Commit 4a20bbed authored by Phil Willoughby's avatar Phil Willoughby Committed by Facebook Github Bot

rlock() should work with const input

Summary: The instance method is permitted on `const` objects, so the ADL method should also accept a `const&` input.

Reviewed By: yfeldblum

Differential Revision: D8240295

fbshipit-source-id: 960aa5567afea3f52b91c1b83566820f5ecefc4d
parent 57ebbcd1
......@@ -894,9 +894,9 @@ class SynchronizedWLocker : public SynchronizedLockerBase<Synchronized> {
}
};
template <typename Synchronized>
class SynchronizedRLocker : public SynchronizedLockerBase<Synchronized> {
class SynchronizedRLocker : public SynchronizedLockerBase<Synchronized const> {
public:
using SynchronizedLockerBase<Synchronized>::SynchronizedLockerBase;
using SynchronizedLockerBase<Synchronized const>::SynchronizedLockerBase;
using LockedPtr = typename Synchronized::ConstLockedPtr;
auto lock() {
......@@ -1653,7 +1653,7 @@ auto wlock(Synchronized<Data, Mutex>& synchronized) {
return detail::SynchronizedWLocker<Synchronized<Data, Mutex>>{synchronized};
}
template <typename Data, typename Mutex>
auto rlock(Synchronized<Data, Mutex>& synchronized) {
auto rlock(Synchronized<Data, Mutex> const& synchronized) {
return detail::SynchronizedRLocker<Synchronized<Data, Mutex>>{synchronized};
}
template <typename Data, typename Mutex>
......
......@@ -823,7 +823,7 @@ TEST(FollyLockTest, TestVariadicLockWithSynchronized) {
{
auto syncs = std::array<folly::Synchronized<int>, 3>{};
auto& one = syncs[0];
auto& two = syncs[1];
auto const& two = syncs[1];
auto& three = syncs[2];
auto locks =
lock(folly::wlock(one), folly::rlock(two), folly::wlock(three));
......
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