Commit 3c4a013f authored by Caren Thomas's avatar Caren Thomas Committed by Facebook Github Bot 5

Add very basic compatibility with folly locks for synchronized

Summary: Add folly locks to the HasLockUnlock struct so that they can be used inside Synchronized. acquireReadWrite() and releaseReadWrite() functions are added to each lock class so that their .lock and .unlock methods are accessible by Synchronized. These changes allow an extremely basic level of compatibility for the purpose of running benchmarks and so compatibility with dual_locking, etc. have not been tested.

Reviewed By: simpkins

Differential Revision: D3434621

fbshipit-source-id: d55cffbb1eccaf23645384b9a41f85c5df593ffe
parent cc5485f8
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#pragma once #pragma once
#include <type_traits>
#include <folly/detail/SpinLockImpl.h> #include <folly/detail/SpinLockImpl.h>
namespace folly { namespace folly {
...@@ -62,4 +64,11 @@ class SpinLockGuardImpl : private boost::noncopyable { ...@@ -62,4 +64,11 @@ class SpinLockGuardImpl : private boost::noncopyable {
typedef SpinLockGuardImpl<SpinLock> SpinLockGuard; typedef SpinLockGuardImpl<SpinLock> SpinLockGuard;
namespace detail {
template <class T>
struct HasLockUnlock;
template <>
struct HasLockUnlock<folly::SpinLock> : public std::true_type {};
}
} }
...@@ -19,9 +19,10 @@ ...@@ -19,9 +19,10 @@
// Test bed for folly/Synchronized.h // Test bed for folly/Synchronized.h
#include <folly/Portability.h> #include <folly/Portability.h>
#include <folly/Synchronized.h>
#include <folly/RWSpinLock.h> #include <folly/RWSpinLock.h>
#include <folly/SharedMutex.h> #include <folly/SharedMutex.h>
#include <folly/SpinLock.h>
#include <folly/Synchronized.h>
#include <folly/test/SynchronizedTestLib.h> #include <folly/test/SynchronizedTestLib.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -46,6 +47,7 @@ using SynchronizedTestTypes = testing::Types ...@@ -46,6 +47,7 @@ using SynchronizedTestTypes = testing::Types
, boost::recursive_timed_mutex , boost::recursive_timed_mutex
#endif #endif
, boost::shared_mutex , boost::shared_mutex
, folly::SpinLock
#ifdef RW_SPINLOCK_USE_X86_INTRINSIC_ #ifdef RW_SPINLOCK_USE_X86_INTRINSIC_
, folly::RWTicketSpinLock32 , folly::RWTicketSpinLock32
, folly::RWTicketSpinLock64 , folly::RWTicketSpinLock64
......
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