proxygen
folly::basic_once_flag< Mutex, Atom > Class Template Reference

#include <CallOnce.h>

Public Member Functions

constexpr basic_once_flag () noexcept=default
 
 basic_once_flag (const basic_once_flag &)=delete
 
basic_once_flagoperator= (const basic_once_flag &)=delete
 

Private Member Functions

template<typename F , typename... Args>
FOLLY_ALWAYS_INLINE void call_once (F &&f, Args &&...args)
 
template<typename F , typename... Args>
FOLLY_NOINLINE void call_once_slow (F &&f, Args &&...args)
 

Private Attributes

Atom< bool > called_ {false}
 
Mutex mutex_
 

Friends

template<typename Mutex_ , template< typename > class Atom_, typename F , typename... Args>
void call_once (basic_once_flag< Mutex_, Atom_ > &, F &&, Args &&...)
 

Detailed Description

template<typename Mutex, template< typename > class Atom>
class folly::basic_once_flag< Mutex, Atom >

Definition at line 31 of file CallOnce.h.

Constructor & Destructor Documentation

template<typename Mutex, template< typename > class Atom>
constexpr folly::basic_once_flag< Mutex, Atom >::basic_once_flag ( )
defaultnoexcept

Referenced by folly::call_once().

template<typename Mutex, template< typename > class Atom>
folly::basic_once_flag< Mutex, Atom >::basic_once_flag ( const basic_once_flag< Mutex, Atom > &  )
delete

Member Function Documentation

template<typename Mutex, template< typename > class Atom>
template<typename F , typename... Args>
FOLLY_ALWAYS_INLINE void folly::basic_once_flag< Mutex, Atom >::call_once ( F &&  f,
Args &&...  args 
)
inlineprivate

Definition at line 81 of file CallOnce.h.

81  {
82  if (LIKELY(called_.load(std::memory_order_acquire))) {
83  return;
84  }
85  call_once_slow(std::forward<F>(f), std::forward<Args>(args)...);
86  }
auto f
#define LIKELY(x)
Definition: Likely.h:47
Atom< bool > called_
Definition: CallOnce.h:98
FOLLY_NOINLINE void call_once_slow(F &&f, Args &&...args)
Definition: CallOnce.h:89
template<typename Mutex, template< typename > class Atom>
template<typename F , typename... Args>
FOLLY_NOINLINE void folly::basic_once_flag< Mutex, Atom >::call_once_slow ( F &&  f,
Args &&...  args 
)
inlineprivate

Definition at line 89 of file CallOnce.h.

Referenced by folly::basic_once_flag< SharedMutex >::call_once().

89  {
90  std::lock_guard<Mutex> lock(mutex_);
91  if (called_.load(std::memory_order_relaxed)) {
92  return;
93  }
94  invoke(std::forward<F>(f), std::forward<Args>(args)...);
95  called_.store(true, std::memory_order_release);
96  }
auto f
constexpr auto invoke(F &&f, Args &&...args) noexcept(noexcept(static_cast< F && >(f)(static_cast< Args && >(args)...))) -> decltype(static_cast< F && >(f)(static_cast< Args && >(args)...))
Definition: Invoke.h:49
auto lock(Synchronized< D, M > &synchronized, Args &&...args)
Atom< bool > called_
Definition: CallOnce.h:98
template<typename Mutex, template< typename > class Atom>
basic_once_flag& folly::basic_once_flag< Mutex, Atom >::operator= ( const basic_once_flag< Mutex, Atom > &  )
delete

Referenced by folly::call_once().

Friends And Related Function Documentation

template<typename Mutex, template< typename > class Atom>
template<typename Mutex_ , template< typename > class Atom_, typename F , typename... Args>
void call_once ( basic_once_flag< Mutex_, Atom_ > &  ,
F &&  ,
Args &&  ... 
)
friend

Referenced by folly::call_once().

Member Data Documentation

template<typename Mutex, template< typename > class Atom>
Atom<bool> folly::basic_once_flag< Mutex, Atom >::called_ {false}
private
template<typename Mutex, template< typename > class Atom>
Mutex folly::basic_once_flag< Mutex, Atom >::mutex_
private

Definition at line 99 of file CallOnce.h.

Referenced by folly::basic_once_flag< SharedMutex >::call_once_slow().


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