28 #include <type_traits> 33 #if defined(ANDROID) || defined(__ANDROID__) || defined(__APPLE__) || \ 35 #define FOLLY_LOCK_TRAITS_HAVE_TIMED_MUTEXES 0 37 #define FOLLY_LOCK_TRAITS_HAVE_TIMED_MUTEXES 1 63 template <
bool is_unique,
bool is_shared,
bool is_upgrade>
84 template <
class Mutex>
90 "The mutex type must support lock and unlock functions");
95 static constexpr
bool has_lock_unique =
true;
96 static constexpr
bool has_lock_timed =
98 static constexpr
bool has_lock_shared =
100 static constexpr
bool has_lock_upgrade =
111 template <
class Mutex, MutexLevel level,
bool is_timed>
114 template <
class Mutex>
116 static constexpr
bool is_timed{
false};
117 static constexpr
bool is_shared{
false};
118 static constexpr
bool is_upgrade{
false};
138 return mutex.try_lock();
146 template <
class Mutex>
149 static constexpr
bool is_timed{
false};
150 static constexpr
bool is_shared{
true};
151 static constexpr
bool is_upgrade{
false};
164 mutex.unlock_shared();
171 return mutex.try_lock_shared();
203 template <
class Mutex>
206 static constexpr
bool is_timed{
false};
207 static constexpr
bool is_shared{
true};
208 static constexpr
bool is_upgrade{
true};
214 mutex.lock_upgrade();
221 mutex.unlock_upgrade();
228 return mutex.try_lock_upgrade();
235 mutex.unlock_upgrade_and_lock();
242 mutex.unlock_and_lock_upgrade();
249 mutex.unlock_and_lock_shared();
256 mutex.unlock_upgrade_and_lock_shared();
260 template <
class Mutex>
263 static constexpr
bool is_timed{
true};
264 static constexpr
bool is_shared{
false};
265 static constexpr
bool is_upgrade{
false};
272 template <
class Rep,
class Period>
275 const std::chrono::duration<Rep, Period>& timeout) {
276 return mutex.try_lock_for(timeout);
285 template <
class Mutex>
289 static constexpr
bool is_timed{
true};
290 static constexpr
bool is_shared{
true};
291 static constexpr
bool is_upgrade{
false};
298 template <
class Rep,
class Period>
301 const std::chrono::duration<Rep, Period>& timeout) {
302 return mutex.try_lock_for(timeout);
310 template <
class Rep,
class Period>
313 const std::chrono::duration<Rep, Period>& timeout) {
314 return mutex.try_lock_shared_for(timeout);
318 template <
class Mutex>
322 static constexpr
bool is_timed{
true};
323 static constexpr
bool is_shared{
true};
324 static constexpr
bool is_upgrade{
true};
331 template <
class Rep,
class Period>
334 const std::chrono::duration<Rep, Period>& timeout) {
335 return mutex.try_lock_upgrade_for(timeout);
343 template <
class Rep,
class Period>
346 const std::chrono::duration<Rep, Period>& timeout) {
347 return mutex.try_unlock_upgrade_and_lock_for(timeout);
371 template <
template <
typename...>
class LockTraits>
373 template <
typename Mutex>
378 template <
template <
typename...>
class LockTraits>
380 template <
typename Mutex>
385 template <
template <
typename...>
class LockTraits>
387 template <
typename Mutex>
446 template <
class Mutex>
450 detail::MutexLevelValueImpl<
451 detail::LockInterfaceDispatcher<Mutex>::has_lock_unique,
452 detail::LockInterfaceDispatcher<Mutex>::has_lock_shared,
453 detail::LockInterfaceDispatcher<Mutex>::has_lock_upgrade>::value,
454 detail::LockInterfaceDispatcher<Mutex>::has_lock_timed> {};
456 template <
class Mutex>
471 template <
class Mutex>
476 template <
class Mutex,
class Rep,
class Period>
479 const std::chrono::duration<Rep, Period>& timeout) {
491 template <
class Mutex>
496 template <
class Mutex,
class Rep,
class Period>
499 const std::chrono::duration<Rep, Period>& timeout) {
514 template <
class Mutex>
519 template <
class Mutex,
class Rep,
class Period>
522 const std::chrono::duration<Rep, Period>& timeout) {
537 template <
class Mutex>
550 template <
class Mutex>
563 template <
class Mutex>
580 template <
class Mutex>
585 template <
class Mutex,
class Rep,
class Period>
588 const std::chrono::duration<Rep, Period>& timeout) {
601 template <
class Mutex>
606 template <
class Mutex,
class Rep,
class Period>
609 const std::chrono::duration<Rep, Period>&) {
625 template <
class Mutex>
630 template <
class Mutex,
class Rep,
class Period>
633 const std::chrono::duration<Rep, Period>&) {
649 template <
class Mutex>
654 template <
class Mutex,
class Rep,
class Period>
657 const std::chrono::duration<Rep, Period>&) {
static void unlock(Mutex &mutex)
static std::true_type lock(Mutex &mutex)
static bool lock(Mutex &mutex)
static bool try_lock_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &timeout)
static void unlock(Mutex &mutex)
static std::true_type lock(Mutex &mutex)
static bool try_lock_shared_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &timeout)
static bool try_unlock_upgrade_and_lock_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &timeout)
static void unlock_and_lock_shared(Mutex &mutex)
static bool try_lock_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &timeout)
static void unlock_upgrade(Mutex &mutex)
static void unlock(Mutex &mutex)
static void lock_upgrade(Mutex &mutex)
static void unlock(Mutex &mutex)
—— Concurrent Priority Queue Implementation ——
std::chrono::milliseconds duration
static bool try_lock_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &)
static std::true_type lock(Mutex &mutex)
bool_constant< true > true_type
static void unlock_and_lock_upgrade(Mutex &mutex)
static bool try_lock_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &)
static std::true_type lock(Mutex &mutex)
FOLLY_CREATE_MEMBER_INVOKE_TRAITS(lock, lock)
static bool try_lock_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &)
static std::true_type lock(Mutex &mutex)
auto lock(SynchronizedLocker...lockersIn) -> std::tuple< typename SynchronizedLocker::LockedPtr... >
static bool try_lock_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &timeout)
static const char *const value
static bool lock(Mutex &mutex)
static void lock_shared(Mutex &mutex)
static bool try_lock_upgrade(Mutex &mutex)
static bool try_lock_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &timeout)
std::enable_if< ExprIsConst< Constness >::value, Map >::type member(Return(Class::*member)() const)
static bool try_lock(Mutex &mutex)
static std::true_type lock(Mutex &mutex)
static bool lock(Mutex &mutex)
static void unlock_upgrade_and_lock(Mutex &mutex)
static void unlock_upgrade_and_lock_shared(Mutex &mutex)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
static void lock(Mutex &mutex)
static bool try_lock_shared(Mutex &mutex)
static void unlock_shared(Mutex &mutex)
static bool try_lock_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &timeout)
static bool try_lock_upgrade_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &timeout)
static std::true_type lock(Mutex &mutex)
static bool try_lock_for(Mutex &mutex, const std::chrono::duration< Rep, Period > &timeout)