proxygen
folly::settings::detail::SettingWrapper< T, TrivialPtr > Class Template Reference

#include <Settings.h>

Public Member Functions

std::conditional_t< IsSmallPOD< T >::value, T, const T & > operator* () const
 
const Toperator-> () const
 
void set (const T &t, StringPiece reason="api")
 
const TdefaultValue () const
 
 SettingWrapper (SettingCore< T > &core)
 

Private Attributes

SettingCore< T > & core_
 

Friends

class folly::settings::Snapshot
 

Detailed Description

template<class T, std::atomic< uint64_t > * TrivialPtr>
class folly::settings::detail::SettingWrapper< T, TrivialPtr >

Parameters
TrivialPtrlocation of the small type storage. Optimization for better inlining.

Definition at line 36 of file Settings.h.

Constructor & Destructor Documentation

template<class T , std::atomic< uint64_t > * TrivialPtr>
folly::settings::detail::SettingWrapper< T, TrivialPtr >::SettingWrapper ( SettingCore< T > &  core)
inlineexplicit

Definition at line 76 of file Settings.h.

76 : core_(core) {}

Member Function Documentation

template<class T , std::atomic< uint64_t > * TrivialPtr>
const T& folly::settings::detail::SettingWrapper< T, TrivialPtr >::defaultValue ( ) const
inline

Returns the default value this setting was constructed with. NOTE: SettingsMetadata is type-agnostic, so it only stores the string representation of the default value. This method returns the actual value that was passed on construction.

Definition at line 72 of file Settings.h.

References folly::settings::detail::SettingWrapper< T, TrivialPtr >::core_.

72  {
73  return core_.defaultValue();
74  }
template<class T , std::atomic< uint64_t > * TrivialPtr>
std::conditional_t<IsSmallPOD<T>::value, T, const T&> folly::settings::detail::SettingWrapper< T, TrivialPtr >::operator* ( ) const
inline

Returns the setting's current value.

As an optimization, returns by value for small types, and by const& for larger types. Note that the returned reference is not guaranteed to be long-lived and should not be saved anywhere. In particular, a set() call might invalidate a reference obtained here after some amount of time (on the order of minutes).

Definition at line 47 of file Settings.h.

References folly::settings::detail::SettingWrapper< T, TrivialPtr >::core_.

Referenced by folly::settings::detail::SnapshotSettingWrapper< T >::operator->().

47  {
48  return core_.getWithHint(*TrivialPtr);
49  }
template<class T , std::atomic< uint64_t > * TrivialPtr>
const T* folly::settings::detail::SettingWrapper< T, TrivialPtr >::operator-> ( ) const
inline

Definition at line 50 of file Settings.h.

References folly::settings::detail::SettingWrapper< T, TrivialPtr >::core_.

50  {
51  return &core_.getSlow().value;
52  }
template<class T , std::atomic< uint64_t > * TrivialPtr>
void folly::settings::detail::SettingWrapper< T, TrivialPtr >::set ( const T t,
StringPiece  reason = "api" 
)
inline

Atomically updates the setting's current value. Will invalidate any previous calls to operator*() after some amount of time (on the order of minutes).

Parameters
reasonWill be stored with the current value, useful for debugging.
Exceptions
std::runtime_errorIf we can't convert t to string.

Definition at line 62 of file Settings.h.

References folly::settings::detail::SettingWrapper< T, TrivialPtr >::core_.

62  {
63  core_.set(t, reason);
64  }

Friends And Related Function Documentation

template<class T , std::atomic< uint64_t > * TrivialPtr>
friend class folly::settings::Snapshot
friend

Definition at line 80 of file Settings.h.

Member Data Documentation


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