proxygen
WaitableMutex Class Reference
Inheritance diagram for WaitableMutex:

Public Member Functions

void unlock ()
 
template<typename Wait >
void wait (Wait wfunc)
 

Private Types

using Lot = ParkingLot< std::function< bool(void)>>
 

Static Private Attributes

static Lot lot
 

Detailed Description

Definition at line 73 of file ParkingLotTest.cpp.

Member Typedef Documentation

using WaitableMutex::Lot = ParkingLot<std::function<bool(void)>>
private

Definition at line 74 of file ParkingLotTest.cpp.

Member Function Documentation

void WaitableMutex::unlock ( )
inline

Definition at line 78 of file ParkingLotTest.cpp.

References folly::RemoveBreak, folly::RemoveContinue, uint64_t, and folly::ParkingLot< Data >::unpark().

78  {
79  bool unparked = false;
80  lot.unpark(uint64_t(this), [&](std::function<bool(void)> wfunc) {
81  if (wfunc()) {
82  unparked = true;
83  return UnparkControl::RemoveBreak;
84  } else {
85  return UnparkControl::RemoveContinue;
86  }
87  });
88  if (!unparked) {
89  std::mutex::unlock();
90  }
91  // Otherwise, we pass mutex directly to waiter without needing to unlock.
92  }
static Lot lot
void unpark(const Key key, Unparker &&func)
template<typename Wait >
void WaitableMutex::wait ( Wait  wfunc)
inline

Definition at line 95 of file ParkingLotTest.cpp.

References lot, folly::ParkingLot< Data >::park(), and uint64_t.

Referenced by TEST().

95  {
96  lot.park(
97  uint64_t(this),
98  wfunc,
99  [&]() { return !wfunc(); },
100  [&]() { std::mutex::unlock(); });
101  }
static Lot lot
ParkResult park(const Key key, D &&data, ToPark &&toPark, PreWait &&preWait)
Definition: ParkingLot.h:189

Member Data Documentation

WaitableMutex::Lot WaitableMutex::lot
staticprivate

Definition at line 75 of file ParkingLotTest.cpp.

Referenced by wait().


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