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

complete the transition away from LockTraits

Summary: `Synchronized` no longer needs a full lock-traits facility. Absorb the few things it needs and cut the rest.

Reviewed By: simpkins

Differential Revision: D28774648

fbshipit-source-id: 0679a3192a8eb17444628d12704cdc34fe5911b3
parent b65ef9f8
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -744,47 +744,62 @@ using LPtr = LockedPtr<Synchronized<int>, LockPolicy>; ...@@ -744,47 +744,62 @@ using LPtr = LockedPtr<Synchronized<int>, LockPolicy>;
namespace { namespace {
template <template <typename...> class Trait> template <template <typename...> class Trait>
void testLockedPtrCompatibilityExclusive() { void testLockedPtrCompatibilityExclusive() {
EXPECT_TRUE(( EXPECT_TRUE((Trait<
Trait<LPtr<LockPolicyExclusive>, LPtr<LockPolicyTryExclusive>&&>::value)); LPtr<detail::SynchronizedLockPolicyExclusive>,
LPtr<detail::SynchronizedLockPolicyTryExclusive>&&>::value));
EXPECT_FALSE(
(Trait<LPtr<LockPolicyExclusive>&, LPtr<LockPolicyShared>&&>::value)); EXPECT_FALSE((Trait<
EXPECT_FALSE( LPtr<detail::SynchronizedLockPolicyExclusive>&,
(Trait<LPtr<LockPolicyExclusive>, LPtr<LockPolicyTryShared>&&>::value)); LPtr<detail::SynchronizedLockPolicyShared>&&>::value));
EXPECT_FALSE( EXPECT_FALSE((Trait<
(Trait<LPtr<LockPolicyExclusive>, LPtr<LockPolicyUpgrade>&&>::value)); LPtr<detail::SynchronizedLockPolicyExclusive>,
EXPECT_FALSE( LPtr<detail::SynchronizedLockPolicyTryShared>&&>::value));
(Trait<LPtr<LockPolicyExclusive>, LPtr<LockPolicyTryUpgrade>&&>::value)); EXPECT_FALSE((Trait<
LPtr<detail::SynchronizedLockPolicyExclusive>,
LPtr<detail::SynchronizedLockPolicyUpgrade>&&>::value));
EXPECT_FALSE((Trait<
LPtr<detail::SynchronizedLockPolicyExclusive>,
LPtr<detail::SynchronizedLockPolicyTryUpgrade>&&>::value));
} }
template <template <typename...> class Trait> template <template <typename...> class Trait>
void testLockedPtrCompatibilityShared() { void testLockedPtrCompatibilityShared() {
EXPECT_TRUE( EXPECT_TRUE((Trait<
(Trait<LPtr<LockPolicyShared>, LPtr<LockPolicyTryShared>&&>::value)); LPtr<detail::SynchronizedLockPolicyShared>,
LPtr<detail::SynchronizedLockPolicyTryShared>&&>::value));
EXPECT_FALSE(
(Trait<LPtr<LockPolicyShared>, LPtr<LockPolicyExclusive>&&>::value)); EXPECT_FALSE((Trait<
EXPECT_FALSE( LPtr<detail::SynchronizedLockPolicyShared>,
(Trait<LPtr<LockPolicyShared>, LPtr<LockPolicyTryExclusive>&&>::value)); LPtr<detail::SynchronizedLockPolicyExclusive>&&>::value));
EXPECT_FALSE( EXPECT_FALSE((Trait<
(Trait<LPtr<LockPolicyShared>, LPtr<LockPolicyUpgrade>&&>::value)); LPtr<detail::SynchronizedLockPolicyShared>,
EXPECT_FALSE( LPtr<detail::SynchronizedLockPolicyTryExclusive>&&>::value));
(Trait<LPtr<LockPolicyShared>, LPtr<LockPolicyTryUpgrade>&&>::value)); EXPECT_FALSE((Trait<
LPtr<detail::SynchronizedLockPolicyShared>,
LPtr<detail::SynchronizedLockPolicyUpgrade>&&>::value));
EXPECT_FALSE((Trait<
LPtr<detail::SynchronizedLockPolicyShared>,
LPtr<detail::SynchronizedLockPolicyTryUpgrade>&&>::value));
} }
template <template <typename...> class Trait> template <template <typename...> class Trait>
void testLockedPtrCompatibilityUpgrade() { void testLockedPtrCompatibilityUpgrade() {
EXPECT_TRUE( EXPECT_TRUE((Trait<
(Trait<LPtr<LockPolicyUpgrade>, LPtr<LockPolicyTryUpgrade>&&>::value)); LPtr<detail::SynchronizedLockPolicyUpgrade>,
LPtr<detail::SynchronizedLockPolicyTryUpgrade>&&>::value));
EXPECT_FALSE(
(Trait<LPtr<LockPolicyUpgrade>, LPtr<LockPolicyExclusive>&&>::value)); EXPECT_FALSE((Trait<
EXPECT_FALSE( LPtr<detail::SynchronizedLockPolicyUpgrade>,
(Trait<LPtr<LockPolicyUpgrade>, LPtr<LockPolicyTryExclusive>&&>::value)); LPtr<detail::SynchronizedLockPolicyExclusive>&&>::value));
EXPECT_FALSE( EXPECT_FALSE((Trait<
(Trait<LPtr<LockPolicyUpgrade>, LPtr<LockPolicyShared>&&>::value)); LPtr<detail::SynchronizedLockPolicyUpgrade>,
EXPECT_FALSE( LPtr<detail::SynchronizedLockPolicyTryExclusive>&&>::value));
(Trait<LPtr<LockPolicyUpgrade>, LPtr<LockPolicyTryShared>&&>::value)); EXPECT_FALSE((Trait<
LPtr<detail::SynchronizedLockPolicyUpgrade>,
LPtr<detail::SynchronizedLockPolicyShared>&&>::value));
EXPECT_FALSE((Trait<
LPtr<detail::SynchronizedLockPolicyUpgrade>,
LPtr<detail::SynchronizedLockPolicyTryShared>&&>::value));
} }
} // namespace } // namespace
......
...@@ -101,7 +101,7 @@ void runParallel(size_t numThreads, const Function& function) { ...@@ -101,7 +101,7 @@ void runParallel(size_t numThreads, const Function& function) {
// testBasic() version for shared lock types // testBasic() version for shared lock types
template <class Mutex> template <class Mutex>
typename std::enable_if<folly::LockTraits<Mutex>::is_shared>::type std::enable_if_t<folly::detail::kSynchronizedMutexIsShared<void, Mutex>>
testBasicImpl() { testBasicImpl() {
folly::Synchronized<std::vector<int>, Mutex> obj; folly::Synchronized<std::vector<int>, Mutex> obj;
const auto& constObj = obj; const auto& constObj = obj;
...@@ -153,7 +153,7 @@ testBasicImpl() { ...@@ -153,7 +153,7 @@ testBasicImpl() {
// testBasic() version for non-shared lock types // testBasic() version for non-shared lock types
template <class Mutex> template <class Mutex>
typename std::enable_if<!folly::LockTraits<Mutex>::is_shared>::type std::enable_if_t<!folly::detail::kSynchronizedMutexIsShared<void, Mutex>>
testBasicImpl() { testBasicImpl() {
folly::Synchronized<std::vector<int>, Mutex> obj; folly::Synchronized<std::vector<int>, Mutex> obj;
const auto& constObj = obj; const auto& constObj = obj;
...@@ -198,7 +198,7 @@ void testBasic() { ...@@ -198,7 +198,7 @@ void testBasic() {
// testWithLock() version for shared lock types // testWithLock() version for shared lock types
template <class Mutex> template <class Mutex>
typename std::enable_if<folly::LockTraits<Mutex>::is_shared>::type std::enable_if_t<folly::detail::kSynchronizedMutexIsShared<void, Mutex>>
testWithLock() { testWithLock() {
folly::Synchronized<std::vector<int>, Mutex> obj; folly::Synchronized<std::vector<int>, Mutex> obj;
const auto& constObj = obj; const auto& constObj = obj;
...@@ -297,7 +297,7 @@ testWithLock() { ...@@ -297,7 +297,7 @@ testWithLock() {
// testWithLock() version for non-shared lock types // testWithLock() version for non-shared lock types
template <class Mutex> template <class Mutex>
typename std::enable_if<!folly::LockTraits<Mutex>::is_shared>::type std::enable_if_t<!folly::detail::kSynchronizedMutexIsShared<void, Mutex>>
testWithLock() { testWithLock() {
folly::Synchronized<std::vector<int>, Mutex> obj; folly::Synchronized<std::vector<int>, Mutex> obj;
...@@ -387,7 +387,7 @@ void testUnlockCommon() { ...@@ -387,7 +387,7 @@ void testUnlockCommon() {
// testUnlock() version for shared lock types // testUnlock() version for shared lock types
template <class Mutex> template <class Mutex>
typename std::enable_if<folly::LockTraits<Mutex>::is_shared>::type std::enable_if_t<folly::detail::kSynchronizedMutexIsShared<void, Mutex>>
testUnlock() { testUnlock() {
folly::Synchronized<int, Mutex> value{10}; folly::Synchronized<int, Mutex> value{10};
{ {
...@@ -420,7 +420,7 @@ testUnlock() { ...@@ -420,7 +420,7 @@ testUnlock() {
// testUnlock() version for non-shared lock types // testUnlock() version for non-shared lock types
template <class Mutex> template <class Mutex>
typename std::enable_if<!folly::LockTraits<Mutex>::is_shared>::type std::enable_if_t<!folly::detail::kSynchronizedMutexIsShared<void, Mutex>>
testUnlock() { testUnlock() {
folly::Synchronized<int, Mutex> value{10}; folly::Synchronized<int, Mutex> value{10};
{ {
......
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