proxygen
|
#include <folly/Function.h>
#include <folly/Likely.h>
#include <folly/LockTraits.h>
#include <folly/Preprocessor.h>
#include <folly/SharedMutex.h>
#include <folly/Traits.h>
#include <folly/Utility.h>
#include <folly/container/Foreach.h>
#include <folly/functional/ApplyTuple.h>
#include <glog/logging.h>
#include <array>
#include <mutex>
#include <tuple>
#include <type_traits>
#include <utility>
Go to the source code of this file.
Namespaces | |
folly | |
—— Concurrent Priority Queue Implementation —— | |
folly::detail | |
Macros | |
#define | SYNCHRONIZED_VAR(var) FB_CONCATENATE(SYNCHRONIZED_##var##_, __LINE__) |
#define | SYNCHRONIZED(...) |
#define | TIMED_SYNCHRONIZED(timeout, ...) |
#define | SYNCHRONIZED_CONST(...) |
#define | TIMED_SYNCHRONIZED_CONST(timeout, ...) |
#define | SYNCHRONIZED_DUAL(n1, e1, n2, e2) |
Typedefs | |
template<class Mutex > | |
using | folly::MutexLevelValue = detail::MutexLevelValueImpl< true, LockTraits< Mutex >::is_shared, LockTraits< Mutex >::is_upgrade > |
template<class SynchronizedType > | |
using | folly::detail::SynchronizedDataType = typename std::conditional< std::is_const< SynchronizedType >::value, typename SynchronizedType::DataType const, typename SynchronizedType::DataType >::type |
template<class SynchronizedType > | |
using | folly::detail::LockedPtrType = typename std::conditional< std::is_const< SynchronizedType >::value, typename SynchronizedType::ConstLockedPtr, typename SynchronizedType::LockedPtr >::type |
Functions | |
template<typename Synchronized , typename LockFunc , typename TryLockFunc , typename... Args> | |
auto | folly::detail::makeSynchronizedLocker (Synchronized &synchronized, LockFunc &&lockFunc, TryLockFunc &&tryLockFunc, Args &&...args) |
template<typename... SynchronizedLocker> | |
auto | folly::detail::lock (SynchronizedLocker...lockersIn) -> std::tuple< typename SynchronizedLocker::LockedPtr... > |
template<typename Synchronized , typename... Args> | |
auto | folly::detail::wlock (Synchronized &synchronized, Args &&...args) |
template<typename Synchronized , typename... Args> | |
auto | folly::detail::rlock (Synchronized &synchronized, Args &&...args) |
template<typename Synchronized , typename... Args> | |
auto | folly::detail::ulock (Synchronized &synchronized, Args &&...args) |
template<typename Synchronized , typename... Args> | |
auto | folly::detail::lock (Synchronized &synchronized, Args &&...args) |
template<typename D , typename M , typename... Args> | |
auto | folly::wlock (Synchronized< D, M > &synchronized, Args &&...args) |
template<typename Data , typename Mutex , typename... Args> | |
auto | folly::rlock (const Synchronized< Data, Mutex > &synchronized, Args &&...args) |
template<typename D , typename M , typename... Args> | |
auto | folly::ulock (Synchronized< D, M > &synchronized, Args &&...args) |
template<typename D , typename M , typename... Args> | |
auto | folly::lock (Synchronized< D, M > &synchronized, Args &&...args) |
template<typename D , typename M , typename... Args> | |
auto | folly::lock (const Synchronized< D, M > &synchronized, Args &&...args) |
template<typename Func , typename... SynchronizedLockers> | |
decltype(auto) | folly::synchronized (Func &&func, SynchronizedLockers &&...lockers) |
template<typename LockableOne , typename LockableTwo , typename... Lockables> | |
void | folly::lock (LockableOne &one, LockableTwo &two, Lockables &...lockables) |
template<class Sync1 , class Sync2 > | |
std::tuple< detail::LockedPtrType< Sync1 >, detail::LockedPtrType< Sync2 > > | folly::acquireLocked (Sync1 &l1, Sync2 &l2) |
template<class Sync1 , class Sync2 > | |
std::pair< detail::LockedPtrType< Sync1 >, detail::LockedPtrType< Sync2 > > | folly::acquireLockedPair (Sync1 &l1, Sync2 &l2) |
template<class T , class M > | |
void | folly::swap (Synchronized< T, M > &lhs, Synchronized< T, M > &rhs) |
#define SYNCHRONIZED | ( | ... | ) |
SYNCHRONIZED is the main facility that makes Synchronized<T> helpful. It is a pseudo-statement that introduces a scope where the object is locked. Inside that scope you get to access the unadorned datum.
Example:
Synchronized<vector<int>> svector; ... SYNCHRONIZED (svector) { ... use svector as a vector<int> ... } or SYNCHRONIZED (v, svector) { ... use v as a vector<int> ... }
Refer to folly/docs/Synchronized.md for a detailed explanation and more examples.
Definition at line 1686 of file Synchronized.h.
Referenced by folly::sync_tests::testDeprecated().
#define SYNCHRONIZED_CONST | ( | ... | ) |
Similar to SYNCHRONIZED, but only uses a read lock.
Definition at line 1724 of file Synchronized.h.
Referenced by folly::sync_tests::testDeprecated().
#define SYNCHRONIZED_DUAL | ( | n1, | |
e1, | |||
n2, | |||
e2 | |||
) |
Synchronizes two Synchronized objects (they may encapsulate different data). Synchronization is done in increasing address of object order, so there is no deadlock risk.
Definition at line 1743 of file Synchronized.h.
Referenced by folly::sync_tests::testDualLocking(), and folly::sync_tests::testDualLockingWithConst().
#define SYNCHRONIZED_VAR | ( | var | ) | FB_CONCATENATE(SYNCHRONIZED_##var##_, __LINE__) |
Disambiguate the name var by concatenating the line number of the original point of expansion. This avoids shadowing warnings for nested SYNCHRONIZEDs. The name is consistent if used multiple times within another macro. Only for internal use.
Definition at line 1667 of file Synchronized.h.
#define TIMED_SYNCHRONIZED | ( | timeout, | |
... | |||
) |
Definition at line 1707 of file Synchronized.h.
Referenced by folly::sync_tests::testTimedSynchronized().
#define TIMED_SYNCHRONIZED_CONST | ( | timeout, | |
... | |||
) |
Similar to TIMED_SYNCHRONIZED, but only uses a read lock.
Definition at line 1732 of file Synchronized.h.
Referenced by folly::sync_tests::testTimedSynchronizedWithConst().