proxygen
folly::detail::atomic_notification Namespace Reference

Functions

std::cv_status toCvStatus (FutexResult result)
 
std::cv_status toCvStatus (ParkResult result)
 
template<template< typename... > class Atom, typename... Args>
void atomic_wait_impl (const Atom< std::uint32_t, Args... > *atomic, std::uint32_t expected)
 
template<template< typename... > class Atom, typename Integer , typename... Args>
void atomic_wait_impl (const Atom< Integer, Args... > *atomic, Integer expected)
 
template<template< typename... > class Atom, typename... Args, typename Clock , typename Duration >
std::cv_status atomic_wait_until_impl (const Atom< std::uint32_t, Args... > *atomic, std::uint32_t expected, const std::chrono::time_point< Clock, Duration > &deadline)
 
template<template< typename... > class Atom, typename Integer , typename... Args, typename Clock , typename Duration >
std::cv_status atomic_wait_until_impl (const Atom< Integer, Args... > *atomic, Integer expected, const std::chrono::time_point< Clock, Duration > &deadline)
 
template<template< typename... > class Atom, typename... Args>
void atomic_notify_one_impl (const Atom< std::uint32_t, Args... > *atomic)
 
template<template< typename... > class Atom, typename Integer , typename... Args>
void atomic_notify_one_impl (const Atom< Integer, Args... > *atomic)
 
template<template< typename... > class Atom, typename Integer , typename... Args>
void atomic_notify_all_impl (const Atom< std::uint32_t, Args... > *atomic)
 
template<template< typename... > class Atom, typename Integer , typename... Args>
void atomic_notify_all_impl (const Atom< Integer, Args... > *atomic)
 

Variables

ParkingLot< std::uint32_tparkingLot
 

Function Documentation

template<template< typename... > class Atom, typename Integer , typename... Args>
void folly::detail::atomic_notification::atomic_notify_all_impl ( const Atom< std::uint32_t, Args... > *  atomic)

Definition at line 108 of file AtomicNotification-inl.h.

References testing::Args(), Atom, and folly::detail::futexWake().

Referenced by folly::atomic_notify_all().

108  {
109  futexWake(atomic);
110  return;
111 }
int futexWake(const Futex *futex, int count, uint32_t wakeMask)
Definition: Futex-inl.h:107
template<template< typename... > class Atom, typename Integer , typename... Args>
void folly::detail::atomic_notification::atomic_notify_all_impl ( const Atom< Integer, Args... > *  atomic)

Definition at line 114 of file AtomicNotification-inl.h.

References folly::data(), FOLLY_SAFE_DCHECK, max, folly::RemoveContinue, and folly::ParkingLot< Data >::unpark().

114  {
115  static_assert(!std::is_same<Integer, std::uint32_t>{}, "");
116  parkingLot.unpark(atomic, [&](const auto& data) {
118  return UnparkControl::RemoveContinue;
119  });
120 }
LogLevel max
Definition: LogLevel.cpp:31
ParkingLot< std::uint32_t > parkingLot
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
#define FOLLY_SAFE_DCHECK(expr, msg)
Definition: SafeAssert.h:42
template<template< typename... > class Atom, typename... Args>
void folly::detail::atomic_notification::atomic_notify_one_impl ( const Atom< std::uint32_t, Args... > *  atomic)

Definition at line 93 of file AtomicNotification-inl.h.

References testing::Args(), Atom, and folly::detail::futexWake().

Referenced by folly::atomic_notify_one().

93  {
94  futexWake(atomic, 1);
95  return;
96 }
int futexWake(const Futex *futex, int count, uint32_t wakeMask)
Definition: Futex-inl.h:107
template<template< typename... > class Atom, typename Integer , typename... Args>
void folly::detail::atomic_notification::atomic_notify_one_impl ( const Atom< Integer, Args... > *  atomic)

Definition at line 99 of file AtomicNotification-inl.h.

References testing::Args(), Atom, folly::data(), FOLLY_SAFE_DCHECK, max, folly::RemoveBreak, and folly::ParkingLot< Data >::unpark().

99  {
100  static_assert(!std::is_same<Integer, std::uint32_t>{}, "");
101  parkingLot.unpark(atomic, [&](const auto& data) {
103  return UnparkControl::RemoveBreak;
104  });
105 }
LogLevel max
Definition: LogLevel.cpp:31
ParkingLot< std::uint32_t > parkingLot
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
#define FOLLY_SAFE_DCHECK(expr, msg)
Definition: SafeAssert.h:42
template<template< typename... > class Atom, typename... Args>
void folly::detail::atomic_notification::atomic_wait_impl ( const Atom< std::uint32_t, Args... > *  atomic,
std::uint32_t  expected 
)

Definition at line 51 of file AtomicNotification-inl.h.

References testing::Args(), Atom, and folly::detail::futexWait().

Referenced by folly::atomic_wait().

53  {
54  futexWait(atomic, expected);
55  return;
56 }
FutexResult futexWait(const Futex< MockAtom > *futex, uint32_t expected, uint32_t waitMask)
template<template< typename... > class Atom, typename Integer , typename... Args>
void folly::detail::atomic_notification::atomic_wait_impl ( const Atom< Integer, Args... > *  atomic,
Integer  expected 
)

Definition at line 59 of file AtomicNotification-inl.h.

References testing::Args(), Atom, and folly::ParkingLot< Data >::park().

59  {
60  static_assert(!std::is_same<Integer, std::uint32_t>{}, "");
61  parkingLot.park(
62  atomic, -1, [&] { return atomic->load() == expected; }, [] {});
63 }
ParkingLot< std::uint32_t > parkingLot
template<template< typename... > class Atom, typename... Args, typename Clock , typename Duration >
std::cv_status folly::detail::atomic_notification::atomic_wait_until_impl ( const Atom< std::uint32_t, Args... > *  atomic,
std::uint32_t  expected,
const std::chrono::time_point< Clock, Duration > &  deadline 
)

Definition at line 70 of file AtomicNotification-inl.h.

References testing::Args(), Atom, folly::detail::futexWaitUntil(), and toCvStatus().

Referenced by folly::atomic_wait_until().

73  {
74  return toCvStatus(futexWaitUntil(atomic, expected, deadline));
75 }
FutexResult futexWaitUntil(const Futex< MockAtom > *futex, std::uint32_t expected, std::chrono::time_point< Clock, Duration > const &deadline, uint32_t waitMask)
std::cv_status toCvStatus(ParkResult result)
template<template< typename... > class Atom, typename Integer , typename... Args, typename Clock , typename Duration >
std::cv_status folly::detail::atomic_notification::atomic_wait_until_impl ( const Atom< Integer, Args... > *  atomic,
Integer  expected,
const std::chrono::time_point< Clock, Duration > &  deadline 
)

Definition at line 83 of file AtomicNotification-inl.h.

References testing::Args(), Atom, folly::ParkingLot< Data >::park_until(), and toCvStatus().

86  {
87  static_assert(!std::is_same<Integer, std::uint32_t>{}, "");
88  return toCvStatus(parkingLot.park_until(
89  atomic, -1, [&] { return atomic->load() == expected; }, [] {}, deadline));
90 }
std::cv_status toCvStatus(ParkResult result)
ParkingLot< std::uint32_t > parkingLot
std::cv_status folly::detail::atomic_notification::toCvStatus ( FutexResult  result)
inline

We use Futex<std::atomic> as the alias that has the lowest performance overhead with respect to atomic notifications. Assert that atomic_uint_fast_wait_t is the same as Futex<std::atomic> Implementation and specializations for the atomic_wait() family of functions

Definition at line 38 of file AtomicNotification-inl.h.

References folly::detail::TIMEDOUT.

Referenced by atomic_wait_until_impl().

38  {
39  return (result == FutexResult::TIMEDOUT) ? std::cv_status::timeout
40  : std::cv_status::no_timeout;
41 }
std::cv_status folly::detail::atomic_notification::toCvStatus ( ParkResult  result)
inline

Definition at line 42 of file AtomicNotification-inl.h.

References testing::Args(), Atom, parkingLot, and folly::Timeout.

42  {
43  return (result == ParkResult::Timeout) ? std::cv_status::timeout
44  : std::cv_status::no_timeout;
45 }

Variable Documentation

ParkingLot< std::uint32_t > folly::detail::atomic_notification::parkingLot

Definition at line 29 of file AtomicNotification.cpp.

Referenced by toCvStatus().