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