proxygen
folly::detail::UnlockPolicyExclusive< LockTraits > Struct Template Reference

#include <LockTraits.h>

Inheritance diagram for folly::detail::UnlockPolicyExclusive< LockTraits >:
folly::LockPolicyExclusive folly::LockPolicyTryExclusive folly::LockPolicyFromUpgradeToExclusive

Static Public Member Functions

template<typename Mutex >
static void unlock (Mutex &mutex)
 

Detailed Description

template<template< typename... > class LockTraits>
struct folly::detail::UnlockPolicyExclusive< LockTraits >

Unlock helpers

These help in determining whether it is safe for Synchronized::LockedPtr instances to be move assigned from one another. It is safe if they both have the same unlock policy, and it is not if they don't have the same unlock policy. For example

auto wlock = synchronized.wlock(); wlock.unlock();

wlock = synchronized.rlock();

This code would try to release the shared lock with a call to unlock(), resulting in possibly undefined behavior. By allowing the LockPolicy classes (defined below) to know what their unlocking behavior is, we can prevent against this by disabling unsafe conversions to and from incompatible LockedPtr types (they are incompatible if the underlying LockPolicy has different unlock policies.

Definition at line 372 of file LockTraits.h.

Member Function Documentation

template<template< typename... > class LockTraits>
template<typename Mutex >
static void folly::detail::UnlockPolicyExclusive< LockTraits >::unlock ( Mutex mutex)
inlinestatic

Definition at line 374 of file LockTraits.h.

Referenced by TEST().

374  {
375  LockTraits<Mutex>::unlock(mutex);
376  }
std::mutex mutex

The documentation for this struct was generated from the following file: