proxygen
folly::detail Namespace Reference

Namespaces

 apply_tuple
 
 atomic_notification
 
 concurrenthashmap
 
 distributed_mutex
 
 fixedstring
 
 function
 
 impl
 
 member
 
 partial
 
 propagate_const_adl
 

Classes

struct  AllocatorCustomizesConstruct_
 
struct  AllocatorCustomizesConstruct_< void_t< typename Alloc::folly_has_default_object_construct >, Alloc, Args... >
 
struct  AllocatorCustomizesDestroy_
 
struct  AllocatorCustomizesDestroy_< void_t< typename Alloc::folly_has_default_object_destroy >, Alloc, Args... >
 
struct  AmplificationProduct
 
struct  AmplificationProduct< std::tuple< T, Ts... > >
 
struct  AmplificationProduct< std::tuple<> >
 
struct  ArgumentTypesByKind
 
struct  ArgumentTypesByKind< IdentifyCallable::Kind::Function, Fn >
 
struct  ArgumentTypesByKind< IdentifyCallable::Kind::MemberFunction, Fn >
 
struct  async_timeout_wrapper
 
struct  AtFork
 
struct  AtomicStructRaw
 
struct  AtomicStructRaw< 0 >
 
struct  AtomicStructRaw< 1 >
 
struct  AtomicStructRaw< 2 >
 
struct  AtomicStructRaw< 3 >
 
struct  BenchmarkRegistration
 
struct  BenchmarkResult
 
struct  BitsTraits
 
struct  Bucket
 
class  BufferedDigest
 
class  BufferedSlidingWindow
 
class  BufferedStat
 
struct  Bytes
 
struct  CheckOverflowToDuration
 
struct  CheckOverflowToDuration< true >
 
struct  CheckTrailingSpace
 
struct  cmp_pred
 
struct  ComparableAsStringPiece
 
class  CompressionCounter
 Wrapper around the makeCompressionCounterHandler() extension point. More...
 
class  ConcurrentHashMapSegment
 
struct  constexpr_abs_helper
 
struct  constexpr_abs_helper< T, typename std::enable_if< std::is_floating_point< T >::value >::type >
 
struct  constexpr_abs_helper< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value &&std::is_signed< T >::value >::type >
 
struct  constexpr_abs_helper< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value &&std::is_unsigned< T >::value >::type >
 
class  csl_iterator
 
struct  DefaultMake
 
struct  DefaultTag
 
struct  DefaultType
 
struct  DefaultType< Default >
 
struct  DefaultType< Key, KeysDefault... >
 
struct  DefaultValueWrapper
 
struct  Destroy
 
class  DigestBuilder
 
struct  DoNotOptimizeAwayNeedsIndirect
 
struct  DynamicHasher
 
struct  DynamicKeyEqual
 
struct  Emplace
 
class  emplace_iterator_base
 
class  emplace_iterator_base< Derived, EmplaceImpl, false >
 
class  emplace_iterator_base< Derived, EmplaceImpl, true >
 
class  emplace_iterator_impl
 
struct  EmplaceBack
 
struct  EmplaceFront
 
struct  EmplaceHint
 
struct  Empty
 
struct  EmulatedFutexAtomic
 
struct  EndianInt
 
class  Enumerator
 
class  EventBaseLocalBase
 
class  EventBaseLocalBaseBase
 
class  FingerprintPolynomial
 
struct  FingerprintTable
 
struct  float_hasher
 
struct  format_table_align_make_item
 
struct  format_table_conv_make_item
 
struct  format_table_sign_make_item
 
class  FormatterTag
 
struct  FormatTraitsBase
 
struct  free_invoke_proxy
 
struct  GivesZeroFilledMemory
 
struct  GivesZeroFilledMemory< MMapAlloc >
 
class  GroupVarintBase
 
struct  GroupVarintTraits
 
struct  GroupVarintTraits< uint32_t >
 
struct  GroupVarintTraits< uint64_t >
 
struct  growth_policy_wrapper
 
struct  growth_policy_wrapper< void >
 
struct  HasArgumentTypes
 
class  HasLess
 
class  HistogramBuckets
 
class  IdentifyCallable
 
struct  IndexableTraits
 
struct  IndexableTraits< fbvector< T, A > >
 
struct  IndexableTraits< small_vector< T, M, A, B, C > >
 
struct  IndexableTraitsAssoc
 
struct  IndexableTraitsSeq
 
struct  IndexedMemPoolRecycler
 
struct  integral_hasher
 
struct  IntegralSizePolicy
 
struct  IntegralSizePolicy< SizeType, false >
 
struct  IntegralSizePolicy< SizeType, true >
 
struct  IntegralSizePolicyBase
 
struct  IntermediateTimeRep
 
struct  IntermediateTimeRep< T, false, false >
 
struct  IntermediateTimeRep< T, false, true >
 
struct  IntermediateTimeRep< T, true, IsSigned >
 
struct  is_chrono_conversion
 
struct  is_duration
 
struct  is_duration< std::chrono::duration< Rep, Period > >
 
struct  is_negative_impl
 
struct  is_negative_impl< T, false >
 
struct  is_posix_time_type
 
struct  is_propagate_const
 
struct  is_propagate_const< propagate_const< Pointer > >
 
struct  is_std_chrono_type
 
struct  is_time_point
 
struct  is_time_point< std::chrono::time_point< Clock, Duration > >
 
struct  IsAvalanchingHasherFromMemberType
 
struct  IsAvalanchingHasherFromMemberType< Hasher, void_t< typename Hasher::folly_is_avalanching > >
 
struct  IsCharPointer
 
struct  IsCharPointer< char * >
 
struct  IsCharPointer< const char * >
 
struct  IsConvertible
 
struct  IsConvertible< void, decltype(std::ignore)>
 
struct  IsFormatter
 
struct  IsFormatter< T, typename std::enable_if< std::is_same< typename T::IsFormatter, detail::FormatterTag >::value >::type >
 
struct  IsSizableString
 
struct  IsSizableStringContainerIterator
 
struct  IsUniquePtrToSL
 
struct  IsUniquePtrToSL< std::unique_ptr< T, D > >
 
class  IteratorAdaptor
 
class  IteratorFacade
 
struct  LastElement
 
struct  LastElementImpl
 
struct  LastElementImpl< Head, Ts... >
 
struct  Lazy
 
struct  LifoSemBase
 
class  LifoSemHead
 
struct  LifoSemNode
 
struct  LifoSemNodeRecycler
 
struct  LifoSemRawNode
 
struct  lift_void_to_char
 
struct  lift_void_to_char< void >
 
struct  like_
 
struct  like_< Src & >
 
struct  like_< Src && >
 
struct  like_< Src const >
 
struct  like_< Src const volatile >
 
struct  like_< Src volatile >
 
class  LockInterfaceDispatcher
 
struct  LockTraitsImpl
 
struct  LockTraitsImpl< Mutex, MutexLevel::SHARED, false >
 
struct  LockTraitsImpl< Mutex, MutexLevel::SHARED, true >
 
struct  LockTraitsImpl< Mutex, MutexLevel::UNIQUE, false >
 
struct  LockTraitsImpl< Mutex, MutexLevel::UNIQUE, true >
 
struct  LockTraitsImpl< Mutex, MutexLevel::UPGRADE, false >
 
struct  LockTraitsImpl< Mutex, MutexLevel::UPGRADE, true >
 
struct  MakeConst
 
struct  MakeConst< T & >
 
struct  MakeConst< T * >
 
struct  max_align_t_
 
struct  member_invoke_proxy
 
struct  MemoryIdler
 
struct  MetaBindBack
 
struct  MetaBindFront
 
struct  MetaCompose
 
class  MetaDefer
 
struct  MetaFlip
 
struct  MetaIdentity
 
struct  MetaQuote
 
class  MMapAlloc
 
class  MPMCPipelineStageImpl
 
class  MPMCQueueBase
 MPMCQueue base CRTP template. More...
 
class  MPMCQueueBase< Derived< T, Atom, Dynamic > >
 CRTP specialization of MPMCQueueBase. More...
 
struct  MutexLevelValueImpl
 
struct  MutexLevelValueImpl< true, false, false >
 
struct  MutexLevelValueImpl< true, true, false >
 
struct  MutexLevelValueImpl< true, true, true >
 
struct  NestedMapType
 
struct  NestedMapType< T, 1 >
 
class  NodeRecycler
 
class  NodeRecycler< NodeType, NodeAlloc, typename std::enable_if< !NodeType::template DestroyIsNoOp< NodeAlloc >::value >::type >
 
class  NodeRecycler< NodeType, NodeAlloc, typename std::enable_if< NodeType::template DestroyIsNoOp< NodeAlloc >::value >::type >
 
struct  notification_queue_consumer_wrapper
 
struct  OptionalPromiseReturn
 
struct  OutputType
 
struct  Overload
 
struct  Overload< Case >
 
struct  Overload< Case, Cases... >
 
struct  PipelineStageInfo
 
struct  PipelineStageInfo< MPMCPipelineStage< T, Amp > >
 
class  RangeEnumerator
 
class  ReadMostlySharedPtrCore
 
struct  ReturnUnit
 
class  RingBufferSlot
 
class  ScopeGuardImpl
 
class  ScopeGuardImplBase
 
struct  SeedData
 
class  shared_ptr_internals
 
struct  ShellCmdFormat
 
class  SignedValueHandler
 
class  SignedValueHandler< T, false >
 
class  SignedValueHandler< T, true >
 
struct  SingleElementQueue
 
struct  SingletonHolder
 
class  SingletonHolderBase
 
struct  SingletonVaultState
 
class  SkipListNode
 
class  SkipListRandomHeight
 
class  Sleeper
 
class  SlidingWindow
 
class  SlowFingerprint
 
struct  small_vector_base
 
struct  sorted_vector_enable_if_is_transparent
 
struct  sorted_vector_enable_if_is_transparent< void_t< typename Compare::is_transparent >, Compare, Key, T >
 
struct  StateSize
 
struct  StateSize< RNG, void_t< decltype(RNG::state_size)> >
 
struct  StateSize< std::linear_congruential_engine< UIntType, a, c, m > >
 
struct  StateSize< std::subtract_with_carry_engine< UIntType, w, s, r > >
 
class  StaticSingletonManager
 
struct  StaticSingletonManagerTest
 
struct  string_table_c_escape_make_item
 
struct  string_table_c_unescape_make_item
 
struct  string_table_hex_make_item
 
struct  string_table_uri_escape_make_item
 
class  StringPieceLite
 
class  SynchronizedLocker
 
struct  Tag
 
class  ThreadCachedInts
 
class  ThreadCachedLists
 
class  ThreadCachedListsBase
 
struct  TransparentRangeEqualTo
 
struct  TransparentRangeHash
 
struct  TupleSelect
 
struct  TupleSelect< TemplateSeq< std::size_t, Ns... > >
 
struct  TurnSequencer
 
struct  Type
 
struct  type
 
struct  type
 
struct  type
 
class  TypeDescriptor
 
class  TypeDescriptorHasher
 
struct  TypeList
 
struct  uint_types_by_size
 
struct  uint_types_by_size< 16/8 >
 
struct  uint_types_by_size< 32/8 >
 
struct  uint_types_by_size< 64/8 >
 
struct  uint_types_by_size< 8/8 >
 
struct  UnlockPolicyExclusive
 
struct  UnlockPolicyShared
 
struct  UnlockPolicyUpgrade
 
struct  ValueTypeForTransparentConversionToRange
 
struct  ValueTypeForTransparentConversionToRange< T, void_t< decltype(std::declval< hasher< Range< typename T::value_type const * >>>()(std::declval< Range< typename T::value_type const * >>()))>
 

Typedefs

using TimeIterPair = std::pair< std::chrono::high_resolution_clock::duration, unsigned int >
 
using BenchmarkFun = std::function< detail::TimeIterPair(unsigned int)>
 
template<typename Rep , typename Period >
using IntermediateDuration = std::chrono::duration< typename IntermediateTimeRep< Rep, std::is_floating_point< Rep >::value, std::is_signed< Rep >::value >::type, std::ratio< 1, Period::den >>
 
template<typename T >
using TransparentlyConvertibleToRange = std::is_convertible< T, Range< typename ValueTypeForTransparentConversionToRange< T >::type const * >>
 
template<typename Tgt , typename Src >
using IsArithToArith = bool_constant< !std::is_same< Tgt, Src >::value &&!std::is_same< Tgt, bool >::value &&std::is_arithmetic< Src >::value &&std::is_arithmetic< Tgt >::value >
 
template<typename Tgt >
using ParseToResult = decltype(parseTo(StringPiece{}, std::declval< Tgt & >()))
 
template<typename Tgt >
using ParseToError = ExpectedErrorType< decltype(detail::parseToWrap(StringPiece{}, std::declval< Tgt & >()))>
 
template<template< typename > class Atom = std::atomic>
using Futex = Atom< std::uint32_t >
 
template<bool B>
using Bool = bool_constant< B >
 
using True = std::true_type
 
using False = std::false_type
 
template<class Fn , class... Ts>
using MetaApply = typename Fn::template apply< Ts... >
 
template<bool If_, class Then , class Else >
using If = MetaApply< impl::If_< If_ >, Then, Else >
 
template<template< class... > class C>
using MetaQuoteTrait = MetaCompose< MetaQuote< _t >, MetaQuote< C >>
 
template<class Fn >
using MetaCurry = MetaCompose< Fn, MetaQuote< TypeList >>
 
template<class Fn >
using MetaUncurry = MetaBindBack< MetaQuote< MetaApply >, Fn >
 
template<class List , class... Ts>
using TypePushBack = MetaApply< List, MetaBindBack< MetaQuote< TypeList >, Ts... >>
 
template<class List , class... Ts>
using TypePushFront = MetaApply< List, MetaBindFront< MetaQuote< TypeList >, Ts... >>
 
template<class Fn , class List >
using MetaUnpack = MetaApply< List, Fn >
 
template<class List , class Fn >
using TypeTransform = MetaApply< List, impl::TypeTransform_< Fn >>
 
template<class List , class State , class Fn >
using TypeFold = MetaApply< MetaApply< List, impl::FoldR_< Fn >>, State >
 
template<class List , class State , class Fn >
using TypeReverseFold = MetaApply< MetaApply< List, impl::FoldL_< Fn >>, State >
 
template<class List >
using Inherit = impl::Inherit_< List >
 
template<class List >
using TypeUnique = TypeFold< List, TypeList<>, impl::Unique_ >
 
template<class List >
using TypeReverseUnique = TypeReverseFold< List, TypeList<>, MetaFlip< impl::Unique_ >>
 
template<class T >
using AsTypeList = _t< impl::AsTypeList_< T >>
 
template<class List >
using TypeJoin = MetaApply< TypeFold< List, MetaQuote< TypeList >, impl::Join_ >>
 
template<class... Ts>
using TypeConcat = TypeJoin< TypeList< Ts... >>
 
template<typename Fn >
using ArgumentTypes = typename ArgumentTypesByKind< IdentifyCallable::getKind< Fn >(), Fn >::type
 
template<typename... Args>
using EnableForArgTypes = typename std::enable_if< HasArgumentTypes< Args... >::value, void >::type
 
template<size_t Deg>
using poly_table = std::array< std::array< std::array< uint64_t, poly_size(Deg)>, 256 >, 8 >
 
using max_align_v_ = max_align_t_< long double, double, float, long long int, long int, int, short int, bool, char, char16_t, char32_t, wchar_t, void *, std::max_align_t >
 
template<typename T >
using is_decay_propagate_const = is_propagate_const< _t< std::decay< T >>>
 
template<typename N , typename D >
using IdivResultType = typename std::enable_if< std::is_integral< N >::value &&std::is_integral< D >::value &&!std::is_same< N, bool >::value &&!std::is_same< D, bool >::value, decltype(N{1}/D{1})>::type
 
template<typename RNG >
using StateSizeT = _t< StateSize< RNG >>
 
template<typename F , bool INE>
using ScopeGuardImplDecay = ScopeGuardImpl< typename std::decay< F >::type, INE >
 
template<class SynchronizedType >
using SynchronizedDataType = typename std::conditional< std::is_const< SynchronizedType >::value, typename SynchronizedType::DataType const, typename SynchronizedType::DataType >::type
 
template<class SynchronizedType >
using LockedPtrType = typename std::conditional< std::is_const< SynchronizedType >::value, typename SynchronizedType::ConstLockedPtr, typename SynchronizedType::LockedPtr >::type
 

Enumerations

enum  FutexResult { FutexResult::VALUE_CHANGED, FutexResult::AWOKEN, FutexResult::INTERRUPTED, FutexResult::TIMEDOUT }
 
enum  MutexLevel { MutexLevel::UNIQUE, MutexLevel::SHARED, MutexLevel::UPGRADE }
 
enum  ScopeGuardOnExit
 
enum  spin_result { spin_result::success, spin_result::timeout, spin_result::advance }
 

Functions

template<typename NotKeyT , typename KeyT >
void checkLegalKeyIfKeyTImpl (NotKeyT, KeyT, KeyT, KeyT)
 
template<typename KeyT >
void checkLegalKeyIfKeyTImpl (KeyT key_in, KeyT emptyKey, KeyT lockedKey, KeyT erasedKey)
 
void addBenchmarkImpl (const char *file, const char *name, std::function< TimeIterPair(unsigned int)>)
 
template<typename Src >
Expected< time_t, ConversionCodechronoRangeCheck (Src value)
 
template<typename SubsecondRatio , typename Rep >
static Expected< std::pair< time_t, long >, ConversionCodedurationToPosixTime (const std::chrono::duration< Rep, std::ratio< 1, 1 >> &duration)
 
template<typename SubsecondRatio , typename Rep , std::intmax_t Denominator>
static Expected< std::pair< time_t, long >, ConversionCodedurationToPosixTime (const std::chrono::duration< Rep, std::ratio< 1, Denominator >> &duration)
 
template<typename SubsecondRatio , typename Rep , std::intmax_t Numerator>
static Expected< std::pair< time_t, long >, ConversionCodedurationToPosixTime (const std::chrono::duration< Rep, std::ratio< Numerator, 1 >> &duration)
 
template<typename SubsecondRatio , typename Rep , typename Period >
Expected< std::pair< time_t, long >, ConversionCodedurationToPosixTime (const std::chrono::duration< Rep, Period > &duration)
 
template<typename SubsecondRatio , typename Seconds , typename Subseconds , typename Rep >
auto posixTimeToDuration (Seconds seconds, Subseconds subseconds, std::chrono::duration< Rep, std::ratio< 1, 1 >> dummy) -> Expected< decltype(dummy), ConversionCode >
 
template<typename SubsecondRatio , typename Seconds , typename Subseconds , typename Rep , std::intmax_t Denominator>
auto posixTimeToDuration (Seconds seconds, Subseconds subseconds, std::chrono::duration< Rep, std::ratio< 1, Denominator >> dummy) -> Expected< decltype(dummy), ConversionCode >
 
template<typename SubsecondRatio , typename Seconds , typename Subseconds , typename Rep , std::intmax_t Numerator>
auto posixTimeToDuration (Seconds seconds, Subseconds subseconds, std::chrono::duration< Rep, std::ratio< Numerator, 1 >> dummy) -> Expected< decltype(dummy), ConversionCode >
 
template<typename SubsecondRatio , typename Seconds , typename Subseconds , typename Rep , std::intmax_t Denominator, std::intmax_t Numerator>
auto posixTimeToDuration (Seconds seconds, Subseconds subseconds, std::chrono::duration< Rep, std::ratio< Numerator, Denominator >> dummy) -> Expected< decltype(dummy), ConversionCode >
 
template<typename Tgt , typename SubsecondRatio , typename Seconds , typename Subseconds >
Expected< Tgt, ConversionCodetryPosixTimeToDuration (Seconds seconds, Subseconds subseconds)
 
template<typename T >
constexpr T constexpr_log2_ (T a, T e)
 
template<typename T >
constexpr T constexpr_log2_ceil_ (T l2, T t)
 
template<typename T >
constexpr T constexpr_square_ (T t)
 
template<typename U >
constexpr std::size_t constexpr_find_first_set_ (std::size_t s, std::size_t a, U const u)
 
template<typename D , typename S >
constexpr D constexpr_clamp_cast_helper (S src, S sl, S su, D dl, D du)
 
template<class Iterator >
FOLLY_ALWAYS_INLINE auto getPointer (const Iterator &it, long) -> decltype(std::addressof(*it))
 
template<class Iterator >
FOLLY_ALWAYS_INLINE auto getPointer (const Iterator &it, int) -> decltype(it.operator->())
 
template<class T , class U >
std::enable_if< (std::is_arithmetic< T >::value &&std::is_arithmetic< U >::value)||(std::is_pointer< T >::value &&std::is_pointer< U >::value), bool >::type notThereYet (T &iter, const U &end)
 
template<class T , class U >
std::enable_if< !((std::is_arithmetic< T >::value &&std::is_arithmetic< U >::value)||(std::is_pointer< T >::value &&std::is_pointer< U >::value)), bool >::type notThereYet (T &iter, const U &end)
 
template<class T , class U >
std::enable_if< HasLess< U, T >::value, bool >::type downTo (T &iter, const U &begin)
 
template<class T , class U >
std::enable_if<!HasLess< U, T >::value, bool >::type downTo (T &iter, const U &begin)
 
template<typename Arg >
decltype(auto) unwrap_emplace_arg (Arg &&arg) noexcept
 
template<typename Arg >
decltype(auto) unwrap_emplace_arg (std::reference_wrapper< Arg > arg) noexcept
 
template<typename Arg >
decltype(auto) unwrap_emplace_arg (folly::rvalue_reference_wrapper< Arg > arg) noexcept
 
Expected< bool, ConversionCodestr_to_bool (StringPiece *src) noexcept
 
template<class Tgt >
Expected< Tgt, ConversionCodestr_to_floating (StringPiece *src) noexcept
 
template Expected< float, ConversionCodestr_to_floating< float > (StringPiece *src) noexcept
 
template Expected< double, ConversionCodestr_to_floating< double > (StringPiece *src) noexcept
 
template<class Tgt >
Expected< Tgt, ConversionCodedigits_to (const char *b, const char *const e) noexcept
 
template Expected< char, ConversionCodedigits_to< char > (const char *, const char *) noexcept
 
template Expected< signed char, ConversionCodedigits_to< signed char > (const char *, const char *) noexcept
 
template Expected< unsigned char, ConversionCodedigits_to< unsigned char > (const char *, const char *) noexcept
 
template Expected< short, ConversionCodedigits_to< short > (const char *, const char *) noexcept
 
template Expected< unsigned short, ConversionCodedigits_to< unsigned short > (const char *, const char *) noexcept
 
template Expected< int, ConversionCodedigits_to< int > (const char *, const char *) noexcept
 
template Expected< unsigned int, ConversionCodedigits_to< unsigned int > (const char *, const char *) noexcept
 
template Expected< long, ConversionCodedigits_to< long > (const char *, const char *) noexcept
 
template Expected< unsigned long, ConversionCodedigits_to< unsigned long > (const char *, const char *) noexcept
 
template Expected< long long, ConversionCodedigits_to< long long > (const char *, const char *) noexcept
 
template Expected< unsigned long long, ConversionCodedigits_to< unsigned long long > (const char *, const char *) noexcept
 
template<class Tgt >
Expected< Tgt, ConversionCodestr_to_integral (StringPiece *src) noexcept
 
template Expected< char, ConversionCodestr_to_integral< char > (StringPiece *src) noexcept
 
template Expected< signed char, ConversionCodestr_to_integral< signed char > (StringPiece *src) noexcept
 
template Expected< unsigned char, ConversionCodestr_to_integral< unsigned char > (StringPiece *src) noexcept
 
template Expected< short, ConversionCodestr_to_integral< short > (StringPiece *src) noexcept
 
template Expected< unsigned short, ConversionCodestr_to_integral< unsigned short > (StringPiece *src) noexcept
 
template Expected< int, ConversionCodestr_to_integral< int > (StringPiece *src) noexcept
 
template Expected< unsigned int, ConversionCodestr_to_integral< unsigned int > (StringPiece *src) noexcept
 
template Expected< long, ConversionCodestr_to_integral< long > (StringPiece *src) noexcept
 
template Expected< unsigned long, ConversionCodestr_to_integral< unsigned long > (StringPiece *src) noexcept
 
template Expected< long long, ConversionCodestr_to_integral< long long > (StringPiece *src) noexcept
 
template Expected< unsigned long long, ConversionCodestr_to_integral< unsigned long long > (StringPiece *src) noexcept
 
ConversionCode enforceWhitespaceErr (StringPiece sp)
 
void enforceWhitespace (StringPiece sp)
 
template<typename... Ts>
auto getLastElement (const Ts &...ts) -> decltype(LastElementImpl< Ts... >::call(ts...))
 
template<class Tgt >
std::enable_if< !std::is_same< Tgt, bool >::value &&(std::is_integral< Tgt >::value||std::is_floating_point< Tgt >::value), Expected< Tgt, ConversionCode > >::type convertTo (const bool &value) noexcept
 
template<class Tgt , class Src >
std::enable_if< std::is_integral< Src >::value &&!std::is_same< Tgt, Src >::value &&!std::is_same< Tgt, bool >::value &&std::is_integral< Tgt >::value, Expected< Tgt, ConversionCode > >::type convertTo (const Src &value) noexcept
 
template<class Tgt , class Src >
std::enable_if< std::is_floating_point< Tgt >::value &&std::is_floating_point< Src >::value &&!std::is_same< Tgt, Src >::value, Expected< Tgt, ConversionCode > >::type convertTo (const Src &value) noexcept
 
template<typename Tgt , typename Src >
std::enable_if< std::is_floating_point< Src >::value &&std::is_integral< Tgt >::value &&!std::is_same< Tgt, bool >::value, bool >::type checkConversion (const Src &value)
 
template<typename Tgt , typename Src >
constexpr std::enable_if< std::is_integral< Src >::value &&std::is_floating_point< Tgt >::value, bool >::type checkConversion (const Src &)
 
template<typename Tgt , typename Src >
constexpr std::enable_if< std::is_floating_point< Src >::value &&std::is_same< Tgt, bool >::value, bool >::type checkConversion (const Src &)
 
template<typename Tgt , typename Src >
std::enable_if< (std::is_integral< Src >::value &&std::is_floating_point< Tgt >::value)||(std::is_floating_point< Src >::value &&std::is_integral< Tgt >::value), Expected< Tgt, ConversionCode > >::type convertTo (const Src &value) noexcept
 
template<typename Tgt , typename Src >
std::string errorValue (const Src &value)
 
template<class Tgt >
std::enable_if< std::is_void< ParseToResult< Tgt > >::value, Expected< StringPiece, ConversionCode > >::type parseToWrap (StringPiece sp, Tgt &out)
 
template<class Tgt >
std::enable_if< !std::is_void< ParseToResult< Tgt > >::value, ParseToResult< Tgt > >::type parseToWrap (StringPiece sp, Tgt &out)
 
template<typename Cond >
void atomic_hash_spin_wait (Cond condition)
 
int cplus_demangle_v3_callback_wrapper (char const *const mangled, void(*const cbref)(char const *, std::size_t, void *), void *const opaque)
 
template<typename TargetClock , typename Clock , typename Duration >
TargetClock::time_point time_point_conv (std::chrono::time_point< Clock, Duration > const &time)
 
int futexWakeImpl (const Futex< std::atomic > *futex, int count, uint32_t wakeMask)
 
FutexResult futexWaitImpl (const Futex< std::atomic > *futex, uint32_t expected, std::chrono::system_clock::time_point const *absSystemTime, std::chrono::steady_clock::time_point const *absSteadyTime, uint32_t waitMask)
 
int futexWakeImpl (const Futex< EmulatedFutexAtomic > *futex, int count, uint32_t wakeMask)
 
FutexResult futexWaitImpl (const Futex< EmulatedFutexAtomic > *futex, uint32_t expected, std::chrono::system_clock::time_point const *absSystemTime, std::chrono::steady_clock::time_point const *absSteadyTime, uint32_t waitMask)
 
template<typename Futex , typename Deadline >
std::enable_if< Deadline::clock::is_steady, FutexResult >::type futexWaitImpl (Futex *futex, uint32_t expected, Deadline const &deadline, uint32_t waitMask)
 
template<typename Futex , typename Deadline >
std::enable_if<!Deadline::clock::is_steady, FutexResult >::type futexWaitImpl (Futex *futex, uint32_t expected, Deadline const &deadline, uint32_t waitMask)
 
template<typename Futex >
FutexResult futexWait (const Futex *futex, uint32_t expected, uint32_t waitMask)
 
template<typename Futex >
int futexWake (const Futex *futex, int count, uint32_t wakeMask)
 
template<typename Futex , class Clock , class Duration >
FutexResult futexWaitUntil (const Futex *futex, uint32_t expected, std::chrono::time_point< Clock, Duration > const &deadline, uint32_t waitMask)
 
FutexResult futexWaitImpl (const Futex< std::atomic > *futex, uint32_t expected, system_clock::time_point const *absSystemTime, steady_clock::time_point const *absSteadyTime, uint32_t waitMask)
 
FutexResult futexWaitImpl (const Futex< EmulatedFutexAtomic > *futex, uint32_t expected, system_clock::time_point const *absSystemTime, steady_clock::time_point const *absSteadyTime, uint32_t waitMask)
 
std::string familyNameStrDefault (sa_family_t family)
 
void getNthMSBitImplThrow (size_t bitCount, sa_family_t family)
 
std::string familyNameStr (sa_family_t family)
 
template<typename IPAddrType >
bool getNthMSBitImpl (const IPAddrType &ip, size_t bitIndex, sa_family_t family)
 
template<class IntegralType , IntegralType DigitCount, IntegralType Base = IntegralType(10), bool PrintAllDigits = false, class = typename std::enable_if< std::is_integral<IntegralType>::value && std::is_unsigned<IntegralType>::value, bool>::type>
void writeIntegerString (IntegralType val, char **buffer)
 
size_t fastIpV4ToBufferUnsafe (const in_addr &inAddr, char *str)
 
std::string fastIpv4ToString (const in_addr &inAddr)
 
void fastIpv4AppendToString (const in_addr &inAddr, std::string &out)
 
size_t fastIpv6ToBufferUnsafe (const in6_addr &in6Addr, char *str)
 
std::string fastIpv6ToString (const in6_addr &in6Addr)
 
void fastIpv6AppendToString (const in6_addr &in6Addr, std::string &out)
 
size_t qfind_first_byte_of_bitset (const StringPieceLite haystack, const StringPieceLite needles)
 
size_t qfind_first_byte_of_byteset (const StringPieceLite haystack, const StringPieceLite needles)
 
size_t qfind_first_byte_of_std (const StringPieceLite haystack, const StringPieceLite needles)
 
size_t qfind_first_byte_of_nosse (const StringPieceLite haystack, const StringPieceLite needles)
 
size_t qfind_first_byte_of_sse42 (const StringPieceLite haystack, const StringPieceLite needles)
 
ssize_t tfo_sendmsg (int, const struct msghdr *, int)
 
int tfo_enable (int, size_t)
 
bool tfo_succeeded (int)
 
template<typename T , typename Tag , typename F >
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN TcreateGlobal (F &&creator)
 
template<typename T , typename Tag >
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN TcreateGlobal ()
 
 TEST_F (StaticSingletonManagerTest, example)
 
template<template< class > class Op>
dynamic numericOp (dynamic const &a, dynamic const &b)
 
template<typename F >
exception_wrapper try_and_catch_ (F &&f)
 
template<typename F , typename Ex , typename... Exs>
exception_wrapper try_and_catch_ (F &&f)
 
template<typename Fn >
EnableForArgTypes< Fn > invokeForKeyValue (Fn f, const folly::dynamic &, const folly::dynamic &)
 
template<typename Fn >
EnableForArgTypes< Fn, folly::dynamicinvokeForKeyValue (Fn fn, const folly::dynamic &, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, int64_tinvokeForKeyValue (Fn fn, const folly::dynamic &, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, bool > invokeForKeyValue (Fn fn, const folly::dynamic &, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, double > invokeForKeyValue (Fn fn, const folly::dynamic &, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, std::stringinvokeForKeyValue (Fn fn, const folly::dynamic &, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, folly::dynamic, folly::dynamicinvokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, folly::dynamic, int64_tinvokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, folly::dynamic, bool > invokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, folly::dynamic, double > invokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, folly::dynamic, std::stringinvokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, std::string, folly::dynamicinvokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, std::string, int64_tinvokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, std::string, bool > invokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, std::string, double > invokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, std::string, std::stringinvokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, int64_t, folly::dynamicinvokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, int64_t, int64_tinvokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, int64_t, bool > invokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, int64_t, double > invokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
template<typename Fn >
EnableForArgTypes< Fn, int64_t, std::stringinvokeForKeyValue (Fn fn, const folly::dynamic &k, const folly::dynamic &v)
 
std::string toPseudoJson (const folly::dynamic &d)
 
constexpr size_t poly_size (size_t bits)
 
void insertThousandsGroupingUnsafe (char *start_buffer, char **end_buffer)
 
template<class Uint >
size_t uintToHex (char *buffer, size_t bufLen, Uint v, std::array< std::array< char, 2 >, 256 > const &repr)
 
template<class Uint >
size_t uintToHexLower (char *buffer, size_t bufLen, Uint v)
 
template<class Uint >
size_t uintToHexUpper (char *buffer, size_t bufLen, Uint v)
 
template<class Uint >
size_t uintToOctal (char *buffer, size_t bufLen, Uint v)
 
template<class Uint >
size_t uintToBinary (char *buffer, size_t bufLen, Uint v)
 
std::shared_ptr< TimekeepergetTimekeeperSingleton ()
 
uint32_t crc32c_sw (const uint8_t *data, size_t nbytes, uint32_t startingChecksum)
 
uint32_t crc32_hw (const uint8_t *, size_t, uint32_t)
 
bool crc32c_hw_supported ()
 
bool crc32_hw_supported ()
 
template<uint32_t CRC_POLYNOMIAL>
uint32_t crc_sw (const uint8_t *data, size_t nbytes, uint32_t startingChecksum)
 
uint32_t crc32_sw (const uint8_t *data, size_t nbytes, uint32_t startingChecksum)
 
uint32_t crc32c_hw (const uint8_t *data, size_t nbytes, uint32_t startingChecksum=~0U)
 
uint32_t crc32_combine_sw (uint32_t crc1, uint32_t crc2, size_t crc2len)
 
uint32_t crc32_combine_hw (uint32_t crc1, uint32_t crc2, size_t crc2len)
 
uint32_t crc32c_combine_sw (uint32_t crc1, uint32_t crc2, size_t crc2len)
 
uint32_t crc32c_combine_hw (uint32_t crc1, uint32_t crc2, size_t crc2len)
 
constexpr size_t max_align_ (std::size_t a)
 
template<typename... Es>
constexpr std::size_t max_align_ (std::size_t a, std::size_t e, Es...es)
 
void assume_check (bool cond)
 
template<typename Dst , typename Src >
constexpr std::make_signed_t< Dst > bits_to_signed (Src const s)
 
template<typename Dst , typename Src >
constexpr std::make_unsigned_t< Dst > bits_to_unsigned (Src const s)
 
static uint8_t byteswap_gen (uint8_t v)
 
static uint64_t byteswap_gen (uint64_t v)
 
static uint32_t byteswap_gen (uint32_t v)
 
static uint16_t byteswap_gen (uint16_t v)
 
template<typename T >
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T && to_exception_arg_ (T &&t)
 
template<std::size_t N>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN char const * to_exception_arg_ (char const (&array)[N])
 
template<typename Ex , typename... Args>
FOLLY_NOINLINE FOLLY_COLD void throw_exception_ (Args &&...args)
 
template<typename Ex , typename... Args>
FOLLY_NOINLINE FOLLY_COLD void terminate_with_ (Args &&...args) noexcept
 
void assertionFailure (const char *expr, const char *msg, const char *file, unsigned int line, const char *function)
 
template<typename Arg >
auto fallbackFormatOneArg (std::string *str, const Arg *arg, int) -> decltype(toAppend(std::declval< Arg >(), std::declval< std::string * >()), std::declval< void >())
 
template<typename Arg >
void fallbackFormatOneArg (std::string *str, const Arg *arg, long)
 
constexpr const char * xlogStripFilenameRecursive (const char *filename, const char *prefixes, size_t prefixIdx, size_t filenameIdx, bool match)
 
constexpr const char * xlogStripFilenameMatchFound (const char *filename, const char *prefixes, size_t prefixIdx, size_t filenameIdx)
 
template<class... KeysDefault>
auto extract_default (const KeysDefault &...keysDefault) -> typename DefaultType< KeysDefault... >::type const &
 
template<typename T >
constexpr T divFloorBranchless (T num, T denom)
 
template<typename T >
constexpr T divFloorBranchful (T num, T denom)
 
template<typename T >
constexpr T divCeilBranchless (T num, T denom)
 
template<typename T >
constexpr T divCeilBranchful (T num, T denom)
 
template<typename T >
constexpr T divRoundAwayBranchless (T num, T denom)
 
template<typename T >
constexpr T divRoundAwayBranchful (T num, T denom)
 
void handleMallctlError (const char *cmd, int err)
 
template<typename T >
void mallctlHelper (const char *cmd, T *out, T *in)
 
void unsafeStringSetLargerSize (std::string &s, std::size_t n)
 
template<typename T >
void unsafeVectorSetLargerSize (std::vector< T > &v, std::size_t n)
 
template<typename Alloc , size_t kAlign, bool kAllocate>
void rawOverAlignedImpl (Alloc const &alloc, size_t n, void *&raw)
 
 FOLLY_CREATE_MEMBER_INVOKE_TRAITS (AllocatorConstruct_, construct)
 
 FOLLY_CREATE_MEMBER_INVOKE_TRAITS (AllocatorDestroy_, destroy)
 
template<typename Char >
constexpr size_t constexpr_strlen_internal (const Char *s, size_t len)
 
template<typename Char >
constexpr int constexpr_strcmp_internal (const Char *s1, const Char *s2)
 
bool sysMembarrierAvailable ()
 
int sysMembarrier ()
 
template<class Iter >
std::enable_if< std::is_same< typename std::iterator_traits< Iter >::iterator_category, std::random_access_iterator_tag >::value, typename std::iterator_traits< Iter >::reference >::type value_before (Iter i)
 
template<class Iter >
std::enable_if< !std::is_same< typename std::iterator_traits< Iter >::iterator_category, std::random_access_iterator_tag >::value, typename std::iterator_traits< Iter >::reference >::type value_before (Iter i)
 
size_t qfind_first_byte_of (const StringPiece haystack, const StringPiece needles)
 
template<typename FunctionType >
ScopeGuardImpl< typename std::decay< FunctionType >::type, true > operator+ (detail::ScopeGuardOnExit, FunctionType &&fn)
 
std::unique_lock< std::mutexsharedMutexAnnotationGuard (void *ptr)
 
void singletonWarnDoubleRegistrationAndAbort (const TypeDescriptor &type)
 
static void singleton_hs_init_weak (int *argc, char **argv[]) __attribute__((__weakref__("hs_init")))
 
void singletonWarnLeakyDoubleRegistrationAndAbort (const TypeDescriptor &type)
 
void singletonWarnLeakyInstantiatingNotRegisteredAndAbort (const TypeDescriptor &type)
 
void singletonWarnRegisterMockEarlyAndAbort (const TypeDescriptor &type)
 
void singletonWarnDestroyInstanceLeak (const TypeDescriptor &type, const void *ptr)
 
void singletonWarnCreateCircularDependencyAndAbort (const TypeDescriptor &type)
 
void singletonWarnCreateUnregisteredAndAbort (const TypeDescriptor &type)
 
void singletonWarnCreateBeforeRegistrationCompleteAndAbort (const TypeDescriptor &type)
 
void singletonPrintDestructionStackTrace (const TypeDescriptor &type)
 
void singletonThrowNullCreator (const std::type_info &type)
 
void singletonThrowGetInvokedAfterDestruction (const TypeDescriptor &type)
 
template<class T >
std::enable_if< std::is_default_constructible< T >::value &&!folly::is_trivially_copyable< T >::value >::type moveObjectsRight (T *first, T *lastConstructed, T *realLast)
 
template<class T >
std::enable_if< !std::is_default_constructible< T >::value||folly::is_trivially_copyable< T >::value >::type moveObjectsRight (T *first, T *lastConstructed, T *realLast)
 
template<class T , class Function >
void populateMemForward (T *mem, std::size_t n, Function const &op)
 
template<class T >
TpointerFlagSet (T *p)
 
template<class T >
bool pointerFlagGet (T *p)
 
template<class T >
TpointerFlagClear (T *p)
 
void * shiftPointer (void *p, size_t sizeBytes)
 
template<class Iterator >
int distance_if_multipass (Iterator first, Iterator last)
 
template<class OurContainer , class Vector , class GrowthPolicy >
OurContainer::iterator insert_with_hint (OurContainer &sorted, Vector &cont, typename OurContainer::iterator hint, typename OurContainer::value_type &&value, GrowthPolicy &po)
 
template<class OurContainer , class Vector , class InputIterator >
void bulk_insert (OurContainer &sorted, Vector &cont, InputIterator first, InputIterator last)
 
template<typename Container , typename Compare >
Container && as_sorted (Container &&container, Compare const &comp)
 
template<typename ReturnType >
ReturnType avgHelper (long double sum, uint64_t count)
 
template<typename ReturnType , typename ValueType >
std::enable_if< !std::is_same< typename std::remove_cv< ValueType >::type, long double >::value, ReturnType >::type avgHelper (ValueType sum, uint64_t count)
 
template<typename ReturnType = double, typename Duration = std::chrono::seconds, typename Interval = Duration>
ReturnType rateHelper (ReturnType count, Duration elapsed)
 
static uint8_t getRadixBucket (double *f, uint8_t shift)
 
static void double_radix_sort_rec (uint64_t n, uint64_t *buckets, uint8_t shift, bool inout, double *in, double *out)
 
void double_radix_sort (uint64_t n, uint64_t *buckets, double *in, double *tmp)
 
QuantileEstimates estimatesFromDigest (const TDigest &digest, Range< const double * > quantiles)
 
size_t delimSize (char)
 
size_t delimSize (StringPiece s)
 
bool atDelim (const char *s, char c)
 
bool atDelim (const char *s, StringPiece sp)
 
char delimFront (char c)
 
char delimFront (StringPiece s)
 
template<class OutStringT , class DelimT , class OutputIterator >
void internalSplit (DelimT delim, StringPiece sp, OutputIterator out, bool ignoreEmpty)
 
template<class String >
StringPiece prepareDelim (const String &s)
 
char prepareDelim (char c)
 
template<class OutputType >
void toOrIgnore (StringPiece input, OutputType &output)
 
void toOrIgnore (StringPiece, decltype(std::ignore)&)
 
template<bool exact, class Delim , class OutputType >
bool splitFixed (const Delim &delimiter, StringPiece input, OutputType &output)
 
template<bool exact, class Delim , class OutputType , class... OutputTypes>
bool splitFixed (const Delim &delimiter, StringPiece input, OutputType &outHead, OutputTypes &...outTail)
 
template<class Delim , class Iterator , class String >
void internalJoinAppend (Delim delimiter, Iterator begin, Iterator end, String &output)
 
template<class Delim , class Iterator , class String >
std::enable_if< IsSizableStringContainerIterator< Iterator >::value >::type internalJoin (Delim delimiter, Iterator begin, Iterator end, String &output)
 
template<class Delim , class Iterator , class String >
std::enable_if< !IsSizableStringContainerIterator< Iterator >::value >::type internalJoin (Delim delimiter, Iterator begin, Iterator end, String &output)
 
size_t hexDumpLine (const void *ptr, size_t offset, size_t size, std::string &line)
 
template<typename Atomic >
bool atomic_fetch_set_default (Atomic &atomic, std::size_t bit, std::memory_order order)
 
template<typename Atomic >
bool atomic_fetch_reset_default (Atomic &atomic, std::size_t bit, std::memory_order order)
 
template<typename Atomic >
bool atomic_fetch_set_x86 (Atomic &, std::size_t, std::memory_order) noexcept
 
template<typename Atomic >
bool atomic_fetch_reset_x86 (Atomic &, std::size_t, std::memory_order) noexcept
 
std::memory_order default_failure_memory_order (std::memory_order successMode)
 
template<typename Clock , typename Duration , typename F >
spin_result spin_pause_until (std::chrono::time_point< Clock, Duration > const &deadline, WaitOptions const &opt, F f)
 
template<typename Clock , typename Duration , typename F >
spin_result spin_yield_until (std::chrono::time_point< Clock, Duration > const &deadline, F f)
 
constexpr int hazptr_domain_rcount_threshold ()
 
void annotate_rwlock_create_impl (void const volatile *const addr, char const *const f, int const l)
 
void annotate_rwlock_create_static_impl (void const volatile *const addr, char const *const f, int const l)
 
void annotate_rwlock_destroy_impl (void const volatile *const addr, char const *const f, int const l)
 
void annotate_rwlock_acquired_impl (void const volatile *const addr, annotate_rwlock_level const w, char const *const f, int const l)
 
void annotate_rwlock_try_acquired_impl (void const volatile *const addr, annotate_rwlock_level const w, bool const result, char const *const f, int const l)
 
void annotate_rwlock_released_impl (void const volatile *const addr, annotate_rwlock_level const w, char const *const f, int const l)
 
void annotate_benign_race_sized_impl (const volatile void *addr, long size, const char *desc, const char *f, int l)
 
template<typename Synchronized , typename LockFunc , typename TryLockFunc , typename... Args>
auto makeSynchronizedLocker (Synchronized &synchronized, LockFunc &&lockFunc, TryLockFunc &&tryLockFunc, Args &&...args)
 
template<typename... SynchronizedLocker>
auto lock (SynchronizedLocker...lockersIn) -> std::tuple< typename SynchronizedLocker::LockedPtr... >
 
template<typename Synchronized , typename... Args>
auto wlock (Synchronized &synchronized, Args &&...args)
 
template<typename Synchronized , typename... Args>
auto rlock (Synchronized &synchronized, Args &&...args)
 
template<typename Synchronized , typename... Args>
auto ulock (Synchronized &synchronized, Args &&...args)
 
template<typename Synchronized , typename... Args>
auto lock (Synchronized &synchronized, Args &&...args)
 
template<typename... Arguments>
std::vector< std::stringshellify (StringPiece format, Arguments &&...arguments)
 
FOLLY_PUSH_WARNING FOLLY_MSVC_DISABLE_WARNING (4388) FOLLY_MSVC_DISABLE_WARNING(4804) template< typename RHS
 
FOLLY_PUSH_WARNING RHS LHS bool less_than_impl (LHS const lhs)
 
template<typename RHS , RHS rhs, typename LHS >
bool greater_than_impl (LHS const lhs)
 

Variables

constexpr double kClampCastLowerBoundDoubleToInt64F = -9223372036854774784.0
 
constexpr double kClampCastUpperBoundDoubleToInt64F = 9223372036854774784.0
 
constexpr double kClampCastUpperBoundDoubleToUInt64F = 18446744073709549568.0
 
constexpr float kClampCastLowerBoundFloatToInt32F = -2147483520.0f
 
constexpr float kClampCastUpperBoundFloatToInt32F = 2147483520.0f
 
constexpr float kClampCastUpperBoundFloatToUInt32F = 4294967040.0f
 
struct folly::detail::LastElementImpl sizeof
 
FOLLY_STORAGE_CONSTEXPR std::array< std::array< std::uint8_t, 256 >, 8 > const kSelectInByte
 
const std::array< std::array< char, 2 >, 256 > formatHexUpper
 
const std::array< std::array< char, 2 >, 256 > formatHexLower
 
const std::array< std::array< char, 3 >, 512 > formatOctal
 
const std::array< std::array< char, 8 >, 256 > formatBinary
 
const size_t kMaxHexLength = 2 * sizeof(uintmax_t)
 
const size_t kMaxOctalLength = 3 * sizeof(uintmax_t)
 
const size_t kMaxBinaryLength = 8 * sizeof(uintmax_t)
 
FOLLY_STORAGE_CONSTEXPR auto formatAlignTable
 
FOLLY_STORAGE_CONSTEXPR auto formatSignTable
 
static FOLLY_TLS uint32_t tls_lastCpuBufferSlot = 0
 
const std::array< char, 256 > cEscapeTable
 
const std::array< char, 256 > cUnescapeTable
 
const std::array< unsigned char, 256 > hexTable
 
const std::array< unsigned char, 256 > uriEscapeTable
 
template<typename T >
constexpr auto is_atomic = false
 
FOLLY_PUSH_WARNING RHS rhs
 

Detailed Description

Call doNotOptimizeAway(var) to ensure that var will be computed even post-optimization. Use it for variables that are computed during benchmarking but otherwise are useless. The compiler tends to do a good job at eliminating unused variables, and this function fools it into thinking var is in fact needed.

Call makeUnpredictable(var) when you don't want the optimizer to use its knowledge of var to shape the following code. This is useful when constant propagation or power reduction is possible during your benchmark but not in real use cases.

DynamicParser provides a tiny DSL for easily, correctly, and losslessly parsing a folly::dynamic into any other representation.

To make this concrete, this lets you take a JSON config that potentially contains user errors, and parse all of its valid parts, while automatically and reversibly recording any parts that cause errors:

{"my values": { "an int": "THIS WILL BE RECORDED AS AN ERROR, BUT WE'LL PARSE THE REST", "a double": 3.1415, "keys & values": { "the sky is blue": true, "THIS WILL ALSO BE RECORDED AS AN ERROR": "cheese", "2+2=5": false, } }}

To parse this JSON, you need no exception handling, it is as easy as:

folly::dynamic d = ...; // Input int64_t integer; // Three outputs double real; std::map<std::string, bool> enabled_widgets; DynamicParser p(DynamicParser::OnError::RECORD, &d); p.required("my values", [&]() { p.optional("an int", [&](int64_t v) { integer = v; }); p.required("a double", [&](double v) { real = v; }); p.optional("keys & values", [&]() { p.objectItems([&](std::string widget, bool enabled) { enabled_widgets.emplace(widget, enabled); }); }); });

Your code in the lambdas can throw, and this will be reported just like missing key and type conversion errors, with precise context on what part of the folly::dynamic caused the error. No need to throw: std::runtime_error("Value X at key Y caused a flux capacitor overload") This will do: std::runtime_error("Flux capacitor overload")

== Keys and values are auto-converted to match your callback ==

DynamicParser's optional(), required(), objectItems(), and arrayItems() automatically convert the current key and value to match the signature of the provided callback. parser.key() and parser.value() can be used to access the same data without conversion.

The following types are supported – you should generally take arguments by-value, or by-const-reference for dynamics & strings you do not copy.

Key: folly::dynamic (no conversion), std::string, int64_t Value: folly::dynamic (no conversion), int64_t, bool, double, std::string

There are 21 supported callback signatures, of three kinds:

1: No arguments – useful if you will just call more parser methods.

5: The value alone – the common case for optional() and required(). [&](whatever_t value) {}

15: Both the key and the value converted according to the rules above: [&](whatever_t key, whatever_t) {}

NB: The key alone should be rarely needed, but these callback styles provide it with no conversion overhead, and only minimal verbosity: [&](const std::string& k, const folly::dynamic&) {} [&]() { auto k = p.key().asString(); }

== How releaseErrors() can make your parse lossless ==

If you write parsing code by hand, you usually end up with error-handling resembling that of OnError::THROW – the first error you hit aborts the whole parse, and you report it.

OnError::RECORD offers a more user-friendly alternative for "parse, serialize, re-parse" pipelines, akin to what web-forms do. All exception-causing parts are losslessly recorded in a parallel folly::dynamic, available via releaseErrors() at the end of the parse.

Suppose we fail to look up "key1" at the root, and hit a value error in "key2": {"subkey2": ...}. The error report will have the form:

{"nested": { "key_errors": {"key1": "explanatory message"}, "value": <whole input>="">, "nested": { "key2": { "nested": { "subkey2": {"value": <original value>="">, "error": "message"} } } } }}

Errors in array items are handled just the same, but using integer keys.

The advantage of this approach is that your parsing can throw wherever, and DynamicParser isolates it, allowing the good parts to parse.

Put another way, this makes it easy to implement a transformation that splits a folly::dynamic into a "parsed" part (which might be your struct meant for runtime use), and a matching "errors" part. As long as your successful parses are lossless, you can always reconstruct the original input from the parse output and the recorded "errors".

== Limitations ==

  • The input dynamic should be an object or array. wrapError() could be exposed to allow parsing single scalars, but this would not be a significant usability improvement over try-catch.
  • Do NOT try to parse the same part of the input dynamic twice. You might report multiple value errors, which is currently unsupported.
  • optional() does not support defaulting. This is unavoidable, since DynamicParser does not dictate how you record parsed data. If your parse writes into an output struct, then it ought to be initialized at construction time. If your output is initialized to default values, then you need no "default" feature. If it is not initialized, you are in trouble anyway. Suppose your optional() parse hits an error. What does your output contain?
    • Uninitialized data :(
    • You rely on an optional() feature to fall back to parsing some default dynamic. Sadly, the default hits a parse error. Now what? Since there is no good way to default, DynamicParser leaves it out.

== Future: un-parsed items ==

DynamicParser could support erroring on un-parsed items – the parts of the folly::dynamic, which were never asked for. Here is an ok design:

(i) At the start of parsing any value, the user may call: parser.recursivelyForbidUnparsed(); parser.recursivelyAllowUnparsed(); parser.locallyForbidUnparsed(); parser.locallyAllowUnparsed();

(ii) At the end of the parse, any unparsed items are dumped to "errors". For example, failing to parse index 1 out of ["v1", "v2", "v3"] yields: "nested": {1: {"unparsed": "v2"}} or perhaps more verbosely: "nested": {1: {"error": "unparsed value", "value": "v2"}}

By default, unparsed items are allowed. Calling a "forbid" function after some keys have already been parsed is allowed to fail (this permits a lazy implementation, which has minimal overhead when "forbid" is not requested).

== Future: multiple value errors ==

The present contract is that exactly one value error is reported per location in the input (multiple key lookup errors are, of course, supported). If the need arises, multiple value errors could easily be supported by replacing the "error" string with an "errors" array.

Wrap a sequence or associative container so that out-of-range lookups return a default value rather than throwing an exception.

Usage: format("[no_such_key"], defaulted(map, 42)) -> 42

Creates a NotificationQueue::Consumer wrapping a function object Modeled after AsyncTimeout::make

An IOBuf is a pointer to a buffer of data.

IOBuf objects are intended to be used primarily for networking code, and are modelled somewhat after FreeBSD's mbuf data structure, and Linux's sk_buff structure.

IOBuf objects facilitate zero-copy network programming, by allowing multiple IOBuf objects to point to the same underlying buffer of data, using a reference count to track when the buffer is no longer needed and can be freed.

Data Layout

The IOBuf itself is a small object containing a pointer to the buffer and information about which segment of the buffer contains valid data.

The data layout looks like this:

+----—+ | IOBuf | +----—+ / | v +---------—+-----------------—+--------—+ | headroom | data | tailroom | +---------—+-----------------—+--------—+ ^ ^ ^ ^ buffer() data() tail() bufferEnd()

The length() method returns the length of the valid data; capacity() returns the entire capacity of the buffer (from buffer() to bufferEnd()). The headroom() and tailroom() methods return the amount of unused capacity available before and after the data.

Buffer Sharing

The buffer itself is reference counted, and multiple IOBuf objects may point to the same buffer. Each IOBuf may point to a different section of valid data within the underlying buffer. For example, if multiple protocol requests are read from the network into a single buffer, a separate IOBuf may be created for each request, all sharing the same underlying buffer.

In other words, when multiple IOBufs share the same underlying buffer, the data() and tail() methods on each IOBuf may point to a different segment of the data. However, the buffer() and bufferEnd() methods will point to the same location for all IOBufs sharing the same underlying buffer.

  +-----------+     +---------+
  |  IOBuf 1  |     | IOBuf 2 |
  +-----------+     +---------+
   |         | _____/        |

data | tail |/ data | tail v v v +----------------------------------—+ | | | | | +----------------------------------—+

If you only read data from an IOBuf, you don't need to worry about other IOBuf objects possibly sharing the same underlying buffer. However, if you ever write to the buffer you need to first ensure that no other IOBufs point to the same buffer. The unshare() method may be used to ensure that you have an unshared buffer.

IOBuf Chains

IOBuf objects also contain pointers to next and previous IOBuf objects. This can be used to represent a single logical piece of data that its stored in non-contiguous chunks in separate buffers.

A single IOBuf object can only belong to one chain at a time.

IOBuf chains are always circular. The "prev" pointer in the head of the chain points to the tail of the chain. However, it is up to the user to decide which IOBuf is the head. Internally the IOBuf code does not care which element is the head.

The lifetime of all IOBufs in the chain are linked: when one element in the chain is deleted, all other chained elements are also deleted. Conceptually it is simplest to treat this as if the head of the chain owns all other IOBufs in the chain. When you delete the head of the chain, it will delete the other elements as well. For this reason, prependChain() and appendChain() take ownership of of the new elements being added to this chain.

When the coalesce() method is used to coalesce an entire IOBuf chain into a single IOBuf, all other IOBufs in the chain are eliminated and automatically deleted. The unshare() method may coalesce the chain; if it does it will similarly delete all IOBufs eliminated from the chain.

As discussed in the following section, it is up to the user to maintain a lock around the entire IOBuf chain if multiple threads need to access the chain. IOBuf does not provide any internal locking.

Synchronization

When used in multithread programs, a single IOBuf object should only be used in a single thread at a time. If a caller uses a single IOBuf across multiple threads the caller is responsible for using an external lock to synchronize access to the IOBuf.

Two separate IOBuf objects may be accessed concurrently in separate threads without locking, even if they point to the same underlying buffer. The buffer reference count is always accessed atomically, and no other operations should affect other IOBufs that point to the same data segment. The caller is responsible for using unshare() to ensure that the data buffer is not shared by other IOBufs before writing to it, and this ensures that the data itself is not modified in one thread while also being accessed from another thread.

For IOBuf chains, no two IOBufs in the same chain should be accessed simultaneously in separate threads. The caller must maintain a lock around the entire chain if the chain, or individual IOBufs in the chain, may be accessed by multiple threads.

IOBuf Object Allocation

IOBuf objects themselves exist separately from the data buffer they point to. Therefore one must also consider how to allocate and manage the IOBuf objects.

It is more common to allocate IOBuf objects on the heap, using the create(), takeOwnership(), or wrapBuffer() factory functions. The clone()/cloneOne() functions also return new heap-allocated IOBufs. The createCombined() function allocates the IOBuf object and data storage space together, in a single memory allocation. This can improve performance, particularly if you know that the data buffer and the IOBuf itself will have similar lifetimes.

That said, it is also possible to allocate IOBufs on the stack or inline inside another object as well. This is useful for cases where the IOBuf is short-lived, or when the overhead of allocating the IOBuf on the heap is undesirable.

However, note that stack-allocated IOBufs may only be used as the head of a chain (or standalone as the only IOBuf in a chain). All non-head members of an IOBuf chain must be heap allocated. (All functions to add nodes to a chain require a std::unique_ptr<IOBuf>, which enforces this requrement.)

Copying IOBufs is only meaningful for the head of a chain. The entire chain is cloned; the IOBufs will become shared, and the old and new IOBufs will refer to the same underlying memory.

IOBuf Sharing

The IOBuf class manages sharing of the underlying buffer that it points to, maintaining a reference count if multiple IOBufs are pointing at the same buffer.

However, it is the callers responsibility to manage sharing and ownership of IOBuf objects themselves. The IOBuf structure does not provide room for an intrusive refcount on the IOBuf object itself, only the underlying data buffer is reference counted. If users want to share the same IOBuf object between multiple parts of the code, they are responsible for managing this sharing on their own. (For example, by using a shared_ptr. Alternatively, users always have the option of using clone() to create a second IOBuf that points to the same underlying buffer.)

Endianness detection and manipulation primitives.

Small internal helper - returns the value just before an iterator.

Specializations of comparison operators for StringPiece

Typedef Documentation

template<typename Fn >
using folly::detail::ArgumentTypes = typedef typename ArgumentTypesByKind<IdentifyCallable::getKind<Fn>(), Fn>::type

Definition at line 80 of file DynamicParser-inl.h.

template<class T >
using folly::detail::AsTypeList = typedef _t<impl::AsTypeList_<T>>

Convert a type to a list of types. Given a type T:

  • If T is of the form C<Ts...>, where C is a class template and Ts... is a list of types, the result is TypeList<Ts...>.
  • Else, if T is of the form std::integer_sequence<T, Is...>, then the result is TypeList<std::integral_constant<T, Is>...>.
  • Otherwise, asTypeList<T> is ill-formed.

Definition at line 514 of file TypeList.h.

using folly::detail::BenchmarkFun = typedef std::function<detail::TimeIterPair(unsigned int)>

Definition at line 59 of file Benchmark.h.

template<bool B>
using folly::detail::Bool = typedef bool_constant<B>

Handy shortcuts for some standard facilities

Definition at line 81 of file TypeList.h.

template<typename... Args>
using folly::detail::EnableForArgTypes = typedef typename std::enable_if<HasArgumentTypes<Args...>::value, void>::type

Definition at line 97 of file DynamicParser-inl.h.

using folly::detail::False = typedef std::false_type

Definition at line 83 of file TypeList.h.

template<template< typename > class Atom = std::atomic>
using folly::detail::Futex = typedef Atom<std::uint32_t>

Futex is an atomic 32 bit unsigned integer that provides access to the futex() syscall on that value. It is templated in such a way that it can interact properly with DeterministicSchedule testing.

If you don't know how to use futex(), you probably shouldn't be using this class. Even if you do know how, you should have a good reason (and benchmarks to back you up).

Because of the semantics of the futex syscall, the futex family of functions are available as free functions rather than member functions

Definition at line 51 of file Futex.h.

template<typename N , typename D >
using folly::detail::IdivResultType = typedef typename std::enable_if< std::is_integral<N>::value && std::is_integral<D>::value && !std::is_same<N, bool>::value && !std::is_same<D, bool>::value, decltype(N{1} / D{1})>::type

Definition at line 105 of file Math.h.

template<bool If_, class Then , class Else >
using folly::detail::If = typedef MetaApply<impl::If_<If_>, Then, Else>

Like std::conditional, but with fewer template instantiations

Definition at line 159 of file TypeList.h.

template<class List >
using folly::detail::Inherit = typedef impl::Inherit_<List>

Given a TypeList, create a type that inherits from all the types in the list.

Requires: all of the types in the list are non-final class types, and the types are all unique.

Definition at line 438 of file TypeList.h.

template<typename Rep , typename Period >
using folly::detail::IntermediateDuration = typedef std::chrono::duration< typename IntermediateTimeRep< Rep, std::is_floating_point<Rep>::value, std::is_signed<Rep>::value>::type, std::ratio<1, Period::den>>

Definition at line 220 of file Conv.h.

template<typename T >
using folly::detail::is_decay_propagate_const = typedef is_propagate_const<_t<std::decay<T>>>

Definition at line 47 of file PropagateConst.h.

template<typename Tgt , typename Src >
using folly::detail::IsArithToArith = typedef bool_constant< !std::is_same<Tgt, Src>::value && !std::is_same<Tgt, bool>::value && std::is_arithmetic<Src>::value && std::is_arithmetic<Tgt>::value>

Definition at line 1348 of file Conv.h.

template<class SynchronizedType >
using folly::detail::LockedPtrType = typedef typename std::conditional< std::is_const<SynchronizedType>::value, typename SynchronizedType::ConstLockedPtr, typename SynchronizedType::LockedPtr>::type

Definition at line 795 of file Synchronized.h.

using folly::detail::max_align_v_ = typedef max_align_t_< long double, double, float, long long int, long int, int, short int, bool, char, char16_t, char32_t, wchar_t, void*, std::max_align_t>

Definition at line 54 of file Align.h.

template<class Fn , class... Ts>
using folly::detail::MetaApply = typedef typename Fn::template apply<Ts...>

Given a metafunction class Fn and arguments Ts..., invoke Fn with Ts....

Definition at line 90 of file TypeList.h.

template<class Fn >
using folly::detail::MetaCurry = typedef MetaCompose<Fn, MetaQuote<TypeList>>

Given a metafunction class Fn that expects a single TypeList argument, turn it into a metafunction class that takes N arguments, wraps them in a TypeList, and calls Fn with it.

MetaApply<MetaCurry<Fn>, Ts...> is equivalent to MetaApply<Fn, TypeList<Ts...>>.

Definition at line 269 of file TypeList.h.

template<template< class... > class C>
using folly::detail::MetaQuoteTrait = typedef MetaCompose<MetaQuote<_t>, MetaQuote<C>>

Lifts a trait class template to be a metafunction class.

MetaApply<MetaQuoteTrait<C>, Ts...> is equivalent to typename C<Ts...>type.

Definition at line 232 of file TypeList.h.

template<class Fn >
using folly::detail::MetaUncurry = typedef MetaBindBack<MetaQuote<MetaApply>, Fn>

Given a metafunction class Fn that expects N arguments, turn it into a metafunction class that takes a single TypeList arguments and calls Fn with the types in the TypeList.

MetaApply<MetaUncurry<Fn>, TypeList<Ts...>> is equivalent to MetaApply<Fn, Ts...>.

Definition at line 280 of file TypeList.h.

template<class Fn , class List >
using folly::detail::MetaUnpack = typedef MetaApply<List, Fn>

Given a metafunction class Fn and a TypeList, call Fn with the types in the TypeList.

Definition at line 308 of file TypeList.h.

template<typename Tgt >
using folly::detail::ParseToError = typedef ExpectedErrorType<decltype( detail::parseToWrap(StringPiece{}, std::declval<Tgt&>()))>

Definition at line 1462 of file Conv.h.

template<typename Tgt >
using folly::detail::ParseToResult = typedef decltype(parseTo(StringPiece{}, std::declval<Tgt&>()))

Definition at line 1421 of file Conv.h.

template<size_t Deg>
using folly::detail::poly_table = typedef std::array<std::array<std::array<uint64_t, poly_size(Deg)>, 256>, 8>

Definition at line 61 of file Fingerprint.h.

template<typename F , bool INE>
using folly::detail::ScopeGuardImplDecay = typedef ScopeGuardImpl<typename std::decay<F>::type, INE>

Definition at line 138 of file ScopeGuard.h.

template<typename RNG >
using folly::detail::StateSizeT = typedef _t<StateSize<RNG>>

Definition at line 58 of file Random-inl.h.

template<class SynchronizedType >
using folly::detail::SynchronizedDataType = typedef typename std::conditional< std::is_const<SynchronizedType>::value, typename SynchronizedType::DataType const, typename SynchronizedType::DataType>::type

Definition at line 786 of file Synchronized.h.

using folly::detail::TimeIterPair = typedef std::pair<std::chrono::high_resolution_clock::duration, unsigned int>

Definition at line 58 of file Benchmark.h.

template<typename T >
using folly::detail::TransparentlyConvertibleToRange = typedef std::is_convertible< T, Range<typename ValueTypeForTransparentConversionToRange<T>::type const*>>

Definition at line 82 of file HeterogeneousAccess.h.

using folly::detail::True = typedef std::true_type

Definition at line 82 of file TypeList.h.

template<class... Ts>
using folly::detail::TypeConcat = typedef TypeJoin<TypeList<Ts...>>

Given several TypeLists, flatten the lists into a single list.

Note
This is just the curried form of TypeJoin. (See MetaCurry.)

TypeConcat<TypeList<As...>, TypeList<Bs...>> is equivalent to TypeList<As..., Bs...>

Definition at line 549 of file TypeList.h.

template<class List , class State , class Fn >
using folly::detail::TypeFold = typedef MetaApply<MetaApply<List, impl::FoldR_<Fn>>, State>

Given a TypeList, an initial state, and a binary function, reduce the TypeList by applying the function to each element and the current state, producing a new state to be used with the next element. This is a "right" fold in functional parlance.

TypeFold<TypeList<A, B, C>, X, Fn> is equivalent to MetaApply<Fn, A, MetaApply<Fn, B, MetaApply<Fn, C, X>>>.

Definition at line 380 of file TypeList.h.

template<class List >
using folly::detail::TypeJoin = typedef MetaApply<TypeFold<List, MetaQuote<TypeList>, impl::Join_>>

Given a TypeList of TypeLists, flatten the lists into a single list.

TypeJoin<TypeList<TypeList<As...>, TypeList<Bs...>>> is equivalent to TypeList<As..., Bs...>

Definition at line 538 of file TypeList.h.

template<class List , class... Ts>
using folly::detail::TypePushBack = typedef MetaApply<List, MetaBindBack<MetaQuote<TypeList>, Ts...>>

Given a TypeList and some arguments, append those arguments to the end of the TypeList.

TypePushBack<TypeList<Ts...>, Us...> is equivalent to TypeList<Ts..., Us...>.

Definition at line 290 of file TypeList.h.

template<class List , class... Ts>
using folly::detail::TypePushFront = typedef MetaApply<List, MetaBindFront<MetaQuote<TypeList>, Ts...>>

Given a TypeList and some arguments, prepend those arguments to the start of the TypeList.

TypePushFront<TypeList<Ts...>, Us...> is equivalent to TypeList<Us..., Ts...>.

Definition at line 301 of file TypeList.h.

template<class List , class State , class Fn >
using folly::detail::TypeReverseFold = typedef MetaApply<MetaApply<List, impl::FoldL_<Fn>>, State>

Given a TypeList, an initial state, and a binary function, reduce the TypeList by applying the function to each element and the current state, producing a new state to be used with the next element. This is a "left" fold, in functional parlance.

TypeReverseFold<TypeList<A, B, C>, X, Fn> is equivalent to MetaApply<Fn, MetaApply<Fn, MetaApply<Fn, X, C>, B, A>.

Definition at line 419 of file TypeList.h.

template<class List >
using folly::detail::TypeReverseUnique = typedef TypeReverseFold<List, TypeList<>, MetaFlip<impl::Unique_>>

Given a TypeList, produce a new list of types removing duplicates, keeping the last seen element.

TypeUnique<TypeList<int, short, int>> is equivalent to TypeList<short, int>.

Note
This algorithm is O(N^2).

Definition at line 488 of file TypeList.h.

template<class List , class Fn >
using folly::detail::TypeTransform = typedef MetaApply<List, impl::TypeTransform_<Fn>>

Transform all the elements in a TypeList with the metafunction class Fn.

TypeTransform<TypeList<Ts..>, Fn> is equivalent to TypeList<MetaApply<Fn, Ts>...>.

Definition at line 327 of file TypeList.h.

template<class List >
using folly::detail::TypeUnique = typedef TypeFold<List, TypeList<>, impl::Unique_>

Given a TypeList, produce a new list of types removing duplicates, keeping the first seen element.

TypeUnique<TypeList<int, short, int>> is equivalent to TypeList<int, short>.

Note
This algorithm is O(N^2).

Definition at line 475 of file TypeList.h.

Enumeration Type Documentation

Enumerator
VALUE_CHANGED 
AWOKEN 
INTERRUPTED 
TIMEDOUT 

Definition at line 31 of file Futex.h.

31  {
32  VALUE_CHANGED, /* futex value didn't match expected */
33  AWOKEN, /* wakeup by matching futex wake, or spurious wakeup */
34  INTERRUPTED, /* wakeup by interrupting signal */
35  TIMEDOUT, /* wakeup by expiring deadline */
36 };

An enum to describe the "level" of a mutex. The supported levels are Unique - a normal mutex that supports only exclusive locking Shared - a shared mutex which has shared locking and unlocking functions; Upgrade - a mutex that has all the methods of the two above along with support for upgradable locking

Enumerator
UNIQUE 
SHARED 
UPGRADE 

Definition at line 57 of file LockTraits.h.

Internal use for the macro SCOPE_EXIT below

Definition at line 261 of file ScopeGuard.h.

261 {};
Enumerator
success 
timeout 
advance 

Definition at line 29 of file Spin.h.

29  {
30  success, // condition passed
31  timeout, // exceeded deadline
32  advance, // exceeded current wait-options component timeout
33 };

Function Documentation

void folly::detail::addBenchmarkImpl ( const char *  file,
const char *  name,
std::function< TimeIterPair(unsigned int)>   
)

Adds a benchmark wrapped in a std::function. Only used internally. Pass by value is intentional.

Referenced by folly::addBenchmark(), and folly::getGlobalBenchmarkBaselineIndex().

void folly::detail::annotate_benign_race_sized_impl ( const volatile void *  addr,
long  size,
const char *  desc,
const char *  f,
int  l 
)

Definition at line 118 of file SanitizeThread.cpp.

References AnnotateBenignRaceSized(), FOLLY_SANITIZE_THREAD_CALL_HOOK, and folly::kIsSanitizeThread.

Referenced by folly::annotate_benign_race_sized().

123  {
124  if (kIsSanitizeThread) {
126  AnnotateBenignRaceSized, f, l, addr, size, desc);
127  }
128 }
#define FOLLY_SANITIZE_THREAD_CALL_HOOK(name,...)
auto f
constexpr bool kIsSanitizeThread
Definition: Portability.h:124
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
ThreadPoolListHook * addr
FOLLY_ATTR_WEAK void AnnotateBenignRaceSized(const char *f, int l, const volatile void *addr, long size, const char *desc)
void folly::detail::annotate_rwlock_acquired_impl ( void const volatile *const  addr,
annotate_rwlock_level const  w,
char const *const  f,
int const  l 
)

Definition at line 85 of file SanitizeThread.cpp.

References AnnotateRWLockAcquired(), FOLLY_SANITIZE_THREAD_CALL_HOOK, and folly::kIsSanitizeThread.

Referenced by folly::annotate_rwlock_acquired().

89  {
90  if (kIsSanitizeThread) {
92  AnnotateRWLockAcquired, f, l, addr, static_cast<long>(w));
93  }
94 }
#define FOLLY_SANITIZE_THREAD_CALL_HOOK(name,...)
auto f
constexpr bool kIsSanitizeThread
Definition: Portability.h:124
FOLLY_ATTR_WEAK void AnnotateRWLockAcquired(const char *f, int l, const volatile void *addr, long w)
ThreadPoolListHook * addr
void folly::detail::annotate_rwlock_create_impl ( void const volatile *const  addr,
char const *const  f,
int const  l 
)

Definition at line 58 of file SanitizeThread.cpp.

References AnnotateRWLockCreate(), FOLLY_SANITIZE_THREAD_CALL_HOOK, and folly::kIsSanitizeThread.

Referenced by folly::annotate_rwlock_create().

61  {
62  if (kIsSanitizeThread) {
64  }
65 }
#define FOLLY_SANITIZE_THREAD_CALL_HOOK(name,...)
auto f
constexpr bool kIsSanitizeThread
Definition: Portability.h:124
FOLLY_ATTR_WEAK void AnnotateRWLockCreate(const char *f, int l, const volatile void *addr)
ThreadPoolListHook * addr
void folly::detail::annotate_rwlock_create_static_impl ( void const volatile *const  addr,
char const *const  f,
int const  l 
)

Definition at line 67 of file SanitizeThread.cpp.

References AnnotateRWLockCreateStatic(), FOLLY_SANITIZE_THREAD_CALL_HOOK, and folly::kIsSanitizeThread.

Referenced by folly::annotate_rwlock_create_static().

70  {
71  if (kIsSanitizeThread) {
73  }
74 }
#define FOLLY_SANITIZE_THREAD_CALL_HOOK(name,...)
FOLLY_ATTR_WEAK void AnnotateRWLockCreateStatic(const char *f, int l, const volatile void *addr)
auto f
constexpr bool kIsSanitizeThread
Definition: Portability.h:124
ThreadPoolListHook * addr
void folly::detail::annotate_rwlock_destroy_impl ( void const volatile *const  addr,
char const *const  f,
int const  l 
)

Definition at line 76 of file SanitizeThread.cpp.

References AnnotateRWLockDestroy(), FOLLY_SANITIZE_THREAD_CALL_HOOK, and folly::kIsSanitizeThread.

Referenced by folly::annotate_rwlock_destroy().

79  {
80  if (kIsSanitizeThread) {
82  }
83 }
#define FOLLY_SANITIZE_THREAD_CALL_HOOK(name,...)
auto f
constexpr bool kIsSanitizeThread
Definition: Portability.h:124
FOLLY_ATTR_WEAK void AnnotateRWLockDestroy(const char *f, int l, const volatile void *addr)
ThreadPoolListHook * addr
void folly::detail::annotate_rwlock_released_impl ( void const volatile *const  addr,
annotate_rwlock_level const  w,
char const *const  f,
int const  l 
)

Definition at line 107 of file SanitizeThread.cpp.

References AnnotateRWLockReleased(), FOLLY_SANITIZE_THREAD_CALL_HOOK, and folly::kIsSanitizeThread.

Referenced by folly::annotate_rwlock_released().

111  {
112  if (kIsSanitizeThread) {
114  AnnotateRWLockReleased, f, l, addr, static_cast<long>(w));
115  }
116 }
#define FOLLY_SANITIZE_THREAD_CALL_HOOK(name,...)
auto f
constexpr bool kIsSanitizeThread
Definition: Portability.h:124
FOLLY_ATTR_WEAK void AnnotateRWLockReleased(const char *f, int l, const volatile void *addr, long w)
ThreadPoolListHook * addr
void folly::detail::annotate_rwlock_try_acquired_impl ( void const volatile *const  addr,
annotate_rwlock_level const  w,
bool const  result,
char const *const  f,
int const  l 
)

Definition at line 96 of file SanitizeThread.cpp.

References folly::annotate_rwlock_acquired().

101  {
102  if (result) {
104  }
105 }
auto f
static FOLLY_ALWAYS_INLINE void annotate_rwlock_acquired(void const volatile *const addr, annotate_rwlock_level const w, char const *const f, int const l)
ThreadPoolListHook * addr
template<typename Container , typename Compare >
Container&& folly::detail::as_sorted ( Container &&  container,
Compare const &  comp 
)

Definition at line 199 of file sorted_vector_types.h.

References folly::test::begin(), folly::test::end(), and folly::T.

199  {
200  using namespace std;
201  std::sort(begin(container), end(container), comp);
202  return static_cast<Container&&>(container);
203 }
STL namespace.
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
void folly::detail::assertionFailure ( const char *  expr,
const char *  msg,
const char *  file,
unsigned int  line,
const char *  function 
)

Definition at line 34 of file SafeAssert.cpp.

References folly::fsyncNoInt(), uint32_t, folly::uint64ToBufferUnsafe(), and folly::writeFull().

39  {
40  writeStderr("\n\nAssertion failure: ");
41  writeStderr(expr + 1, strlen(expr) - 2);
42  writeStderr("\nMessage: ");
43  writeStderr(msg);
44  writeStderr("\nFile: ");
45  writeStderr(file);
46  writeStderr("\nLine: ");
47  char buf[20];
48  uint32_t n = uint64ToBufferUnsafe(line, buf);
49  writeFull(STDERR_FILENO, buf, n);
50  writeStderr("\nFunction: ");
51  writeStderr(function);
52  writeStderr("\n");
53  fsyncNoInt(STDERR_FILENO);
54  abort();
55 }
uint32_t uint64ToBufferUnsafe(uint64_t v, char *const buffer)
Definition: Conv.h:383
int fsyncNoInt(int fd)
Definition: FileUtil.cpp:64
ssize_t writeFull(int fd, const void *buf, size_t count)
Definition: FileUtil.cpp:134
void folly::detail::assume_check ( bool  cond)

Definition at line 25 of file Assume.cpp.

Referenced by folly::assume().

25  {
26  CHECK(cond) << "compiler-hint assumption fails at runtime";
27 }
bool folly::detail::atDelim ( const char *  s,
char  c 
)
inline

Definition at line 255 of file String-inl.h.

References c.

Referenced by internalSplit().

255  {
256  return *s == c;
257 }
static set< string > s
char c
bool folly::detail::atDelim ( const char *  s,
StringPiece  sp 
)
inline

Definition at line 258 of file String-inl.h.

References folly::Range< Iter >::size(), and folly::Range< Iter >::start().

258  {
259  return !std::memcmp(s, sp.start(), sp.size());
260 }
static set< string > s
template<typename Atomic >
bool folly::detail::atomic_fetch_reset_default ( Atomic &  atomic,
std::size_t  bit,
std::memory_order  order 
)

Definition at line 53 of file AtomicUtil-inl.h.

Referenced by folly::atomic_fetch_reset(), and folly::TEST_F().

56  {
57  using Integer = decltype(atomic.load());
58  auto mask = Integer{0b1} << static_cast<Integer>(bit);
59  return (atomic.fetch_and(~mask, order) & mask);
60 }
int order
template<typename Atomic >
bool folly::detail::atomic_fetch_reset_x86 ( Atomic &  ,
std::size_t  ,
std::memory_order   
)
noexcept

Definition at line 228 of file AtomicUtil-inl.h.

Referenced by folly::atomic_fetch_reset(), and folly::TEST_F().

228  {
229  throw std::logic_error{"Incorrect function called"};
230 }
template<typename Atomic >
bool folly::detail::atomic_fetch_set_default ( Atomic &  atomic,
std::size_t  bit,
std::memory_order  order 
)

Definition at line 43 of file AtomicUtil-inl.h.

Referenced by folly::atomic_fetch_set(), and folly::TEST_F().

46  {
47  using Integer = decltype(atomic.load());
48  auto mask = Integer{0b1} << static_cast<Integer>(bit);
49  return (atomic.fetch_or(mask, order) & mask);
50 }
int order
template<typename Atomic >
bool folly::detail::atomic_fetch_set_x86 ( Atomic &  ,
std::size_t  ,
std::memory_order   
)
noexcept

Definition at line 224 of file AtomicUtil-inl.h.

Referenced by folly::atomic_fetch_set(), and folly::TEST_F().

224  {
225  throw std::logic_error{"Incorrect function called"};
226 }
template<typename Cond >
void folly::detail::atomic_hash_spin_wait ( Cond  condition)

Definition at line 30 of file AtomicHashUtils.h.

References folly::asm_volatile_pause(), i, and folly::fibers::yield().

Referenced by folly::AtomicHashArray< KeyT, ValueT, HashFcn, EqualFcn, Allocator, ProbeFcn, KeyConvertFcn >::insertInternal(), and folly::AtomicHashMap< KeyT, ValueT, HashFcn, EqualFcn, Allocator, ProbeFcn, KeyConvertFcn >::insertInternal().

30  {
31  constexpr size_t kPauseLimit = 10000;
32  for (size_t i = 0; condition(); ++i) {
33  if (i < kPauseLimit) {
35  } else {
37  }
38  }
39 }
void asm_volatile_pause()
Definition: Asm.h:37
template<typename ReturnType >
ReturnType folly::detail::avgHelper ( long double  sum,
uint64_t  count 
)

Definition at line 34 of file Bucket.h.

References count, type, and folly::value().

34  {
35  if (count == 0) {
36  return ReturnType(0);
37  }
38  const long double countf = count;
39  return static_cast<ReturnType>(sum / countf);
40 }
std::atomic< int64_t > sum(0)
int * count
template<typename ReturnType , typename ValueType >
std::enable_if< !std::is_same<typename std::remove_cv<ValueType>::type, long double>::value, ReturnType>::type folly::detail::avgHelper ( ValueType  sum,
uint64_t  count 
)

Definition at line 48 of file Bucket.h.

48  {
49  if (count == 0) {
50  return ReturnType(0);
51  }
52  const double sumf = double(sum);
53  const double countf = double(count);
54  return static_cast<ReturnType>(sumf / countf);
55 }
std::atomic< int64_t > sum(0)
int * count
template<typename Dst , typename Src >
constexpr std::make_signed_t<Dst> folly::detail::bits_to_signed ( Src const  s)

Definition at line 66 of file Bits.h.

References folly::to_signed(), folly::to_unsigned(), and value.

Referenced by folly::findFirstSet().

66  {
67  static_assert(std::is_signed<Dst>::value, "unsigned type");
68  return to_signed(static_cast<std::make_unsigned_t<Dst>>(to_unsigned(s)));
69 }
constexpr auto to_unsigned(T const &t) -> typename std::make_unsigned< T >::type
Definition: Utility.h:399
static const char *const value
Definition: Conv.cpp:50
constexpr auto to_signed(T const &t) -> typename std::make_signed< T >::type
Definition: Utility.h:389
static set< string > s
template<typename Dst , typename Src >
constexpr std::make_unsigned_t<Dst> folly::detail::bits_to_unsigned ( Src const  s)

Definition at line 71 of file Bits.h.

References folly::to_unsigned(), and value.

Referenced by folly::findLastSet(), and folly::popcount().

71  {
72  static_assert(std::is_unsigned<Dst>::value, "signed type");
73  return static_cast<Dst>(to_unsigned(s));
74 }
constexpr auto to_unsigned(T const &t) -> typename std::make_unsigned< T >::type
Definition: Utility.h:399
static const char *const value
Definition: Conv.cpp:50
static set< string > s
template<class OurContainer , class Vector , class InputIterator >
void folly::detail::bulk_insert ( OurContainer &  sorted,
Vector &  cont,
InputIterator  first,
InputIterator  last 
)

Definition at line 161 of file sorted_vector_types.h.

References a, b, folly::copy(), and distance_if_multipass().

Referenced by folly::sorted_vector_set< folly::RequestData * >::insert(), and folly::sorted_vector_map< Key, Value, Compare, Allocator, GrowthPolicy, Container >::insert().

165  {
166  // prevent deref of middle where middle == cont.end()
167  if (first == last) {
168  return;
169  }
170 
171  auto const& cmp(sorted.value_comp());
172 
173  int const d = distance_if_multipass(first, last);
174  if (d != -1) {
175  cont.reserve(cont.size() + d);
176  }
177  auto const prev_size = cont.size();
178 
179  std::copy(first, last, std::back_inserter(cont));
180  auto const middle = cont.begin() + prev_size;
181  if (!std::is_sorted(middle, cont.end(), cmp)) {
182  std::sort(middle, cont.end(), cmp);
183  }
184  if (middle != cont.begin() && !cmp(*(middle - 1), *middle)) {
185  std::inplace_merge(cont.begin(), middle, cont.end(), cmp);
186  }
187  cont.erase(
188  std::unique(
189  cont.begin(),
190  cont.end(),
191  [&](typename OurContainer::value_type const& a,
192  typename OurContainer::value_type const& b) {
193  return !cmp(a, b) && !cmp(b, a);
194  }),
195  cont.end());
196 }
int distance_if_multipass(Iterator first, Iterator last)
char b
constexpr std::decay< T >::type copy(T &&value) noexcept(noexcept(typename std::decay< T >::type(std::forward< T >(value))))
Definition: Utility.h:72
char a
constexpr detail::First first
Definition: Base-inl.h:2553
static uint8_t folly::detail::byteswap_gen ( uint8_t  v)
inlinestatic

Definition at line 185 of file Bits.h.

Referenced by folly::detail::EndianInt< T >::swap().

199 {
static uint64_t folly::detail::byteswap_gen ( uint64_t  v)
inlinestatic

Definition at line 191 of file Bits.h.

199 {
static uint32_t folly::detail::byteswap_gen ( uint32_t  v)
inlinestatic

Definition at line 192 of file Bits.h.

199 {
static uint16_t folly::detail::byteswap_gen ( uint16_t  v)
inlinestatic

Definition at line 193 of file Bits.h.

199 {
template<typename Tgt , typename Src >
std::enable_if< std::is_floating_point<Src>::value && std::is_integral<Tgt>::value && !std::is_same<Tgt, bool>::value, bool>::type folly::detail::checkConversion ( const Src &  value)
inline

Check if a floating point value can safely be converted to an integer value without triggering undefined behaviour.

Definition at line 1267 of file Conv.h.

References max, min, type, and value.

1267  {
1268  constexpr Src tgtMaxAsSrc = static_cast<Src>(std::numeric_limits<Tgt>::max());
1269  constexpr Src tgtMinAsSrc = static_cast<Src>(std::numeric_limits<Tgt>::min());
1270  if (value >= tgtMaxAsSrc) {
1271  if (value > tgtMaxAsSrc) {
1272  return false;
1273  }
1274  const Src mmax = folly::nextafter(tgtMaxAsSrc, Src());
1275  if (static_cast<Tgt>(value - mmax) >
1276  std::numeric_limits<Tgt>::max() - static_cast<Tgt>(mmax)) {
1277  return false;
1278  }
1279  } else if (std::is_signed<Tgt>::value && value <= tgtMinAsSrc) {
1280  if (value < tgtMinAsSrc) {
1281  return false;
1282  }
1283  const Src mmin = folly::nextafter(tgtMinAsSrc, Src());
1284  if (static_cast<Tgt>(value - mmin) <
1285  std::numeric_limits<Tgt>::min() - static_cast<Tgt>(mmin)) {
1286  return false;
1287  }
1288  }
1289  return true;
1290 }
LogLevel max
Definition: LogLevel.cpp:31
LogLevel min
Definition: LogLevel.cpp:30
static const char *const value
Definition: Conv.cpp:50
template<typename Tgt , typename Src >
constexpr std::enable_if< std::is_integral<Src>::value && std::is_floating_point<Tgt>::value, bool>::type folly::detail::checkConversion ( const Src &  )

Definition at line 1297 of file Conv.h.

References type.

1297  {
1298  return true;
1299 }
template<typename Tgt , typename Src >
constexpr std::enable_if< std::is_floating_point<Src>::value && std::is_same<Tgt, bool>::value, bool>::type folly::detail::checkConversion ( const Src &  )

Definition at line 1307 of file Conv.h.

References type, and value.

1307  {
1308  return true;
1309 }
template<typename NotKeyT , typename KeyT >
void folly::detail::checkLegalKeyIfKeyTImpl ( NotKeyT  ,
KeyT  ,
KeyT  ,
KeyT   
)
inline
template<typename KeyT >
void folly::detail::checkLegalKeyIfKeyTImpl ( KeyT  key_in,
KeyT  emptyKey,
KeyT  lockedKey,
KeyT  erasedKey 
)
inline

Definition at line 76 of file AtomicHashArray.h.

80  {
81  DCHECK_NE(key_in, emptyKey);
82  DCHECK_NE(key_in, lockedKey);
83  DCHECK_NE(key_in, erasedKey);
84 }
template<typename Src >
Expected<time_t, ConversionCode> folly::detail::chronoRangeCheck ( Src  value)

This converts a number in some input type to time_t while ensuring that it fits in the range of numbers representable by time_t.

This is similar to the normal folly::tryTo() behavior when converting arthmetic types to an integer type, except that it does not complain about floating point conversions losing precision.

Definition at line 75 of file Conv.h.

References folly::makeUnexpected(), max, folly::NEGATIVE_OVERFLOW, folly::POSITIVE_OVERFLOW, value, and folly::value().

Referenced by durationToPosixTime().

75  {
77  return makeUnexpected(ConversionCode::POSITIVE_OVERFLOW);
78  }
80  if (value < std::numeric_limits<time_t>::lowest()) {
81  return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
82  }
83  }
84 
85  return static_cast<time_t>(value);
86 }
LogLevel max
Definition: LogLevel.cpp:31
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
static const char *const value
Definition: Conv.cpp:50
template<typename D , typename S >
constexpr D folly::detail::constexpr_clamp_cast_helper ( S  src,
S  sl,
S  su,
D  dl,
D  du 
)

Definition at line 356 of file ConstexprMath.h.

References D, type, and value.

Referenced by folly::constexpr_clamp_cast().

356  {
357  return src < sl ? dl : (src > su ? du : D(src));
358 }
#define D(name, bit)
Definition: CpuId.h:145
template<typename U >
constexpr std::size_t folly::detail::constexpr_find_first_set_ ( std::size_t  s,
std::size_t  a,
U const  u 
)

Definition at line 196 of file ConstexprMath.h.

Referenced by folly::constexpr_find_first_set().

196  {
197  return s == 0 ? a
199  s / 2, a + s * bool((u >> a) % (U(1) << s) == U(0)), u);
200 }
constexpr std::size_t constexpr_find_first_set_(std::size_t s, std::size_t a, U const u)
char a
static set< string > s
template<typename T >
constexpr T folly::detail::constexpr_log2_ ( T  a,
T  e 
)

Definition at line 142 of file ConstexprMath.h.

References folly::T.

Referenced by folly::constexpr_log2().

142  {
143  return e == T(1) ? a : constexpr_log2_(a + T(1), e / T(2));
144 }
#define T(v)
Definition: http_parser.c:233
constexpr T constexpr_log2_(T a, T e)
char a
template<typename T >
constexpr T folly::detail::constexpr_log2_ceil_ ( T  l2,
T  t 
)

Definition at line 147 of file ConstexprMath.h.

References folly::T.

Referenced by folly::constexpr_log2_ceil().

147  {
148  return l2 + T(T(1) << l2 < t ? 1 : 0);
149 }
#define T(v)
Definition: http_parser.c:233
template<typename T >
constexpr T folly::detail::constexpr_square_ ( T  t)

Definition at line 152 of file ConstexprMath.h.

References folly::pushmi::detail::t.

Referenced by folly::constexpr_pow().

152  {
153  return t * t;
154 }
template<typename Char >
constexpr int folly::detail::constexpr_strcmp_internal ( const Char *  s1,
const Char *  s2 
)

Definition at line 49 of file Constexpr.h.

Referenced by folly::constexpr_strcmp().

49  {
50  return (*s1 == '\0' || *s1 != *s2)
51  ? (static_cast<int>(*s1 - *s2))
52  : constexpr_strcmp_internal(s1 + 1, s2 + 1);
53 }
constexpr int constexpr_strcmp_internal(const Char *s1, const Char *s2)
Definition: Constexpr.h:49
template<typename Char >
constexpr size_t folly::detail::constexpr_strlen_internal ( const Char *  s,
size_t  len 
)

Definition at line 30 of file Constexpr.h.

References testing::gmock_generated_actions_test::Char().

Referenced by folly::detail::fixedstring::checkNullTerminated(), and folly::constexpr_strlen().

30  {
31  // clang-format off
32  return
33  *(s + 0) == Char(0) ? len + 0 :
34  *(s + 1) == Char(0) ? len + 1 :
35  *(s + 2) == Char(0) ? len + 2 :
36  *(s + 3) == Char(0) ? len + 3 :
37  *(s + 4) == Char(0) ? len + 4 :
38  *(s + 5) == Char(0) ? len + 5 :
39  *(s + 6) == Char(0) ? len + 6 :
40  *(s + 7) == Char(0) ? len + 7 :
41  constexpr_strlen_internal(s + 8, len + 8);
42  // clang-format on
43 }
constexpr size_t constexpr_strlen_internal(const Char *s, size_t len)
Definition: Constexpr.h:30
static set< string > s
template<class Tgt >
std::enable_if< !std::is_same<Tgt, bool>::value && (std::is_integral<Tgt>::value || std::is_floating_point<Tgt>::value), Expected<Tgt, ConversionCode> >::type folly::detail::convertTo ( const bool &  value)
noexcept

Bool to integral/float doesn't need any special checks, and this overload means we aren't trying to see if a bool is less than an integer.

Definition at line 1203 of file Conv.h.

References type, and value.

1203  {
1204  return static_cast<Tgt>(value ? 1 : 0);
1205 }
static const char *const value
Definition: Conv.cpp:50
template<class Tgt , class Src >
std::enable_if< std::is_integral<Src>::value && !std::is_same<Tgt, Src>::value && !std::is_same<Tgt, bool>::value && std::is_integral<Tgt>::value, Expected<Tgt, ConversionCode> >::type folly::detail::convertTo ( const Src &  value)
noexcept

Checked conversion from integral to integral. The checks are only performed when meaningful, e.g. conversion from int to long goes unchecked.

Definition at line 1217 of file Conv.h.

References folly::ARITH_NEGATIVE_OVERFLOW, folly::ARITH_POSITIVE_OVERFLOW, folly::greater_than(), folly::less_than(), folly::makeUnexpected(), max, min, type, value, and folly::value().

1217  {
1218  if /* constexpr */ (
1220  folly::_t<std::make_unsigned<Src>>(std::numeric_limits<Src>::max())) {
1222  return makeUnexpected(ConversionCode::ARITH_POSITIVE_OVERFLOW);
1223  }
1224  }
1225  if /* constexpr */ (
1227  (!std::is_signed<Tgt>::value || sizeof(Src) > sizeof(Tgt))) {
1229  return makeUnexpected(ConversionCode::ARITH_NEGATIVE_OVERFLOW);
1230  }
1231  }
1232  return static_cast<Tgt>(value);
1233 }
LogLevel max
Definition: LogLevel.cpp:31
bool less_than(LHS const lhs)
Definition: Traits.h:698
bool greater_than(LHS const lhs)
Definition: Traits.h:704
LogLevel min
Definition: LogLevel.cpp:30
typename T::type _t
Definition: Traits.h:171
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
static const char *const value
Definition: Conv.cpp:50
template<class Tgt , class Src >
std::enable_if< std::is_floating_point<Tgt>::value && std::is_floating_point<Src>::value && !std::is_same<Tgt, Src>::value, Expected<Tgt, ConversionCode> >::type folly::detail::convertTo ( const Src &  value)
noexcept

Checked conversion from floating to floating. The checks are only performed when meaningful, e.g. conversion from float to double goes unchecked.

Definition at line 1245 of file Conv.h.

References folly::ARITH_NEGATIVE_OVERFLOW, folly::ARITH_POSITIVE_OVERFLOW, folly::makeUnexpected(), max, type, and folly::value().

1245  {
1246  if /* constexpr */ (
1249  return makeUnexpected(ConversionCode::ARITH_POSITIVE_OVERFLOW);
1250  }
1251  if (value < std::numeric_limits<Tgt>::lowest()) {
1252  return makeUnexpected(ConversionCode::ARITH_NEGATIVE_OVERFLOW);
1253  }
1254  }
1255  return static_cast<Tgt>(value);
1256 }
LogLevel max
Definition: LogLevel.cpp:31
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
static const char *const value
Definition: Conv.cpp:50
template<typename Tgt , typename Src >
std::enable_if< (std::is_integral<Src>::value && std::is_floating_point<Tgt>::value) || (std::is_floating_point<Src>::value && std::is_integral<Tgt>::value), Expected<Tgt, ConversionCode> >::type folly::detail::convertTo ( const Src &  value)
noexcept

Checked conversion from integral to floating point and back. The result must be convertible back to the source type without loss of precision. This seems Draconian but sometimes is what's needed, and complements existing routines nicely. For various rounding routines, see <math>.

Definition at line 1323 of file Conv.h.

References folly::ARITH_LOSS_OF_PRECISION, LIKELY, folly::makeUnexpected(), and folly::value().

1323  {
1324  if (LIKELY(checkConversion<Tgt>(value))) {
1325  Tgt result = static_cast<Tgt>(value);
1326  if (LIKELY(checkConversion<Src>(result))) {
1327  Src witness = static_cast<Src>(result);
1328  if (LIKELY(value == witness)) {
1329  return result;
1330  }
1331  }
1332  }
1333  return makeUnexpected(ConversionCode::ARITH_LOSS_OF_PRECISION);
1334 }
#define LIKELY(x)
Definition: Likely.h:47
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
static const char *const value
Definition: Conv.cpp:50
int folly::detail::cplus_demangle_v3_callback_wrapper ( char const *const  mangled,
void(*)(char const *, std::size_t, void *)  cbref,
void *const  opaque 
)

Definition at line 32 of file Demangle.cpp.

35  {
36 #if FOLLY_DETAIL_HAVE_DEMANGLE_H
37  auto const options = DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES;
38  return cplus_demangle_v3_callback(mangled, options, cbref, opaque);
39 #else
40  return 0;
41 #endif
42 }
uint32_t folly::detail::crc32_combine_hw ( uint32_t  crc1,
uint32_t  crc2,
size_t  crc2len 
)

Definition at line 166 of file Crc32CombineDetail.cpp.

References folly::crc32_append_zeroes(), and folly::gf_multiply_crc32_hw().

Referenced by folly::crc32_combine().

166  {
167  return crc2 ^
169  gf_multiply_crc32_hw, crc1, crc2len, crc32_m, crc32_powers);
170 }
static constexpr uint32_t crc32_m
static constexpr std::array< uint32_t, 62 > const crc32_powers
static uint32_t crc32_append_zeroes(F mult, uint32_t crc, size_t len, uint32_t polynomial, std::array< uint32_t, 62 > const &powers_array)
static uint32_t gf_multiply_crc32_hw(uint64_t, uint64_t, uint32_t)
uint32_t folly::detail::crc32_combine_sw ( uint32_t  crc1,
uint32_t  crc2,
size_t  crc2len 
)

Definition at line 161 of file Crc32CombineDetail.cpp.

References folly::crc32_append_zeroes(), and folly::gf_multiply_sw().

Referenced by folly::crc32_combine().

161  {
162  return crc2 ^
164 }
static constexpr uint32_t crc32_m
static constexpr std::array< uint32_t, 62 > const crc32_powers
static uint32_t crc32_append_zeroes(F mult, uint32_t crc, size_t len, uint32_t polynomial, std::array< uint32_t, 62 > const &powers_array)
static constexpr uint32_t gf_multiply_sw(uint32_t a, uint32_t b, uint32_t m)
uint32_t folly::detail::crc32_hw ( const uint8_t data,
size_t  nbytes,
uint32_t  startingChecksum = ~0U 
)

Compute a CRC-32 checksum of a buffer using a hardware-accelerated implementation.

Note
This function is exposed to support special cases where the calling code is absolutely certain it ought to invoke a hardware- accelerated CRC-32 implementation - unit tests, for example. For all other scenarios, please call crc32() and let it pick an implementation based on the capabilities of the underlying CPU.

Definition at line 76 of file Checksum.cpp.

Referenced by benchmarkHardwareCRC32(), folly::crc32(), and TEST().

79  {
80  throw std::runtime_error("crc32_hw is not implemented on this platform");
81 }
bool folly::detail::crc32_hw_supported ( )

Check whether a hardware-accelerated CRC-32 implementation is supported on the current CPU.

Definition at line 87 of file Checksum.cpp.

Referenced by benchmarkHardwareCRC32(), folly::crc32(), folly::crc32_combine(), and folly::crc32c_combine().

87  {
88  return false;
89 }
uint32_t folly::detail::crc32_sw ( const uint8_t data,
size_t  nbytes,
uint32_t  startingChecksum = ~0U 
)

Compute a CRC-32 checksum of a buffer using a portable, software-only implementation.

Note
This function is exposed to support special cases where the calling code is absolutely certain it wants to use the software implementation instead of the hardware-accelerated code - unit tests, for example. For all other scenarios, please call crc32() and let it pick an implementation based on the capabilities of the underlying CPU.

Definition at line 121 of file Checksum.cpp.

References folly::data(), and uint32_t.

Referenced by benchmarkSoftwareCRC32(), folly::crc32(), and TEST().

121  {
122  constexpr uint32_t CRC32_POLYNOMIAL = 0x04C11DB7;
123  return crc_sw<CRC32_POLYNOMIAL>(data, nbytes, startingChecksum);
124 }
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
uint32_t folly::detail::crc32c_combine_hw ( uint32_t  crc1,
uint32_t  crc2,
size_t  crc2len 
)

Definition at line 178 of file Crc32CombineDetail.cpp.

References folly::crc32_append_zeroes(), and folly::gf_multiply_crc32c_hw().

Referenced by folly::crc32c_combine().

178  {
179  return crc2 ^
181  gf_multiply_crc32c_hw, crc1, crc2len, crc32c_m, crc32c_powers);
182 }
static uint32_t crc32_append_zeroes(F mult, uint32_t crc, size_t len, uint32_t polynomial, std::array< uint32_t, 62 > const &powers_array)
static constexpr uint32_t crc32c_m
static uint32_t gf_multiply_crc32c_hw(uint64_t, uint64_t, uint32_t)
static constexpr std::array< uint32_t, 62 > const crc32c_powers
uint32_t folly::detail::crc32c_combine_sw ( uint32_t  crc1,
uint32_t  crc2,
size_t  crc2len 
)

Definition at line 172 of file Crc32CombineDetail.cpp.

References folly::crc32_append_zeroes(), and folly::gf_multiply_sw().

Referenced by folly::crc32c_combine().

172  {
173  return crc2 ^
175  gf_multiply_sw, crc1, crc2len, crc32c_m, crc32c_powers);
176 }
static uint32_t crc32_append_zeroes(F mult, uint32_t crc, size_t len, uint32_t polynomial, std::array< uint32_t, 62 > const &powers_array)
static constexpr uint32_t crc32c_m
static constexpr uint32_t gf_multiply_sw(uint32_t a, uint32_t b, uint32_t m)
static constexpr std::array< uint32_t, 62 > const crc32c_powers
uint32_t folly::detail::crc32c_hw ( const uint8_t data,
size_t  nbytes,
uint32_t  startingChecksum = ~0U 
)

Compute a CRC-32C checksum of a buffer using a hardware-accelerated implementation.

Note
This function is exposed to support special cases where the calling code is absolutely certain it ought to invoke a hardware- accelerated CRC-32C implementation - unit tests, for example. For all other scenarios, please call crc32c() and let it pick an implementation based on the capabilities of the underlying CPU.

Definition at line 292 of file Crc32cDetail.cpp.

Referenced by benchmarkHardwareCRC32C(), folly::crc32c(), and TEST().

292  {
293  throw std::runtime_error("crc32_hw is not implemented on this platform");
294 }
bool folly::detail::crc32c_hw_supported ( )

Check whether a hardware-accelerated CRC-32C implementation is supported on the current CPU.

Definition at line 83 of file Checksum.cpp.

Referenced by benchmarkHardwareCRC32C(), folly::crc32c(), and TEST().

83  {
84  return false;
85 }
uint32_t folly::detail::crc32c_sw ( const uint8_t data,
size_t  nbytes,
uint32_t  startingChecksum = ~0U 
)

Compute a CRC-32C checksum of a buffer using a portable, software-only implementation.

Note
This function is exposed to support special cases where the calling code is absolutely certain it wants to use the software implementation instead of the hardware-accelerated code - unit tests, for example. For all other scenarios, please call crc32c() and let it pick an implementation based on the capabilities of the underlying CPU.

Definition at line 115 of file Checksum.cpp.

References folly::data(), and uint32_t.

Referenced by benchmarkSoftwareCRC32C(), folly::crc32c(), and TEST().

115  {
116  constexpr uint32_t CRC32C_POLYNOMIAL = 0x1EDC6F41;
117  return crc_sw<CRC32C_POLYNOMIAL>(data, nbytes, startingChecksum);
118 }
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
template<uint32_t CRC_POLYNOMIAL>
uint32_t folly::detail::crc_sw ( const uint8_t data,
size_t  nbytes,
uint32_t  startingChecksum 
)

Definition at line 93 of file Checksum.cpp.

References sum(), and uint32_t.

93  {
94  // Reverse the bits in the starting checksum so they'll be in the
95  // right internal format for Boost's CRC engine.
96  // O(1)-time, branchless bit reversal algorithm from
97  // http://graphics.stanford.edu/~seander/bithacks.html
98  startingChecksum = ((startingChecksum >> 1) & 0x55555555) |
99  ((startingChecksum & 0x55555555) << 1);
100  startingChecksum = ((startingChecksum >> 2) & 0x33333333) |
101  ((startingChecksum & 0x33333333) << 2);
102  startingChecksum = ((startingChecksum >> 4) & 0x0f0f0f0f) |
103  ((startingChecksum & 0x0f0f0f0f) << 4);
104  startingChecksum = ((startingChecksum >> 8) & 0x00ff00ff) |
105  ((startingChecksum & 0x00ff00ff) << 8);
106  startingChecksum = (startingChecksum >> 16) | (startingChecksum << 16);
107 
108  boost::crc_optimal<32, CRC_POLYNOMIAL, ~0U, 0, true, true> sum(
109  startingChecksum);
110  sum.process_bytes(data, nbytes);
111  return sum.checksum();
112 }
std::atomic< int64_t > sum(0)
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
template<typename T , typename Tag , typename F >
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T* folly::detail::createGlobal ( F &&  creator)

Definition at line 70 of file StaticSingletonManager.h.

70  {
71  return StaticSingletonManager::create<T, Tag>(static_cast<F&&>(creator));
72 }
template<typename T , typename Tag >
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T* folly::detail::createGlobal ( )

Definition at line 75 of file StaticSingletonManager.h.

References folly::T.

75  {
76  return StaticSingletonManager::create<T, Tag>([]() { return new T(); });
77 }
#define T(v)
Definition: http_parser.c:233
std::memory_order folly::detail::default_failure_memory_order ( std::memory_order  successMode)
inline
char folly::detail::delimFront ( char  c)
inline

Definition at line 264 of file String-inl.h.

References c.

Referenced by internalJoinAppend(), and internalSplit().

264  {
265  // This one exists only for compile-time; it should never be called.
266  std::abort();
267  return c;
268 }
char c
char folly::detail::delimFront ( StringPiece  s)
inline

Definition at line 269 of file String-inl.h.

References folly::Range< Iter >::empty(), and folly::Range< Iter >::start().

269  {
270  assert(!s.empty() && s.start() != nullptr);
271  return *s.start();
272 }
static set< string > s
size_t folly::detail::delimSize ( char  )
inline

Definition at line 249 of file String-inl.h.

Referenced by internalJoin(), internalJoinAppend(), internalSplit(), and splitFixed().

249  {
250  return 1;
251 }
size_t folly::detail::delimSize ( StringPiece  s)
inline

Definition at line 252 of file String-inl.h.

References folly::Range< Iter >::size().

252  {
253  return s.size();
254 }
static set< string > s
template<class Tgt >
Expected<Tgt, ConversionCode> folly::detail::digits_to ( const char *  b,
const char *const  e 
)
inlinenoexcept

String represented as a pair of pointers to char to signed/unsigned integrals. Assumes NO whitespace before or after, and also that the string is composed entirely of digits (and an optional sign only for signed types). String may be empty, in which case digits_to returns an appropriate error.

Definition at line 533 of file Conv.cpp.

References b, folly::digits10(), digits_to< char >(), digits_to< int >(), digits_to< long >(), digits_to< long long >(), digits_to< short >(), digits_to< signed char >(), digits_to< unsigned char >(), digits_to< unsigned int >(), digits_to< unsigned long >(), digits_to< unsigned long long >(), digits_to< unsigned short >(), int32_t, folly::makeUnexpected(), folly::NO_DIGITS, folly::pushmi::__adl::noexcept(), folly::NON_DIGIT_CHAR, folly::size(), folly::SUCCESS, sum(), type, UNLIKELY, and value.

Referenced by folly::toAppendStrImpl().

535  {
536  using UT = typename std::make_unsigned<Tgt>::type;
537  assert(b <= e);
538 
539  SignedValueHandler<Tgt> sgn;
540 
541  auto err = sgn.init(b);
542  if (UNLIKELY(err != ConversionCode::SUCCESS)) {
543  return makeUnexpected(err);
544  }
545 
546  size_t size = size_t(e - b);
547 
548  /* Although the string is entirely made of digits, we still need to
549  * check for overflow.
550  */
552  // Leading zeros?
553  if (b < e && *b == '0') {
554  for (++b;; ++b) {
555  if (b == e) {
556  return Tgt(0); // just zeros, e.g. "0000"
557  }
558  if (*b != '0') {
559  size = size_t(e - b);
560  break;
561  }
562  }
563  }
565  (size != std::numeric_limits<UT>::digits10 + 1 ||
566  strncmp(b, MaxString<UT>::value, size) > 0)) {
567  return makeUnexpected(sgn.overflow());
568  }
569  }
570 
571  // Here we know that the number won't overflow when
572  // converted. Proceed without checks.
573 
574  UT result = 0;
575 
576  for (; e - b >= 4; b += 4) {
577  result *= static_cast<UT>(10000);
578  const int32_t r0 = shift1000[static_cast<size_t>(b[0])];
579  const int32_t r1 = shift100[static_cast<size_t>(b[1])];
580  const int32_t r2 = shift10[static_cast<size_t>(b[2])];
581  const int32_t r3 = shift1[static_cast<size_t>(b[3])];
582  const auto sum = r0 + r1 + r2 + r3;
583  if (sum >= OOR) {
584  goto outOfRange;
585  }
586  result += UT(sum);
587  }
588 
589  switch (e - b) {
590  case 3: {
591  const int32_t r0 = shift100[static_cast<size_t>(b[0])];
592  const int32_t r1 = shift10[static_cast<size_t>(b[1])];
593  const int32_t r2 = shift1[static_cast<size_t>(b[2])];
594  const auto sum = r0 + r1 + r2;
595  if (sum >= OOR) {
596  goto outOfRange;
597  }
598  result = UT(1000 * result + sum);
599  break;
600  }
601  case 2: {
602  const int32_t r0 = shift10[static_cast<size_t>(b[0])];
603  const int32_t r1 = shift1[static_cast<size_t>(b[1])];
604  const auto sum = r0 + r1;
605  if (sum >= OOR) {
606  goto outOfRange;
607  }
608  result = UT(100 * result + sum);
609  break;
610  }
611  case 1: {
612  const int32_t sum = shift1[static_cast<size_t>(b[0])];
613  if (sum >= OOR) {
614  goto outOfRange;
615  }
616  result = UT(10 * result + sum);
617  break;
618  }
619  default:
620  assert(b == e);
621  if (size == 0) {
622  return makeUnexpected(ConversionCode::NO_DIGITS);
623  }
624  break;
625  }
626 
627  return sgn.finalize(result);
628 
629 outOfRange:
630  return makeUnexpected(ConversionCode::NON_DIGIT_CHAR);
631 }
std::atomic< int64_t > sum(0)
char b
PskType type
uint32_t digits10(uint64_t v)
Definition: Conv.h:295
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
static const char *const value
Definition: Conv.cpp:50
#define UNLIKELY(x)
Definition: Likely.h:48
template Expected<char, ConversionCode> folly::detail::digits_to< char > ( const char *  ,
const char *   
)
noexcept
template Expected<int, ConversionCode> folly::detail::digits_to< int > ( const char *  ,
const char *   
)
noexcept
template Expected<long, ConversionCode> folly::detail::digits_to< long > ( const char *  ,
const char *   
)
noexcept
template Expected<long long, ConversionCode> folly::detail::digits_to< long long > ( const char *  ,
const char *   
)
noexcept
template Expected<short, ConversionCode> folly::detail::digits_to< short > ( const char *  ,
const char *   
)
noexcept
template Expected<signed char, ConversionCode> folly::detail::digits_to< signed char > ( const char *  ,
const char *   
)
noexcept
template Expected<unsigned char, ConversionCode> folly::detail::digits_to< unsigned char > ( const char *  ,
const char *   
)
noexcept
template Expected<unsigned int, ConversionCode> folly::detail::digits_to< unsigned int > ( const char *  ,
const char *   
)
noexcept
template Expected<unsigned long, ConversionCode> folly::detail::digits_to< unsigned long > ( const char *  ,
const char *   
)
noexcept
template Expected<unsigned long long, ConversionCode> folly::detail::digits_to< unsigned long long > ( const char *  ,
const char *   
)
noexcept
template Expected<unsigned short, ConversionCode> folly::detail::digits_to< unsigned short > ( const char *  ,
const char *   
)
noexcept
template<class Iterator >
int folly::detail::distance_if_multipass ( Iterator  first,
Iterator  last 
)

Definition at line 122 of file sorted_vector_types.h.

References value.

Referenced by bulk_insert().

122  {
123  typedef typename std::iterator_traits<Iterator>::iterator_category categ;
125  return -1;
126  }
127  return std::distance(first, last);
128 }
static const char *const value
Definition: Conv.cpp:50
constexpr detail::First first
Definition: Base-inl.h:2553
template<typename T >
constexpr T folly::detail::divCeilBranchful ( T  num,
T  denom 
)
inline

Definition at line 68 of file Math.h.

References value.

68  {
69  // First case handles negative or zero rational result, where trunc and ceil
70  // are the same.
71  // Second case handles positive result by preconditioning numerator.
72  // Preconditioning decreases the magnitude of the numerator, which is
73  // itself sign-dependent.
74  return (std::is_signed<T>::value && (num ^ denom) < 0) || num == 0
75  ? num / denom
76  : (num + (num > 0 ? -1 : 1)) / denom + 1;
77 }
static const char *const value
Definition: Conv.cpp:50
template<typename T >
constexpr T folly::detail::divCeilBranchless ( T  num,
T  denom 
)
inline

Definition at line 57 of file Math.h.

References value.

57  {
58  // ceil != trunc when the answer isn't exact (truncation occurred)
59  // and truncation went away from positive infinity. That happens when
60  // the true answer is positive, which happens when num and denom have
61  // the same sign.
62  return (num / denom) +
63  ((num % denom) != 0 ? 1 : 0) *
64  (std::is_signed<T>::value && (num ^ denom) < 0 ? 0 : 1);
65 }
static const char *const value
Definition: Conv.cpp:50
template<typename T >
constexpr T folly::detail::divFloorBranchful ( T  num,
T  denom 
)
inline

Definition at line 46 of file Math.h.

References value.

46  {
47  // First case handles negative result by preconditioning numerator.
48  // Preconditioning decreases the magnitude of the numerator, which is
49  // itself sign-dependent. Second case handles zero or positive rational
50  // result, where trunc and floor are the same.
51  return std::is_signed<T>::value && (num ^ denom) < 0 && num != 0
52  ? (num + (num > 0 ? -1 : 1)) / denom - 1
53  : num / denom;
54 }
static const char *const value
Definition: Conv.cpp:50
template<typename T >
constexpr T folly::detail::divFloorBranchless ( T  num,
T  denom 
)
inline

Definition at line 34 of file Math.h.

References value.

34  {
35  // floor != trunc when the answer isn't exact and truncation went the
36  // wrong way (truncation went toward positive infinity). That happens
37  // when the true answer is negative, which happens when num and denom
38  // have different signs. The following code compiles branch-free on
39  // many platforms.
40  return (num / denom) +
41  ((num % denom) != 0 ? 1 : 0) *
42  (std::is_signed<T>::value && (num ^ denom) < 0 ? -1 : 0);
43 }
static const char *const value
Definition: Conv.cpp:50
template<typename T >
constexpr T folly::detail::divRoundAwayBranchful ( T  num,
T  denom 
)
inline

Definition at line 91 of file Math.h.

References value.

91  {
92  // First case of second ternary operator handles negative rational
93  // result, which is the same as divFloor. Second case of second ternary
94  // operator handles positive result, which is the same as divCeil.
95  // Zero case is separated for simplicity.
96  return num == 0 ? 0
97  : (num + (num > 0 ? -1 : 1)) / denom +
98  (std::is_signed<T>::value && (num ^ denom) < 0 ? -1 : 1);
99 }
static const char *const value
Definition: Conv.cpp:50
template<typename T >
constexpr T folly::detail::divRoundAwayBranchless ( T  num,
T  denom 
)
inline

Definition at line 80 of file Math.h.

References value.

80  {
81  // away != trunc whenever truncation actually occurred, which is when
82  // there is a non-zero remainder. If the unrounded result is negative
83  // then fixup moves it toward negative infinity. If the unrounded
84  // result is positive then adjustment makes it larger.
85  return (num / denom) +
86  ((num % denom) != 0 ? 1 : 0) *
87  (std::is_signed<T>::value && (num ^ denom) < 0 ? -1 : 1);
88 }
static const char *const value
Definition: Conv.cpp:50
void folly::detail::double_radix_sort ( uint64_t  n,
uint64_t buckets,
double *  in,
double *  tmp 
)

Definition at line 83 of file DoubleRadixSort.cpp.

References double_radix_sort_rec().

Referenced by folly::TDigest::merge(), and TEST().

83  {
84  // If array is too small, use std::sort directly.
85  if (n < 700) {
86  std::sort(in, in + n);
87  } else {
88  detail::double_radix_sort_rec(n, buckets, 0, false, in, tmp);
89  }
90 }
static void double_radix_sort_rec(uint64_t n, uint64_t *buckets, uint8_t shift, bool inout, double *in, double *out)
static void folly::detail::double_radix_sort_rec ( uint64_t  n,
uint64_t buckets,
uint8_t  shift,
bool  inout,
double *  in,
double *  out 
)
static

Definition at line 36 of file DoubleRadixSort.cpp.

References getRadixBucket(), i, and uint64_t.

Referenced by double_radix_sort().

42  {
43  // First pass: calculate bucket counts.
44  memset(buckets, 0, 256 * sizeof(uint64_t));
45  for (uint64_t i = 0; i < n; i++) {
46  buckets[getRadixBucket(&in[i], shift)]++;
47  }
48 
49  // Second pass: calculate bucket start positions.
50  uint64_t tot = 0;
51  for (uint64_t i = 0; i < 256; i++) {
52  auto prev = tot;
53  tot += buckets[i];
54  buckets[i + 256] = prev;
55  }
56 
57  // Third pass: Move based on radix counts.
58  for (uint64_t i = 0; i < n; i++) {
59  auto pos = buckets[getRadixBucket(&in[i], shift) + 256]++;
60  out[pos] = in[i];
61  }
62 
63  // If we haven't used up all input bytes, recurse and sort. if the
64  // bucket is too small, use std::sort instead, and copy output to
65  // correct array.
66  if (shift < 56) {
67  tot = 0;
68  for (int i = 0; i < 256; i++) {
69  if (buckets[i] < 256) {
70  std::sort(out + tot, out + tot + buckets[i]);
71  if (!inout) {
72  memcpy(in + tot, out + tot, buckets[i] * sizeof(double));
73  }
74  } else {
76  buckets[i], buckets + 256, shift + 8, !inout, out + tot, in + tot);
77  }
78  tot += buckets[i];
79  }
80  }
81 }
static uint8_t getRadixBucket(double *f, uint8_t shift)
static void double_radix_sort_rec(uint64_t n, uint64_t *buckets, uint8_t shift, bool inout, double *in, double *out)
template<class T , class U >
std::enable_if<HasLess<U, T>::value, bool>::type folly::detail::downTo ( T iter,
const U &  begin 
)

downTo is similar to notThereYet, but in reverse - it helps the FOR_EACH_RANGE_R macro.

Definition at line 287 of file Foreach.h.

289  {
290  return begin < iter--;
291 }
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
template<class T , class U >
std::enable_if<!HasLess<U, T>::value, bool>::type folly::detail::downTo ( T iter,
const U &  begin 
)

Definition at line 294 of file Foreach.h.

296  {
297  if (iter == begin) {
298  return false;
299  }
300  --iter;
301  return true;
302 }
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
template<typename SubsecondRatio , typename Rep >
static Expected<std::pair<time_t, long>, ConversionCode> folly::detail::durationToPosixTime ( const std::chrono::duration< Rep, std::ratio< 1, 1 >> &  duration)
static

Convert a std::chrono::duration with second granularity to a pair of (seconds, subseconds)

The SubsecondRatio template parameter specifies what type of subseconds to return. This must have a numerator of 1.

Definition at line 96 of file Conv.h.

References chronoRangeCheck(), folly::makeUnexpected(), folly::NEGATIVE_OVERFLOW, and value.

97  {
98  static_assert(
99  SubsecondRatio::num == 1, "subsecond numerator should always be 1");
100 
101  auto sec = chronoRangeCheck(duration.count());
102  if (sec.hasError()) {
103  return makeUnexpected(sec.error());
104  }
105 
106  time_t secValue = sec.value();
107  long subsec = 0L;
109  auto fraction = (duration.count() - secValue);
110  subsec = static_cast<long>(fraction * SubsecondRatio::den);
111  if (duration.count() < 0 && fraction < 0) {
112  if (secValue == std::numeric_limits<time_t>::lowest()) {
113  return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
114  }
115  secValue -= 1;
116  subsec += SubsecondRatio::den;
117  }
118  }
119  return std::pair<time_t, long>{secValue, subsec};
120 }
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
static const char *const value
Definition: Conv.cpp:50
Expected< time_t, ConversionCode > chronoRangeCheck(Src value)
Definition: Conv.h:75
template<typename SubsecondRatio , typename Rep , std::intmax_t Denominator>
static Expected<std::pair<time_t, long>, ConversionCode> folly::detail::durationToPosixTime ( const std::chrono::duration< Rep, std::ratio< 1, Denominator >> &  duration)
static

Convert a std::chrono::duration with subsecond granularity to a pair of (seconds, subseconds)

Definition at line 127 of file Conv.h.

References chronoRangeCheck(), folly::makeUnexpected(), folly::NEGATIVE_OVERFLOW, and UNLIKELY.

128  {
129  static_assert(Denominator != 1, "special case expecting den != 1");
130  static_assert(
131  SubsecondRatio::num == 1, "subsecond numerator should always be 1");
132 
133  auto sec = chronoRangeCheck(duration.count() / Denominator);
134  if (sec.hasError()) {
135  return makeUnexpected(sec.error());
136  }
137  auto secTimeT = sec.value();
138 
139  auto remainder = duration.count() - (secTimeT * Denominator);
140  auto subsec = (remainder * SubsecondRatio::den) / Denominator;
141  if (UNLIKELY(duration.count() < 0) && remainder != 0) {
142  if (secTimeT == std::numeric_limits<time_t>::lowest()) {
143  return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
144  }
145  secTimeT -= 1;
146  subsec += SubsecondRatio::den;
147  }
148 
149  return std::pair<time_t, long>{secTimeT, subsec};
150 }
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
Expected< time_t, ConversionCode > chronoRangeCheck(Src value)
Definition: Conv.h:75
#define UNLIKELY(x)
Definition: Likely.h:48
template<typename SubsecondRatio , typename Rep , std::intmax_t Numerator>
static Expected<std::pair<time_t, long>, ConversionCode> folly::detail::durationToPosixTime ( const std::chrono::duration< Rep, std::ratio< Numerator, 1 >> &  duration)
static

Convert a std::chrono::duration with coarser-than-second granularity to a pair of (seconds, subseconds)

Definition at line 157 of file Conv.h.

References folly::makeUnexpected(), max, folly::NEGATIVE_OVERFLOW, folly::POSITIVE_OVERFLOW, and value.

158  {
159  static_assert(Numerator != 1, "special case expecting num!=1");
160  static_assert(
161  SubsecondRatio::num == 1, "subsecond numerator should always be 1");
162 
163  constexpr auto maxValue = std::numeric_limits<time_t>::max() / Numerator;
164  constexpr auto minValue = std::numeric_limits<time_t>::lowest() / Numerator;
165  if (duration.count() > maxValue) {
166  return makeUnexpected(ConversionCode::POSITIVE_OVERFLOW);
167  }
168  if (duration.count() < minValue) {
169  return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
170  }
171 
172  // Note that we can't use chronoRangeCheck() here since we have to check
173  // if (duration.count() * Numerator) would overflow (which we do above).
174  auto secOriginalRep = (duration.count() * Numerator);
175  auto sec = static_cast<time_t>(secOriginalRep);
176 
177  long subsec = 0L;
179  auto fraction = secOriginalRep - sec;
180  subsec = static_cast<long>(fraction * SubsecondRatio::den);
181  if (duration.count() < 0 && fraction < 0) {
182  if (sec == std::numeric_limits<time_t>::lowest()) {
183  return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
184  }
185  sec -= 1;
186  subsec += SubsecondRatio::den;
187  }
188  }
189  return std::pair<time_t, long>{sec, subsec};
190 }
LogLevel max
Definition: LogLevel.cpp:31
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
static const char *const value
Definition: Conv.cpp:50
template<typename SubsecondRatio , typename Rep , typename Period >
Expected<std::pair<time_t, long>, ConversionCode> folly::detail::durationToPosixTime ( const std::chrono::duration< Rep, Period > &  duration)

Convert a std::chrono::duration to a pair of (seconds, subseconds)

This overload is only used for unusual durations where neither the numerator nor denominator are 1.

Definition at line 229 of file Conv.h.

References folly::makeUnexpected(), max, min, folly::NEGATIVE_OVERFLOW, and folly::POSITIVE_OVERFLOW.

230  {
231  static_assert(Period::num != 1, "should use special-case code when num==1");
232  static_assert(Period::den != 1, "should use special-case code when den==1");
233  static_assert(
234  SubsecondRatio::num == 1, "subsecond numerator should always be 1");
235 
236  // Perform this conversion by first converting to a duration where the
237  // numerator is 1, then convert to the output type.
238  using IntermediateType = IntermediateDuration<Rep, Period>;
239  using IntermediateRep = typename IntermediateType::rep;
240 
241  // Check to see if we would have overflow converting to the intermediate
242  // type.
243  constexpr auto maxInput =
245  if (duration.count() > maxInput) {
246  return makeUnexpected(ConversionCode::POSITIVE_OVERFLOW);
247  }
248  constexpr auto minInput =
250  if (duration.count() < minInput) {
251  return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
252  }
253  auto intermediate =
254  IntermediateType{static_cast<IntermediateRep>(duration.count()) *
255  static_cast<IntermediateRep>(Period::num)};
256 
257  return durationToPosixTime<SubsecondRatio>(intermediate);
258 }
LogLevel max
Definition: LogLevel.cpp:31
LogLevel min
Definition: LogLevel.cpp:30
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
void folly::detail::enforceWhitespace ( StringPiece  sp)
inline

Keep this implementation around for prettyToDouble().

Definition at line 130 of file Conv.h.

References enforceWhitespaceErr(), folly::makeConversionError(), folly::SUCCESS, folly::throw_exception(), type, and folly::value().

Referenced by folly::prettyToDouble().

130  {
131  auto err = enforceWhitespaceErr(sp);
132  if (err != ConversionCode::SUCCESS) {
134  }
135 }
ConversionCode enforceWhitespaceErr(StringPiece sp)
Definition: Conv.h:118
FOLLY_NOINLINE FOLLY_COLD void throw_exception(Ex &&ex)
Definition: Exception.h:32
ConversionError makeConversionError(ConversionCode code, StringPiece input)
Definition: Conv.cpp:765
ConversionCode folly::detail::enforceWhitespaceErr ( StringPiece  sp)
inline

Enforce that the suffix following a number is made up only of whitespace.

Definition at line 118 of file Conv.h.

References c, folly::NON_WHITESPACE_AFTER_END, folly::SUCCESS, and UNLIKELY.

Referenced by enforceWhitespace(), and folly::detail::CheckTrailingSpace::operator()().

118  {
119  for (auto c : sp) {
120  if (UNLIKELY(!std::isspace(c))) {
121  return ConversionCode::NON_WHITESPACE_AFTER_END;
122  }
123  }
124  return ConversionCode::SUCCESS;
125 }
#define UNLIKELY(x)
Definition: Likely.h:48
char c
template<typename Tgt , typename Src >
std::string folly::detail::errorValue ( const Src &  value)
inline

Definition at line 1337 of file Conv.h.

References folly::demangle(), value, and folly::value().

1337  {
1338 #ifdef FOLLY_HAS_RTTI
1339  return to<std::string>("(", demangle(typeid(Tgt)), ") ", value);
1340 #else
1341  return to<std::string>(value);
1342 #endif
1343 }
static const char *const value
Definition: Conv.cpp:50
fbstring demangle(const char *name)
Definition: Demangle.cpp:111
QuantileEstimates folly::detail::estimatesFromDigest ( const TDigest digest,
Range< const double * >  quantiles 
)

Definition at line 22 of file QuantileEstimator.cpp.

References folly::Range< Iter >::begin(), folly::QuantileEstimates::count, folly::TDigest::count(), folly::Range< Iter >::end(), folly::TDigest::estimateQuantile(), folly::QuantileEstimates::quantiles, folly::Range< Iter >::size(), folly::QuantileEstimates::sum, and folly::TDigest::sum().

Referenced by folly::SimpleQuantileEstimator< ClockT >::estimateQuantiles(), and folly::SlidingWindowQuantileEstimator< ClockT >::estimateQuantiles().

24  {
25  QuantileEstimates result;
26  result.quantiles.reserve(quantiles.size());
27  result.sum = digest.sum();
28  result.count = digest.count();
29  for (auto it = quantiles.begin(); it != quantiles.end(); ++it) {
30  result.quantiles.push_back(
31  std::make_pair(*it, digest.estimateQuantile(*it)));
32  }
33  return result;
34 }
template<class... KeysDefault>
auto folly::detail::extract_default ( const KeysDefault &...  keysDefault) -> typename DefaultType<KeysDefault...>::type const&

Definition at line 213 of file MapUtil.h.

References folly::pushmi::operators::get.

Referenced by folly::get_default(), and folly::get_ref_default().

214  {
215  return std::get<sizeof...(KeysDefault) - 1>(std::tie(keysDefault...));
216 }
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
Definition: submit.h:391
template<typename Arg >
auto folly::detail::fallbackFormatOneArg ( std::string str,
const Arg *  arg,
int   
) -> decltype( toAppend(std::declval<Arg>(), std::declval<std::string*>()), std::declval<void>())

Definition at line 42 of file LogStreamProcessor.h.

References folly::demangle(), and folly::toAppend().

Referenced by folly::LogStreamProcessor::fallbackFormat().

44  {
45  str->push_back('(');
46  try {
47 #ifdef FOLLY_HAS_RTTI
48  toAppend(folly::demangle(typeid(*arg)), str);
49  str->append(": ");
50 #endif
51  toAppend(*arg, str);
52  } catch (const std::exception&) {
53  str->append("<error_converting_to_string>");
54  }
55  str->push_back(')');
56 }
void toAppend(char value, Tgt *result)
Definition: Conv.h:406
fbstring demangle(const char *name)
Definition: Demangle.cpp:111
template<typename Arg >
void folly::detail::fallbackFormatOneArg ( std::string str,
const Arg *  arg,
long   
)
inline

Definition at line 59 of file LogStreamProcessor.h.

References folly::demangle(), and folly::toAppend().

59  {
60  str->push_back('(');
61 #ifdef FOLLY_HAS_RTTI
62  try {
63  toAppend(folly::demangle(typeid(*arg)), str);
64  str->append(": ");
65  } catch (const std::exception&) {
66  // Ignore the error
67  }
68 #endif
69  str->append("<no_string_conversion>)");
70 }
void toAppend(char value, Tgt *result)
Definition: Conv.h:406
fbstring demangle(const char *name)
Definition: Demangle.cpp:111
std::string folly::detail::familyNameStr ( sa_family_t  family)
inline

Definition at line 30 of file IPAddress.h.

References familyNameStrDefault(), and getNthMSBitImplThrow().

Referenced by getNthMSBitImplThrow(), folly::IPAddressV4::getNthMSByte(), folly::IPAddressV6::getNthMSByte(), folly::operator<(), and folly::toAppend().

30  {
31  switch (family) {
32  case AF_INET:
33  return "AF_INET";
34  case AF_INET6:
35  return "AF_INET6";
36  case AF_UNSPEC:
37  return "AF_UNSPEC";
38  case AF_UNIX:
39  return "AF_UNIX";
40  default:
41  return familyNameStrDefault(family);
42  }
43 }
std::string familyNameStrDefault(sa_family_t family)
Definition: IPAddress.cpp:24
std::string folly::detail::familyNameStrDefault ( sa_family_t  family)

Definition at line 24 of file IPAddress.cpp.

References folly::sformat().

Referenced by familyNameStr().

24  {
25  return sformat("sa_family_t({})", family);
26 }
std::string sformat(StringPiece fmt, Args &&...args)
Definition: Format.h:280
void folly::detail::fastIpv4AppendToString ( const in_addr &  inAddr,
std::string out 
)
inline

Definition at line 239 of file IPAddressSource.h.

References fastIpV4ToBufferUnsafe().

Referenced by folly::IPAddressV4::toFullyQualifiedAppend().

239  {
240  char str[sizeof("255.255.255.255")];
241  out.append(str, fastIpV4ToBufferUnsafe(inAddr, str));
242 }
size_t fastIpV4ToBufferUnsafe(const in_addr &inAddr, char *str)
size_t folly::detail::fastIpV4ToBufferUnsafe ( const in_addr &  inAddr,
char *  str 
)
inline

Definition at line 219 of file IPAddressSource.h.

References uint8_t.

Referenced by fastIpv4AppendToString(), and fastIpv4ToString().

219  {
220  const uint8_t* octets = reinterpret_cast<const uint8_t*>(&inAddr.s_addr);
221  char* buf = str;
222 
223  writeIntegerString<uint8_t, 3>(octets[0], &buf);
224  *(buf++) = '.';
225  writeIntegerString<uint8_t, 3>(octets[1], &buf);
226  *(buf++) = '.';
227  writeIntegerString<uint8_t, 3>(octets[2], &buf);
228  *(buf++) = '.';
229  writeIntegerString<uint8_t, 3>(octets[3], &buf);
230 
231  return buf - str;
232 }
std::string folly::detail::fastIpv4ToString ( const in_addr &  inAddr)
inline

Definition at line 234 of file IPAddressSource.h.

References fastIpV4ToBufferUnsafe(), and string.

Referenced by folly::IPAddressV4::str(), and TEST().

234  {
235  char str[sizeof("255.255.255.255")];
236  return std::string(str, fastIpV4ToBufferUnsafe(inAddr, str));
237 }
const char * string
Definition: Conv.cpp:212
size_t fastIpV4ToBufferUnsafe(const in_addr &inAddr, char *str)
void folly::detail::fastIpv6AppendToString ( const in6_addr &  in6Addr,
std::string out 
)
inline

Definition at line 272 of file IPAddressSource.h.

References fastIpv6ToBufferUnsafe().

Referenced by folly::IPAddressV6::toFullyQualifiedAppend().

272  {
273  char str[sizeof("2001:0db8:0000:0000:0000:ff00:0042:8329")];
274  out.append(str, fastIpv6ToBufferUnsafe(in6Addr, str));
275 }
size_t fastIpv6ToBufferUnsafe(const in6_addr &in6Addr, char *str)
size_t folly::detail::fastIpv6ToBufferUnsafe ( const in6_addr &  in6Addr,
char *  str 
)
inline

Definition at line 244 of file IPAddressSource.h.

References i, uint16_t, and writeIntegerString().

Referenced by fastIpv6AppendToString(), and fastIpv6ToString().

244  {
245 #ifdef _MSC_VER
246  const uint16_t* bytes = reinterpret_cast<const uint16_t*>(&in6Addr.u.Word);
247 #else
248  const uint16_t* bytes = reinterpret_cast<const uint16_t*>(&in6Addr.s6_addr16);
249 #endif
250  char* buf = str;
251 
252  for (int i = 0; i < 8; ++i) {
254  uint16_t,
255  4, // at most 4 hex digits per ushort
256  16, // base 16 (hex)
257  true>(htons(bytes[i]), &buf);
258 
259  if (i != 7) {
260  *(buf++) = ':';
261  }
262  }
263 
264  return buf - str;
265 }
void writeIntegerString(IntegralType val, char **buffer)
std::string folly::detail::fastIpv6ToString ( const in6_addr &  in6Addr)
inline

Definition at line 267 of file IPAddressSource.h.

References fastIpv6ToBufferUnsafe(), and string.

Referenced by TEST(), and folly::IPAddressV6::toFullyQualified().

267  {
268  char str[sizeof("2001:0db8:0000:0000:0000:ff00:0042:8329")];
269  return std::string(str, fastIpv6ToBufferUnsafe(in6Addr, str));
270 }
size_t fastIpv6ToBufferUnsafe(const in6_addr &in6Addr, char *str)
const char * string
Definition: Conv.cpp:212
folly::detail::FOLLY_CREATE_MEMBER_INVOKE_TRAITS ( AllocatorConstruct_  ,
construct   
)
folly::detail::FOLLY_CREATE_MEMBER_INVOKE_TRAITS ( AllocatorDestroy_  ,
destroy   
)
FOLLY_PUSH_WARNING folly::detail::FOLLY_MSVC_DISABLE_WARNING ( 4388  )
template<typename Futex >
FutexResult folly::detail::futexWait ( const Futex futex,
uint32_t  expected,
uint32_t  waitMask = -1 
)

Puts the thread to sleep if this->load() == expected. Returns true when it is returning because it has consumed a wake() event, false for any other return (signal, this->load() != expected, or spurious wakeup).

Definition at line 100 of file Futex-inl.h.

References futexWaitImpl(), and TIMEDOUT.

Referenced by folly::detail::atomic_notification::atomic_wait_impl(), BENCHMARK(), folly::detail::distributed_mutex::doFutexWait(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::WaitForever::doWait(), folly::detail::MemoryIdler::futexWait(), folly::MicroLockCore::lockSlowPath(), MockAtom< T >::MockAtom(), run_basic_tests(), run_basic_thread(), run_wake_blocked_test(), folly::RelaxedConcurrentPriorityQueue< T, MayBlock, SupportsSize, PopBatch, ListTargetSize, Mutex, Atom >::tryBlockingPop(), folly::detail::TurnSequencer< std::atomic >::tryWaitForTurn(), folly::EventCount::wait(), and folly::detail::ThreadCachedInts< folly::detail::folly::detail::Tag >::waitForZero().

100  {
101  auto rv = futexWaitImpl(futex, expected, nullptr, nullptr, waitMask);
102  assert(rv != FutexResult::TIMEDOUT);
103  return rv;
104 }
std::enable_if<!Deadline::clock::is_steady, FutexResult >::type futexWaitImpl(Futex *futex, uint32_t expected, Deadline const &deadline, uint32_t waitMask)
Definition: Futex-inl.h:90
FutexResult folly::detail::futexWaitImpl ( const Futex< std::atomic > *  futex,
uint32_t  expected,
std::chrono::system_clock::time_point const *  absSystemTime,
std::chrono::steady_clock::time_point const *  absSteadyTime,
uint32_t  waitMask 
)
FutexResult folly::detail::futexWaitImpl ( const Futex< EmulatedFutexAtomic > *  futex,
uint32_t  expected,
std::chrono::system_clock::time_point const *  absSystemTime,
std::chrono::steady_clock::time_point const *  absSteadyTime,
uint32_t  waitMask 
)
template<typename Futex , typename Deadline >
std::enable_if<Deadline::clock::is_steady, FutexResult>::type folly::detail::futexWaitImpl ( Futex futex,
uint32_t  expected,
Deadline const &  deadline,
uint32_t  waitMask 
)

Definition at line 80 of file Futex-inl.h.

References futexWaitImpl(), and type.

84  {
85  return futexWaitImpl(futex, expected, nullptr, &deadline, waitMask);
86 }
std::enable_if<!Deadline::clock::is_steady, FutexResult >::type futexWaitImpl(Futex *futex, uint32_t expected, Deadline const &deadline, uint32_t waitMask)
Definition: Futex-inl.h:90
template<typename Futex , typename Deadline >
std::enable_if<!Deadline::clock::is_steady, FutexResult>::type folly::detail::futexWaitImpl ( Futex futex,
uint32_t  expected,
Deadline const &  deadline,
uint32_t  waitMask 
)

Definition at line 90 of file Futex-inl.h.

References futexWaitImpl().

94  {
95  return futexWaitImpl(futex, expected, &deadline, nullptr, waitMask);
96 }
std::enable_if<!Deadline::clock::is_steady, FutexResult >::type futexWaitImpl(Futex *futex, uint32_t expected, Deadline const &deadline, uint32_t waitMask)
Definition: Futex-inl.h:90
FutexResult folly::detail::futexWaitImpl ( const Futex< std::atomic > *  futex,
uint32_t  expected,
system_clock::time_point const *  absSystemTime,
steady_clock::time_point const *  absSteadyTime,
uint32_t  waitMask 
)

Definition at line 245 of file Futex.cpp.

250  {
251 #ifdef __linux__
252  return nativeFutexWaitImpl(
253  futex, expected, absSystemTime, absSteadyTime, waitMask);
254 #else
255  return emulatedFutexWaitImpl(
256  futex, expected, absSystemTime, absSteadyTime, waitMask);
257 #endif
258 }
FutexResult folly::detail::futexWaitImpl ( const Futex< EmulatedFutexAtomic > *  futex,
uint32_t  expected,
system_clock::time_point const *  absSystemTime,
steady_clock::time_point const *  absSteadyTime,
uint32_t  waitMask 
)

Definition at line 260 of file Futex.cpp.

265  {
266  return emulatedFutexWaitImpl(
267  futex, expected, absSystemTime, absSteadyTime, waitMask);
268 }
template<typename Futex , class Clock , class Duration >
FutexResult folly::detail::futexWaitUntil ( const Futex futex,
uint32_t  expected,
std::chrono::time_point< Clock, Duration > const &  deadline,
uint32_t  waitMask = -1 
)

Similar to futexWait but also accepts a deadline until when the wait call may block.

Optimal clock types: std::chrono::system_clock, std::chrono::steady_clock. NOTE: On some systems steady_clock is just an alias for system_clock, and is not actually steady.

For any other clock type, now() will be invoked twice.

Definition at line 112 of file Futex-inl.h.

References futexWaitImpl(), max, and type.

Referenced by folly::detail::atomic_notification::atomic_wait_until_impl(), folly::DynamicBoundedQueue< T, SingleProducer, SingleConsumer, MayBlock, LgSegmentSize, LgAlign, WeightFn, Atom >::canEnqueue(), deterministicAtomicWaitUntilTests(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::WaitForDuration< Rep, Period >::doWait(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::WaitUntilDeadline< Clock, Duration >::doWait(), folly::detail::MemoryIdler::futexWaitPreIdle(), folly::detail::MemoryIdler::futexWaitUntil(), liveClockWaitUntilTests(), MockAtom< T >::MockAtom(), TEST(), and folly::detail::TurnSequencer< std::atomic >::tryWaitForTurn().

116  {
117  using Target = typename std::conditional<
118  Clock::is_steady,
119  std::chrono::steady_clock,
120  std::chrono::system_clock>::type;
121  auto const converted = time_point_conv<Target>(deadline);
122  return converted == Target::time_point::max()
123  ? futexWaitImpl(futex, expected, nullptr, nullptr, waitMask)
124  : futexWaitImpl(futex, expected, converted, waitMask);
125 }
LogLevel max
Definition: LogLevel.cpp:31
PskType type
std::enable_if<!Deadline::clock::is_steady, FutexResult >::type futexWaitImpl(Futex *futex, uint32_t expected, Deadline const &deadline, uint32_t waitMask)
Definition: Futex-inl.h:90
template<typename Futex >
int folly::detail::futexWake ( const Futex futex,
int  count = std::numeric_limits< int >::max(),
uint32_t  wakeMask = -1 
)

Wakes up to count waiters where (waitMask & wakeMask) != 0, returning the number of awoken threads, or -1 if an error occurred. Note that when constructing a concurrency primitive that can guard its own destruction, it is likely that you will want to ignore EINVAL here (as well as making sure that you never touch the object after performing the memory store that is the linearization point for unlock or control handoff). See https://sourceware.org/bugzilla/show_bug.cgi?id=13690

Definition at line 107 of file Futex-inl.h.

References futexWakeImpl().

Referenced by folly::detail::atomic_notification::atomic_notify_all_impl(), folly::detail::atomic_notification::atomic_notify_one_impl(), BENCHMARK(), folly::RelaxedConcurrentPriorityQueue< T, MayBlock, SupportsSize, PopBatch, ListTargetSize, Mutex, Atom >::blockingPushImpl(), folly::detail::TurnSequencer< std::atomic >::completeTurn(), folly::detail::ThreadCachedInts< folly::detail::folly::detail::Tag >::decrement(), folly::detail::distributed_mutex::doFutexWake(), folly::EventCount::doNotify(), folly::SharedMutexImpl< true >::futexWakeAll(), liveClockWaitUntilTests(), folly::Baton< MayBlock, Atom >::post(), folly::SaturatingSemaphore< MayBlock, Atom >::postSlowWaiterMayBlock(), folly::fibers::Baton::postThread(), run_basic_tests(), run_wake_blocked_test(), folly::DynamicBoundedQueue< T, SingleProducer, SingleConsumer, MayBlock, LgSegmentSize, LgAlign, WeightFn, Atom >::transferCredit(), folly::MicroLockCore::unlock(), folly::SharedMutexImpl< true >::wakeRegisteredWaitersImpl(), and folly::detail::ThreadCachedInts< Tag >::Integer::~Integer().

107  {
108  return futexWakeImpl(futex, count, wakeMask);
109 }
int futexWakeImpl(const Futex< EmulatedFutexAtomic > *futex, int count, uint32_t wakeMask)
Definition: Futex.cpp:238
int * count
int folly::detail::futexWakeImpl ( const Futex< std::atomic > *  futex,
int  count,
uint32_t  wakeMask 
)

Available overloads, with definitions elsewhere

These functions are treated as ADL-extension points, the templates above call these functions without them having being pre-declared. This works because ADL lookup finds the definitions of these functions when you pass the relevant arguments

Definition at line 227 of file Futex.cpp.

Referenced by futexWake(), and time_point_conv().

230  {
231 #ifdef __linux__
232  return nativeFutexWake(futex, count, wakeMask);
233 #else
234  return emulatedFutexWake(futex, count, wakeMask);
235 #endif
236 }
int * count
int folly::detail::futexWakeImpl ( const Futex< EmulatedFutexAtomic > *  futex,
int  count,
uint32_t  wakeMask 
)

Definition at line 238 of file Futex.cpp.

241  {
242  return emulatedFutexWake(futex, count, wakeMask);
243 }
int * count
template<typename... Ts>
auto folly::detail::getLastElement ( const Ts &...  ts) -> decltype(LastElementImpl<Ts...>::call(ts...))

Definition at line 232 of file Conv.h.

References folly::detail::LastElementImpl< Ts >::call().

Referenced by folly::reserveInTargetDelim(), folly::to(), and folly::toAppendStrImpl().

233  {
234  return LastElementImpl<Ts...>::call(ts...);
235 }
Future< bool > call(int depth, Executor *executor)
template<typename IPAddrType >
bool folly::detail::getNthMSBitImpl ( const IPAddrType &  ip,
size_t  bitIndex,
sa_family_t  family 
)
inline

Definition at line 49 of file IPAddress.h.

References getNthMSBitImplThrow().

Referenced by folly::IPAddressV4::getNthMSBit(), and folly::IPAddressV6::getNthMSBit().

49  {
50  if (bitIndex >= ip.bitCount()) {
51  getNthMSBitImplThrow(ip.bitCount(), family);
52  }
53  // Underlying bytes are in n/w byte order
54  return (ip.getNthMSByte(bitIndex / 8) & (0x80 >> (bitIndex % 8))) != 0;
55 }
void getNthMSBitImplThrow(size_t bitCount, sa_family_t family)
Definition: IPAddress.cpp:28
void folly::detail::getNthMSBitImplThrow ( size_t  bitCount,
sa_family_t  family 
)

Definition at line 28 of file IPAddress.cpp.

References familyNameStr(), and folly::sformat().

Referenced by familyNameStr(), and getNthMSBitImpl().

28  {
29  throw std::invalid_argument(sformat(
30  "Bit index must be < {} for addresses of type: {}",
31  bitCount,
32  familyNameStr(family)));
33 }
std::string sformat(StringPiece fmt, Args &&...args)
Definition: Format.h:280
std::string familyNameStr(sa_family_t family)
Definition: IPAddress.h:30
template<class Iterator >
FOLLY_ALWAYS_INLINE auto folly::detail::getPointer ( const Iterator &  it,
long   
) -> decltype(std::addressof(*it))

Definition at line 68 of file Enumerate.h.

Referenced by folly::detail::Enumerator< Iterator >::Proxy::operator->().

69  {
70  return std::addressof(*it);
71 }
template<class Iterator >
FOLLY_ALWAYS_INLINE auto folly::detail::getPointer ( const Iterator &  it,
int   
) -> decltype(it.operator->())

Definition at line 73 of file Enumerate.h.

74  {
75  return it.operator->();
76 }
static uint8_t folly::detail::getRadixBucket ( double *  f,
uint8_t  shift 
)
static

Definition at line 27 of file DoubleRadixSort.cpp.

References int64_t, uint64_t, and val.

Referenced by double_radix_sort_rec().

27  {
28  uint64_t val;
29  memcpy(&val, f, sizeof(double));
30  uint64_t mask = -int64_t(val >> 63) | 0x8000000000000000;
31  auto adjusted = val ^ mask;
32  return (adjusted >> (64 - 8 - shift)) & 0xFF;
33 }
auto f
double val
Definition: String.cpp:273
std::shared_ptr< Timekeeper > folly::detail::getTimekeeperSingleton ( )

Definition at line 159 of file ThreadWheelTimekeeper.cpp.

Referenced by folly::futures::sleep(), and folly::futures::detail::FutureBase< T >::withinImplementation().

159  {
160  return timekeeperSingleton_.try_get();
161 }
template<typename RHS , RHS rhs, typename LHS >
bool folly::detail::greater_than_impl ( LHS const  lhs)

Definition at line 660 of file Traits.h.

660  {
661  // clang-format off
662  return
663  rhs > std::numeric_limits<LHS>::max() ? false :
665  lhs > rhs;
666  // clang-format on
667 }
LogLevel max
Definition: LogLevel.cpp:31
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
LogLevel min
Definition: LogLevel.cpp:30
void folly::detail::handleMallctlError ( const char *  cmd,
int  err 
)

Definition at line 27 of file MallctlHelper.cpp.

References folly::errnoStr(), and folly::sformat().

Referenced by mallctlHelper().

27  {
28  assert(err != 0);
29  throw std::runtime_error(
30  sformat("mallctl {}: {} ({})", cmd, errnoStr(err), err));
31 }
std::string sformat(StringPiece fmt, Args &&...args)
Definition: Format.h:280
fbstring errnoStr(int err)
Definition: String.cpp:463
cmd
Definition: gtest-cfgcmd.txt:1
constexpr int folly::detail::hazptr_domain_rcount_threshold ( )

Definition at line 38 of file HazptrDomain.h.

References Atom.

Referenced by TEST().

38  {
39  return 1000;
40 }
size_t folly::detail::hexDumpLine ( const void *  ptr,
size_t  offset,
size_t  size,
std::string line 
)

Hex-dump at most 16 bytes starting at offset from a memory area of size bytes. Return the number of bytes actually dumped.

Definition at line 651 of file String.cpp.

References c, i, min, ptr, and uint8_t.

Referenced by folly::hexDump(), and folly::unhexlify().

651  {
652  static char hexValues[] = "0123456789abcdef";
653  // Line layout:
654  // 8: address
655  // 1: space
656  // (1+2)*16: hex bytes, each preceded by a space
657  // 1: space separating the two halves
658  // 3: " |"
659  // 16: characters
660  // 1: "|"
661  // Total: 78
662  line.clear();
663  line.reserve(78);
664  const uint8_t* p = reinterpret_cast<const uint8_t*>(ptr) + offset;
665  size_t n = std::min(size - offset, size_t(16));
666  line.push_back(hexValues[(offset >> 28) & 0xf]);
667  line.push_back(hexValues[(offset >> 24) & 0xf]);
668  line.push_back(hexValues[(offset >> 20) & 0xf]);
669  line.push_back(hexValues[(offset >> 16) & 0xf]);
670  line.push_back(hexValues[(offset >> 12) & 0xf]);
671  line.push_back(hexValues[(offset >> 8) & 0xf]);
672  line.push_back(hexValues[(offset >> 4) & 0xf]);
673  line.push_back(hexValues[offset & 0xf]);
674  line.push_back(' ');
675 
676  for (size_t i = 0; i < n; i++) {
677  if (i == 8) {
678  line.push_back(' ');
679  }
680 
681  line.push_back(' ');
682  line.push_back(hexValues[(p[i] >> 4) & 0xf]);
683  line.push_back(hexValues[p[i] & 0xf]);
684  }
685 
686  // 3 spaces for each byte we're not printing, one separating the halves
687  // if necessary
688  line.append(3 * (16 - n) + (n <= 8), ' ');
689  line.append(" |");
690 
691  for (size_t i = 0; i < n; i++) {
692  char c = (p[i] >= 32 && p[i] <= 126 ? static_cast<char>(p[i]) : '.');
693  line.push_back(c);
694  }
695  line.append(16 - n, ' ');
696  line.push_back('|');
697  DCHECK_EQ(line.size(), 78u);
698 
699  return n;
700 }
void * ptr
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
LogLevel min
Definition: LogLevel.cpp:30
char c
template<class OurContainer , class Vector , class GrowthPolicy >
OurContainer::iterator folly::detail::insert_with_hint ( OurContainer &  sorted,
Vector &  cont,
typename OurContainer::iterator  hint,
typename OurContainer::value_type &&  value,
GrowthPolicy &  po 
)

Definition at line 131 of file sorted_vector_types.h.

References folly::gen::move, and folly::value().

Referenced by folly::sorted_vector_set< folly::RequestData * >::insert(), and folly::sorted_vector_map< Key, Value, Compare, Allocator, GrowthPolicy, Container >::insert().

136  {
137  const typename OurContainer::value_compare& cmp(sorted.value_comp());
138  if (hint == cont.end() || cmp(value, *hint)) {
139  if (hint == cont.begin() || cmp(*(hint - 1), value)) {
140  hint = po.increase_capacity(cont, hint);
141  return cont.insert(hint, std::move(value));
142  } else {
143  return sorted.insert(std::move(value)).first;
144  }
145  }
146 
147  if (cmp(*hint, value)) {
148  if (hint + 1 == cont.end() || cmp(value, *(hint + 1))) {
149  hint = po.increase_capacity(cont, hint + 1);
150  return cont.insert(hint, std::move(value));
151  } else {
152  return sorted.insert(std::move(value)).first;
153  }
154  }
155 
156  // Value and *hint did not compare, so they are equal keys.
157  return hint;
158 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static const char *const value
Definition: Conv.cpp:50
void folly::detail::insertThousandsGroupingUnsafe ( char *  start_buffer,
char **  end_buffer 
)

Definition at line 387 of file Format.cpp.

References i, and uint32_t.

Referenced by folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::doFormat(), and testGrouping().

387  {
388  uint32_t remaining_digits = uint32_t(*end_buffer - start_buffer);
389  uint32_t separator_size = (remaining_digits - 1) / 3;
390  uint32_t result_size = remaining_digits + separator_size;
391  *end_buffer = *end_buffer + separator_size;
392 
393  // get the end of the new string with the separators
394  uint32_t buffer_write_index = result_size - 1;
395  uint32_t buffer_read_index = remaining_digits - 1;
396  start_buffer[buffer_write_index + 1] = 0;
397 
398  bool done = false;
399  uint32_t next_group_size = 3;
400 
401  while (!done) {
402  uint32_t current_group_size = std::max<uint32_t>(
403  1, std::min<uint32_t>(remaining_digits, next_group_size));
404 
405  // write out the current group's digits to the buffer index
406  for (uint32_t i = 0; i < current_group_size; i++) {
407  start_buffer[buffer_write_index--] = start_buffer[buffer_read_index--];
408  }
409 
410  // if not finished, write the separator before the next group
411  if (buffer_write_index < buffer_write_index + 1) {
412  start_buffer[buffer_write_index--] = ',';
413  } else {
414  done = true;
415  }
416 
417  remaining_digits -= current_group_size;
418  }
419 }
template<class Delim , class Iterator , class String >
std::enable_if<IsSizableStringContainerIterator<Iterator>::value>::type folly::detail::internalJoin ( Delim  delimiter,
Iterator  begin,
Iterator  end,
String &  output 
)

Definition at line 469 of file String-inl.h.

References folly::test::begin(), delimSize(), internalJoinAppend(), folly::size(), and type.

Referenced by folly::join().

469  {
470  output.clear();
471  if (begin == end) {
472  return;
473  }
474  const size_t dsize = delimSize(delimiter);
475  Iterator it = begin;
476  size_t size = it->size();
477  while (++it != end) {
478  size += dsize + it->size();
479  }
480  output.reserve(size);
481  internalJoinAppend(delimiter, begin, end, output);
482 }
size_t delimSize(StringPiece s)
Definition: String-inl.h:252
void internalJoinAppend(Delim delimiter, Iterator begin, Iterator end, String &output)
Definition: String-inl.h:451
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
template<class Delim , class Iterator , class String >
std::enable_if< !IsSizableStringContainerIterator<Iterator>::value>::type folly::detail::internalJoin ( Delim  delimiter,
Iterator  begin,
Iterator  end,
String &  output 
)

Definition at line 487 of file String-inl.h.

References internalJoinAppend().

487  {
488  output.clear();
489  if (begin == end) {
490  return;
491  }
492  internalJoinAppend(delimiter, begin, end, output);
493 }
void internalJoinAppend(Delim delimiter, Iterator begin, Iterator end, String &output)
Definition: String-inl.h:451
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
template<class Delim , class Iterator , class String >
void folly::detail::internalJoinAppend ( Delim  delimiter,
Iterator  begin,
Iterator  end,
String &  output 
)

Definition at line 451 of file String-inl.h.

References delimFront(), delimSize(), folly::toAppend(), type, and value.

Referenced by internalJoin().

455  {
456  assert(begin != end);
457  if (std::is_same<Delim, StringPiece>::value && delimSize(delimiter) == 1) {
459  return;
460  }
461  toAppend(*begin, &output);
462  while (++begin != end) {
463  toAppend(delimiter, *begin, &output);
464  }
465 }
char delimFront(StringPiece s)
Definition: String-inl.h:269
size_t delimSize(StringPiece s)
Definition: String-inl.h:252
void internalJoinAppend(Delim delimiter, Iterator begin, Iterator end, String &output)
Definition: String-inl.h:451
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
static const char *const value
Definition: Conv.cpp:50
void toAppend(char value, Tgt *result)
Definition: Conv.h:406
template<class OutStringT , class DelimT , class OutputIterator >
void folly::detail::internalSplit ( DelimT  delim,
StringPiece  sp,
OutputIterator  out,
bool  ignoreEmpty 
)

Definition at line 284 of file String-inl.h.

References atDelim(), delimFront(), delimSize(), folly::Range< Iter >::empty(), i, s, folly::Range< Iter >::size(), folly::Range< Iter >::start(), folly::Range< Iter >::subpiece(), and value.

288  {
289  assert(sp.empty() || sp.start() != nullptr);
290 
291  const char* s = sp.start();
292  const size_t strSize = sp.size();
293  const size_t dSize = delimSize(delim);
294 
295  if (dSize > strSize || dSize == 0) {
296  if (!ignoreEmpty || strSize > 0) {
297  *out++ = to<OutStringT>(sp);
298  }
299  return;
300  }
301  if (std::is_same<DelimT, StringPiece>::value && dSize == 1) {
302  // Call the char version because it is significantly faster.
303  return internalSplit<OutStringT>(delimFront(delim), sp, out, ignoreEmpty);
304  }
305 
306  size_t tokenStartPos = 0;
307  size_t tokenSize = 0;
308  for (size_t i = 0; i <= strSize - dSize; ++i) {
309  if (atDelim(&s[i], delim)) {
310  if (!ignoreEmpty || tokenSize > 0) {
311  *out++ = to<OutStringT>(sp.subpiece(tokenStartPos, tokenSize));
312  }
313 
314  tokenStartPos = i + dSize;
315  tokenSize = 0;
316  i += dSize - 1;
317  } else {
318  ++tokenSize;
319  }
320  }
321  tokenSize = strSize - tokenStartPos;
322  if (!ignoreEmpty || tokenSize > 0) {
323  *out++ = to<OutStringT>(sp.subpiece(tokenStartPos, tokenSize));
324  }
325 }
char delimFront(StringPiece s)
Definition: String-inl.h:269
size_t delimSize(StringPiece s)
Definition: String-inl.h:252
bool atDelim(const char *s, StringPiece sp)
Definition: String-inl.h:258
static const char *const value
Definition: Conv.cpp:50
static set< string > s
template<typename Fn >
EnableForArgTypes<Fn> folly::detail::invokeForKeyValue ( Fn  f,
const folly::dynamic ,
const folly::dynamic  
)

Definition at line 102 of file DynamicParser-inl.h.

References f.

Referenced by folly::DynamicParser::parse().

102  {
103  f();
104 }
auto f
template<typename Fn >
EnableForArgTypes<Fn, folly::dynamic> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic ,
const folly::dynamic v 
)

Definition at line 111 of file DynamicParser-inl.h.

111  {
112  fn(v);
113 }
template<typename Fn >
EnableForArgTypes<Fn, int64_t> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic ,
const folly::dynamic v 
)

Definition at line 117 of file DynamicParser-inl.h.

References folly::dynamic::asInt().

117  {
118  fn(v.asInt());
119 }
int64_t asInt() const
Definition: dynamic-inl.h:524
template<typename Fn >
EnableForArgTypes<Fn, bool> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic ,
const folly::dynamic v 
)

Definition at line 123 of file DynamicParser-inl.h.

References folly::dynamic::asBool().

123  {
124  fn(v.asBool());
125 }
bool asBool() const
Definition: dynamic-inl.h:527
template<typename Fn >
EnableForArgTypes<Fn, double> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic ,
const folly::dynamic v 
)

Definition at line 129 of file DynamicParser-inl.h.

References folly::dynamic::asDouble().

129  {
130  fn(v.asDouble());
131 }
double asDouble() const
Definition: dynamic-inl.h:521
template<typename Fn >
EnableForArgTypes<Fn, std::string> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic ,
const folly::dynamic v 
)

Definition at line 135 of file DynamicParser-inl.h.

References folly::dynamic::asString().

135  {
136  fn(v.asString());
137 }
std::string asString() const
Definition: dynamic-inl.h:518
template<typename Fn >
EnableForArgTypes<Fn, folly::dynamic, folly::dynamic> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 148 of file DynamicParser-inl.h.

148  {
149  fn(k, v);
150 }
template<typename Fn >
EnableForArgTypes<Fn, folly::dynamic, int64_t> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 154 of file DynamicParser-inl.h.

References folly::dynamic::asInt().

154  {
155  fn(k, v.asInt());
156 }
int64_t asInt() const
Definition: dynamic-inl.h:524
template<typename Fn >
EnableForArgTypes<Fn, folly::dynamic, bool> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 160 of file DynamicParser-inl.h.

References folly::dynamic::asBool().

160  {
161  fn(k, v.asBool());
162 }
bool asBool() const
Definition: dynamic-inl.h:527
template<typename Fn >
EnableForArgTypes<Fn, folly::dynamic, double> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 166 of file DynamicParser-inl.h.

References folly::dynamic::asDouble().

166  {
167  fn(k, v.asDouble());
168 }
double asDouble() const
Definition: dynamic-inl.h:521
template<typename Fn >
EnableForArgTypes<Fn, folly::dynamic, std::string> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 172 of file DynamicParser-inl.h.

References folly::dynamic::asString().

172  {
173  fn(k, v.asString());
174 }
std::string asString() const
Definition: dynamic-inl.h:518
template<typename Fn >
EnableForArgTypes<Fn, std::string, folly::dynamic> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 181 of file DynamicParser-inl.h.

References folly::dynamic::asString(), and v.

181  {
182  fn(k.asString(), v);
183 }
auto v
std::string asString() const
Definition: dynamic-inl.h:518
template<typename Fn >
EnableForArgTypes<Fn, std::string, int64_t> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 187 of file DynamicParser-inl.h.

References folly::dynamic::asInt(), and folly::dynamic::asString().

187  {
188  fn(k.asString(), v.asInt());
189 }
std::string asString() const
Definition: dynamic-inl.h:518
int64_t asInt() const
Definition: dynamic-inl.h:524
template<typename Fn >
EnableForArgTypes<Fn, std::string, bool> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 193 of file DynamicParser-inl.h.

References folly::dynamic::asBool(), and folly::dynamic::asString().

193  {
194  fn(k.asString(), v.asBool());
195 }
bool asBool() const
Definition: dynamic-inl.h:527
std::string asString() const
Definition: dynamic-inl.h:518
template<typename Fn >
EnableForArgTypes<Fn, std::string, double> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 199 of file DynamicParser-inl.h.

References folly::dynamic::asDouble(), and folly::dynamic::asString().

199  {
200  fn(k.asString(), v.asDouble());
201 }
double asDouble() const
Definition: dynamic-inl.h:521
std::string asString() const
Definition: dynamic-inl.h:518
template<typename Fn >
EnableForArgTypes<Fn, std::string, std::string> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 205 of file DynamicParser-inl.h.

References folly::dynamic::asString().

205  {
206  fn(k.asString(), v.asString());
207 }
std::string asString() const
Definition: dynamic-inl.h:518
template<typename Fn >
EnableForArgTypes<Fn, int64_t, folly::dynamic> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 214 of file DynamicParser-inl.h.

References folly::dynamic::asInt(), and v.

214  {
215  fn(k.asInt(), v);
216 }
auto v
int64_t asInt() const
Definition: dynamic-inl.h:524
template<typename Fn >
EnableForArgTypes<Fn, int64_t, int64_t> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 220 of file DynamicParser-inl.h.

References folly::dynamic::asInt().

220  {
221  fn(k.asInt(), v.asInt());
222 }
int64_t asInt() const
Definition: dynamic-inl.h:524
template<typename Fn >
EnableForArgTypes<Fn, int64_t, bool> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 226 of file DynamicParser-inl.h.

References folly::dynamic::asBool(), and folly::dynamic::asInt().

226  {
227  fn(k.asInt(), v.asBool());
228 }
bool asBool() const
Definition: dynamic-inl.h:527
int64_t asInt() const
Definition: dynamic-inl.h:524
template<typename Fn >
EnableForArgTypes<Fn, int64_t, double> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 232 of file DynamicParser-inl.h.

References folly::dynamic::asDouble(), and folly::dynamic::asInt().

232  {
233  fn(k.asInt(), v.asDouble());
234 }
double asDouble() const
Definition: dynamic-inl.h:521
int64_t asInt() const
Definition: dynamic-inl.h:524
template<typename Fn >
EnableForArgTypes<Fn, int64_t, std::string> folly::detail::invokeForKeyValue ( Fn  fn,
const folly::dynamic k,
const folly::dynamic v 
)

Definition at line 238 of file DynamicParser-inl.h.

References folly::dynamic::asInt(), and folly::dynamic::asString().

238  {
239  fn(k.asInt(), v.asString());
240 }
std::string asString() const
Definition: dynamic-inl.h:518
int64_t asInt() const
Definition: dynamic-inl.h:524
FOLLY_PUSH_WARNING RHS LHS bool folly::detail::less_than_impl ( LHS const  lhs)

Definition at line 650 of file Traits.h.

650  {
651  // clang-format off
652  return
655  lhs < rhs;
656  // clang-format on
657 }
LogLevel max
Definition: LogLevel.cpp:31
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
LogLevel min
Definition: LogLevel.cpp:30
template<typename... SynchronizedLocker>
auto folly::detail::lock ( SynchronizedLocker...  lockersIn) -> std::tuple<typename SynchronizedLocker::LockedPtr...>

Acquire locks for multiple Synchronized<T> objects, in a deadlock-safe manner.

The function uses the "smart and polite" algorithm from this link http://howardhinnant.github.io/dining_philosophers.html#Polite

The gist of the algorithm is that it locks a mutex, then tries to lock the other mutexes in a non-blocking manner. If all the locks succeed, we are done, if not, we release the locks we have held, yield to allow other threads to continue and then block on the mutex that we failed to acquire.

This allows dynamically yielding ownership of all the mutexes but one, so that other threads can continue doing work and locking the other mutexes. See the benchmarks in folly/test/SynchronizedBenchmark.cpp for more.

Definition at line 871 of file Synchronized.h.

References testing::Args(), folly::fetch(), folly::for_each(), folly::loop_break, folly::loop_continue, folly::gen::move, and folly::fibers::yield().

Referenced by testing::UnitTest::AddTestPartResult(), BENCHMARK(), burn(), testing::UnitTest::current_test_case(), testing::UnitTest::current_test_info(), testing::internal::linked_ptr_internal::depart(), folly::ssl::detail::dyn_destroy(), testing::internal::UnitTestImpl::GetGlobalTestPartResultReporter(), wangle::ThreadSafeSSLSessionCache::getSSLSession(), testing::internal::GetThreadCount(), folly::ssl::detail::isSSLLockDisabled(), testing::internal::linked_ptr_internal::join(), folly::LockPolicyExclusive::lock(), folly::lock(), testing::internal::NoDefaultContructor::NoDefaultContructor(), folly::SharedPromise< T >::operator=(), testing::UnitTest::PopGTestTrace(), testing::UnitTest::PushGTestTrace(), wangle::LRUPersistentCache< K, V, MutexT >::put(), testing::TestResult::RecordProperty(), wangle::ThreadSafeSSLSessionCache::removeSSLSession(), runContended(), runFairness(), runUncontended(), testing::internal::UnitTestImpl::SetGlobalTestPartResultReporter(), wangle::ThreadSafeSSLSessionCache::setSSLSession(), testing::internal::ShouldRunTestCase(), wangle::ThreadSafeSSLSessionCache::size(), wangle::ThreadSafeSSLSessionCache::supportsPersistence(), TEST(), testing::internal::TEST(), testing::internal::To::To(), wangle::LRUPersistentCache< K, V, MutexT >::~LRUPersistentCache(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

872  {
873  // capture the list of lockers as a tuple
874  auto lockers = std::forward_as_tuple(lockersIn...);
875 
876  // make a list of null LockedPtr instances that we will return to the caller
877  auto lockedPtrs = std::tuple<typename SynchronizedLocker::LockedPtr...>{};
878 
879  // start by locking the first thing in the list
880  std::get<0>(lockedPtrs) = std::get<0>(lockers).lock();
881  auto indexLocked = 0;
882 
883  while (true) {
884  auto couldLockAll = true;
885 
886  for_each(lockers, [&](auto& locker, auto index) {
887  // if we should try_lock on the current locker then do so
888  if (index != indexLocked) {
889  auto lockedPtr = locker.tryLock();
890 
891  // if we were unable to lock this mutex,
892  //
893  // 1. release all the locks,
894  // 2. yield control to another thread to be nice
895  // 3. block on the mutex we failed to lock, acquire the lock
896  // 4. break out and set the index of the current mutex to indicate
897  // which mutex we have locked
898  if (!lockedPtr) {
899  // writing lockedPtrs = decltype(lockedPtrs){} does not compile on
900  // gcc, I believe this is a bug D7676798
901  lockedPtrs = std::tuple<typename SynchronizedLocker::LockedPtr...>{};
902 
904  fetch(lockedPtrs, index) = locker.lock();
905  indexLocked = index;
906  couldLockAll = false;
907 
908  return loop_break;
909  }
910 
911  // else store the locked mutex in the list we return
912  fetch(lockedPtrs, index) = std::move(lockedPtr);
913  }
914 
915  return loop_continue;
916  });
917 
918  if (couldLockAll) {
919  return lockedPtrs;
920  }
921  }
922 }
constexpr auto loop_continue
Definition: Foreach.h:98
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void for_each(T const &range, Function< void(typename T::value_type const &) const > const &func)
decltype(auto) FOLLY_CPP14_CONSTEXPR fetch(Sequence &&sequence, Index &&index)
Definition: Foreach-inl.h:322
constexpr auto loop_break
Definition: Foreach.h:97
template<typename Synchronized , typename... Args>
auto folly::detail::lock ( Synchronized synchronized,
Args &&...  args 
)

Definition at line 955 of file Synchronized.h.

References a, makeSynchronizedLocker(), and s.

955  {
957  synchronized,
958  [](auto& s, auto&&... a) {
959  return s.lock(std::forward<decltype(a)>(a)...);
960  },
961  [](auto& s) { return s.tryLock(); },
962  std::forward<Args>(args)...);
963 }
auto makeSynchronizedLocker(Synchronized &synchronized, LockFunc &&lockFunc, TryLockFunc &&tryLockFunc, Args &&...args)
Definition: Synchronized.h:837
char a
static set< string > s
template<typename Synchronized , typename LockFunc , typename TryLockFunc , typename... Args>
auto folly::detail::makeSynchronizedLocker ( Synchronized synchronized,
LockFunc &&  lockFunc,
TryLockFunc &&  tryLockFunc,
Args &&...  args 
)

Definition at line 837 of file Synchronized.h.

Referenced by lock(), folly::lock(), rlock(), ulock(), and wlock().

841  {
842  using LockFuncType = std::decay_t<LockFunc>;
843  using TryLockFuncType = std::decay_t<TryLockFunc>;
844  return SynchronizedLocker<
845  Synchronized,
846  LockFuncType,
847  TryLockFuncType,
848  std::decay_t<Args>...>{synchronized,
849  std::forward<LockFunc>(lockFunc),
850  std::forward<TryLockFunc>(tryLockFunc),
851  std::forward<Args>(args)...};
852 }
template<typename T >
void folly::detail::mallctlHelper ( const char *  cmd,
T out,
T in 
)

Definition at line 33 of file MallctlHelper.h.

References handleMallctlError(), mallctl, folly::T, UNLIKELY, and folly::usingJEMalloc().

Referenced by folly::mallctlRead(), folly::mallctlReadWrite(), and folly::mallctlWrite().

33  {
34  if (UNLIKELY(!usingJEMalloc())) {
35  throw std::logic_error("Calling mallctl when not using jemalloc.");
36  }
37 
38  size_t outLen = sizeof(T);
39  int err = mallctl(cmd, out, out ? &outLen : nullptr, in, in ? sizeof(T) : 0);
40  if (UNLIKELY(err != 0)) {
41  handleMallctlError(cmd, err);
42  }
43 }
#define T(v)
Definition: http_parser.c:233
bool usingJEMalloc() noexcept
Definition: Malloc.h:147
int(* mallctl)(const char *, void *, size_t *, void *, size_t)
Definition: MallocImpl.cpp:42
cmd
Definition: gtest-cfgcmd.txt:1
void handleMallctlError(const char *cmd, int err)
#define UNLIKELY(x)
Definition: Likely.h:48
constexpr size_t folly::detail::max_align_ ( std::size_t  a)

Definition at line 29 of file Align.h.

References a.

Referenced by max_align_().

29  {
30  return a;
31 }
char a
template<typename... Es>
constexpr std::size_t folly::detail::max_align_ ( std::size_t  a,
std::size_t  e,
Es...  es 
)

Definition at line 33 of file Align.h.

References max_align_().

33  {
34  return !(a < e) ? a : max_align_(e, es...);
35 }
constexpr std::size_t max_align_(std::size_t a, std::size_t e, Es...es)
Definition: Align.h:33
char a
template<class T >
std::enable_if< std::is_default_constructible<T>::value && !folly::is_trivially_copyable<T>::value>::type folly::detail::moveObjectsRight ( T first,
T lastConstructed,
T realLast 
)

Definition at line 108 of file small_vector.h.

References folly::test::end(), folly::gen::move, T, type, and value.

108  {
109  if (lastConstructed == realLast) {
110  return;
111  }
112 
113  T* end = first - 1; // Past the end going backwards.
114  T* out = realLast - 1;
115  T* in = lastConstructed - 1;
116  try {
117  for (; in != end && out >= lastConstructed; --in, --out) {
118  new (out) T(std::move(*in));
119  }
120  for (; in != end; --in, --out) {
121  *out = std::move(*in);
122  }
123  for (; out >= lastConstructed; --out) {
124  new (out) T();
125  }
126  } catch (...) {
127  // We want to make sure the same stuff is uninitialized memory
128  // if we exit via an exception (this is to make sure we provide
129  // the basic exception safety guarantee for insert functions).
130  if (out < lastConstructed) {
131  out = lastConstructed - 1;
132  }
133  for (auto it = out + 1; it != realLast; ++it) {
134  it->~T();
135  }
136  throw;
137  }
138 }
#define T(v)
Definition: http_parser.c:233
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
constexpr detail::First first
Definition: Base-inl.h:2553
template<class T >
std::enable_if< !std::is_default_constructible<T>::value || folly::is_trivially_copyable<T>::value>::type folly::detail::moveObjectsRight ( T first,
T lastConstructed,
T realLast 
)

Definition at line 147 of file small_vector.h.

Referenced by folly::small_vector< Observer< T > *, InlineObservers >::insert(), and folly::small_vector< Observer< T > *, InlineObservers >::insertImpl().

147  {
148  std::move_backward(first, lastConstructed, realLast);
149 }
constexpr detail::First first
Definition: Base-inl.h:2553
template<class T , class U >
std::enable_if< (std::is_arithmetic<T>::value && std::is_arithmetic<U>::value) || (std::is_pointer<T>::value && std::is_pointer<U>::value), bool>::type folly::detail::notThereYet ( T iter,
const U &  end 
)

notThereYet helps the FOR_EACH_RANGE macro by opportunistically using "<" instead of "!=" whenever available when checking for loop termination. This makes e.g. examples such as FOR_EACH_RANGE (i, 10, 5) execute zero iterations instead of looping virtually forever. At the same time, some iterator types define "!=" but not "<". The notThereYet function will dispatch differently for those.

Below is the correct implementation of notThereYet. It is disabled because of a bug in Boost 1.46: The filesystem::path::iterator defines operator< (via boost::iterator_facade), but that in turn uses distance_to which is undefined for that particular iterator. So HasLess (defined above) identifies boost::filesystem::path as properly comparable with <, but in fact attempting to do so will yield a compile-time error.

The else branch (active) contains a conservative implementation.

Definition at line 267 of file Foreach.h.

References folly::test::end(), type, and value.

267  {
268  return iter < end;
269 }
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
template<class T , class U >
std::enable_if< !((std::is_arithmetic<T>::value && std::is_arithmetic<U>::value) || (std::is_pointer<T>::value && std::is_pointer<U>::value)), bool>::type folly::detail::notThereYet ( T iter,
const U &  end 
)

Definition at line 276 of file Foreach.h.

References folly::test::end().

276  {
277  return iter != end;
278 }
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
template<template< class > class Op>
dynamic folly::detail::numericOp ( dynamic const &  a,
dynamic const &  b 
)

Definition at line 169 of file dynamic-inl.h.

References a, folly::dynamic::asDouble(), folly::dynamic::asInt(), b, folly::dynamic::isDouble(), folly::dynamic::isInt(), folly::dynamic::isNumber(), and folly::dynamic::type().

169  {
170  if (!a.isNumber() || !b.isNumber()) {
171  throw_exception<TypeError>("numeric", a.type(), b.type());
172  }
173  if (a.type() != b.type()) {
174  auto& integ = a.isInt() ? a : b;
175  auto& nonint = a.isInt() ? b : a;
176  return Op<double>()(to<double>(integ.asInt()), nonint.asDouble());
177  }
178  if (a.isDouble()) {
179  return Op<double>()(a.asDouble(), b.asDouble());
180  }
181  return Op<int64_t>()(a.asInt(), b.asInt());
182 }
char b
char a
template<typename FunctionType >
ScopeGuardImpl<typename std::decay<FunctionType>::type, true> folly::detail::operator+ ( detail::ScopeGuardOnExit  ,
FunctionType &&  fn 
)

Definition at line 264 of file ScopeGuard.h.

Referenced by folly::makeGuard().

266  {
268  std::forward<FunctionType>(fn));
269 }
PskType type
template<class Tgt >
std::enable_if< std::is_void<ParseToResult<Tgt> >::value, Expected<StringPiece, ConversionCode> >::type folly::detail::parseToWrap ( StringPiece  sp,
Tgt &  out 
)
inline

Definition at line 1447 of file Conv.h.

References folly::Range< Iter >::end(), folly::parseTo(), type, and folly::value().

Referenced by folly::to().

1447  {
1448  parseTo(sp, out);
1449  return StringPiece(sp.end(), sp.end());
1450 }
FOLLY_NODISCARD Expected< StringPiece, ConversionCode > parseTo(StringPiece in, fbstring &out)
Definition: Conv.h:1411
Range< const char * > StringPiece
template<class Tgt >
std::enable_if< !std::is_void<ParseToResult<Tgt> >::value, ParseToResult<Tgt> >::type folly::detail::parseToWrap ( StringPiece  sp,
Tgt &  out 
)
inline

Definition at line 1456 of file Conv.h.

References folly::parseTo().

1456  {
1457  return parseTo(sp, out);
1458 }
FOLLY_NODISCARD Expected< StringPiece, ConversionCode > parseTo(StringPiece in, fbstring &out)
Definition: Conv.h:1411
template<class T >
T* folly::detail::pointerFlagSet ( T p)

Definition at line 379 of file small_vector.h.

References T.

Referenced by folly::small_vector< Observer< T > *, InlineObservers >::makeSizeInternal().

379  {
380  return reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(p) | 1);
381 }
#define T(v)
Definition: http_parser.c:233
constexpr size_t folly::detail::poly_size ( size_t  bits)

Definition at line 55 of file Fingerprint.h.

Referenced by folly::Fingerprint< BITS >::size().

55  {
56  return 1 + (bits - 1) / 64;
57 }
template<class T , class Function >
void folly::detail::populateMemForward ( T mem,
std::size_t  n,
Function const &  op 
)

Definition at line 156 of file small_vector.h.

References i.

Referenced by folly::small_vector< Observer< T > *, InlineObservers >::constructImpl(), folly::small_vector< Observer< T > *, InlineObservers >::doConstruct(), and folly::small_vector< Observer< T > *, InlineObservers >::resize().

156  {
157  std::size_t idx = 0;
158  try {
159  for (size_t i = 0; i < n; ++i) {
160  op(&mem[idx]);
161  ++idx;
162  }
163  } catch (...) {
164  for (std::size_t i = 0; i < idx; ++i) {
165  mem[i].~T();
166  }
167  throw;
168  }
169 }
template<typename SubsecondRatio , typename Seconds , typename Subseconds , typename Rep >
auto folly::detail::posixTimeToDuration ( Seconds  seconds,
Subseconds  subseconds,
std::chrono::duration< Rep, std::ratio< 1, 1 >>  dummy 
) -> Expected<decltype(dummy), ConversionCode>

Convert a timeval or a timespec to a std::chrono::duration with second granularity.

The SubsecondRatio template parameter specifies what type of subseconds to return. This must have a numerator of 1.

The input must be in normalized form: the subseconds field must be greater than or equal to 0, and less than SubsecondRatio::den (i.e., less than 1 second).

Definition at line 380 of file Conv.h.

References dummy(), folly::makeUnexpected(), folly::NEGATIVE_OVERFLOW, UNLIKELY, and value.

384  {
385  using Tgt = decltype(dummy);
386  static_assert(Tgt::period::num == 1, "special case expecting num==1");
387  static_assert(Tgt::period::den == 1, "special case expecting den==1");
388  static_assert(
389  SubsecondRatio::num == 1, "subsecond numerator should always be 1");
390 
391  auto outputSeconds = tryTo<typename Tgt::rep>(seconds);
392  if (outputSeconds.hasError()) {
393  return makeUnexpected(outputSeconds.error());
394  }
395 
397  return Tgt{typename Tgt::rep(seconds) +
398  (typename Tgt::rep(subseconds) / SubsecondRatio::den)};
399  }
400 
401  // If the value is negative, we have to round up a non-zero subseconds value
402  if (UNLIKELY(outputSeconds.value() < 0) && subseconds > 0) {
403  if (UNLIKELY(
404  outputSeconds.value() ==
405  std::numeric_limits<typename Tgt::rep>::lowest())) {
406  return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
407  }
408  return Tgt{outputSeconds.value() + 1};
409  }
410 
411  return Tgt{outputSeconds.value()};
412 }
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
void dummy()
static const char *const value
Definition: Conv.cpp:50
#define UNLIKELY(x)
Definition: Likely.h:48
template<typename SubsecondRatio , typename Seconds , typename Subseconds , typename Rep , std::intmax_t Denominator>
auto folly::detail::posixTimeToDuration ( Seconds  seconds,
Subseconds  subseconds,
std::chrono::duration< Rep, std::ratio< 1, Denominator >>  dummy 
) -> Expected<decltype(dummy), ConversionCode>

Convert a timeval or a timespec to a std::chrono::duration with subsecond granularity

Definition at line 424 of file Conv.h.

References dummy(), LIKELY, folly::makeUnexpected(), folly::SUCCESS, and value.

428  {
429  using Tgt = decltype(dummy);
430  static_assert(Tgt::period::num == 1, "special case expecting num==1");
431  static_assert(Tgt::period::den != 1, "special case expecting den!=1");
432  static_assert(
433  SubsecondRatio::num == 1, "subsecond numerator should always be 1");
434 
435  auto errorCode = detail::CheckOverflowToDuration<
437  template check<Tgt, SubsecondRatio>(seconds, subseconds);
438  if (errorCode != ConversionCode::SUCCESS) {
439  return makeUnexpected(errorCode);
440  }
441 
442  if (LIKELY(seconds >= 0)) {
443  return std::chrono::duration_cast<Tgt>(
444  std::chrono::duration<typename Tgt::rep>{seconds}) +
445  std::chrono::duration_cast<Tgt>(
446  std::chrono::duration<typename Tgt::rep, SubsecondRatio>{
447  subseconds});
448  } else {
449  // For negative numbers we have to round subseconds up towards zero, even
450  // though it is a positive value, since the overall value is negative.
451  return std::chrono::duration_cast<Tgt>(
452  std::chrono::duration<typename Tgt::rep>{seconds + 1}) -
453  std::chrono::duration_cast<Tgt>(
454  std::chrono::duration<typename Tgt::rep, SubsecondRatio>{
455  SubsecondRatio::den - subseconds});
456  }
457 }
#define LIKELY(x)
Definition: Likely.h:47
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
void dummy()
static const char *const value
Definition: Conv.cpp:50
template<typename SubsecondRatio , typename Seconds , typename Subseconds , typename Rep , std::intmax_t Numerator>
auto folly::detail::posixTimeToDuration ( Seconds  seconds,
Subseconds  subseconds,
std::chrono::duration< Rep, std::ratio< Numerator, 1 >>  dummy 
) -> Expected<decltype(dummy), ConversionCode>

Convert a timeval or a timespec to a std::chrono::duration with granularity coarser than 1 second.

Definition at line 469 of file Conv.h.

References dummy(), folly::makeUnexpected(), folly::NEGATIVE_OVERFLOW, UNLIKELY, and value.

473  {
474  using Tgt = decltype(dummy);
475  static_assert(Tgt::period::num != 1, "special case expecting num!=1");
476  static_assert(Tgt::period::den == 1, "special case expecting den==1");
477  static_assert(
478  SubsecondRatio::num == 1, "subsecond numerator should always be 1");
479 
480  if (UNLIKELY(seconds < 0) && subseconds > 0) {
481  // Increment seconds by one to handle truncation of negative numbers
482  // properly.
483  if (UNLIKELY(seconds == std::numeric_limits<Seconds>::lowest())) {
484  return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
485  }
486  seconds += 1;
487  }
488 
490  // Convert to the floating point type before performing the division
491  return Tgt{static_cast<typename Tgt::rep>(seconds) / Tgt::period::num};
492  } else {
493  // Perform the division as an integer, and check that the result fits in
494  // the output integer type
495  auto outputValue = (seconds / Tgt::period::num);
496  auto expectedOuput = tryTo<typename Tgt::rep>(outputValue);
497  if (expectedOuput.hasError()) {
498  return makeUnexpected(expectedOuput.error());
499  }
500 
501  return Tgt{expectedOuput.value()};
502  }
503 }
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
void dummy()
static const char *const value
Definition: Conv.cpp:50
#define UNLIKELY(x)
Definition: Likely.h:48
template<typename SubsecondRatio , typename Seconds , typename Subseconds , typename Rep , std::intmax_t Denominator, std::intmax_t Numerator>
auto folly::detail::posixTimeToDuration ( Seconds  seconds,
Subseconds  subseconds,
std::chrono::duration< Rep, std::ratio< Numerator, Denominator >>  dummy 
) -> Expected<decltype(dummy), ConversionCode>

Convert a timeval or timespec to a std::chrono::duration

This overload is only used for unusual durations where neither the numerator nor denominator are 1.

Definition at line 518 of file Conv.h.

References dummy(), and folly::makeUnexpected().

522  {
523  using Tgt = decltype(dummy);
524  static_assert(
525  Tgt::period::num != 1, "should use special-case code when num==1");
526  static_assert(
527  Tgt::period::den != 1, "should use special-case code when den==1");
528  static_assert(
529  SubsecondRatio::num == 1, "subsecond numerator should always be 1");
530 
531  // Cast through an intermediate type with subsecond granularity.
532  // Note that this could fail due to overflow during the initial conversion
533  // even if the result is representable in the output POSIX-style types.
534  //
535  // Note that for integer type conversions going through this intermediate
536  // type can result in slight imprecision due to truncating the intermediate
537  // calculation to an integer.
538  using IntermediateType =
539  IntermediateDuration<typename Tgt::rep, typename Tgt::period>;
540  auto intermediate = posixTimeToDuration<SubsecondRatio>(
541  seconds, subseconds, IntermediateType{});
542  if (intermediate.hasError()) {
543  return makeUnexpected(intermediate.error());
544  }
545  // Now convert back to the target duration. Use tryTo() to confirm that the
546  // result fits in the target representation type.
547  return tryTo<typename Tgt::rep>(
548  intermediate.value().count() / Tgt::period::num)
549  .then([](typename Tgt::rep tgt) { return Tgt{tgt}; });
550 }
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
void dummy()
template<class String >
StringPiece folly::detail::prepareDelim ( const String &  s)

Definition at line 328 of file String-inl.h.

Referenced by folly::join(), folly::split(), and folly::splitTo().

328  {
329  return StringPiece(s);
330 }
static set< string > s
Range< const char * > StringPiece
char folly::detail::prepareDelim ( char  c)
inline

Definition at line 331 of file String-inl.h.

References c.

331  {
332  return c;
333 }
char c
size_t folly::detail::qfind_first_byte_of ( const StringPiece  haystack,
const StringPiece  needles 
)
inline

Definition at line 1349 of file Range.h.

References qfind_first_byte_of_nosse(), qfind_first_byte_of_sse42(), and folly::CpuId::sse42().

Referenced by BENCHMARK(), SseNeedleFinder::find_first_byte_of(), and folly::qfind_first_of().

1351  {
1352  static auto const qfind_first_byte_of_fn = folly::CpuId().sse42()
1355  return qfind_first_byte_of_fn(haystack, needles);
1356 }
size_t qfind_first_byte_of_sse42(const StringPieceLite haystack, const StringPieceLite needles)
Definition: RangeSse42.cpp:31
size_t qfind_first_byte_of_nosse(const StringPieceLite haystack, const StringPieceLite needles)
Definition: RangeCommon.h:92
FOLLY_ALWAYS_INLINE bool sse42() const
Definition: CpuId.h:133
size_t folly::detail::qfind_first_byte_of_bitset ( const StringPieceLite  haystack,
const StringPieceLite  needles 
)

Definition at line 27 of file RangeCommon.cpp.

References needle, s, folly::detail::StringPieceLite::size(), and uint8_t.

Referenced by BENCHMARK_RELATIVE(), and qfind_first_byte_of_std().

29  {
30  std::bitset<256> s;
31  for (auto needle : needles) {
32  s[(uint8_t)needle] = true;
33  }
34  for (size_t index = 0; index < haystack.size(); ++index) {
35  if (s[(uint8_t)haystack[index]]) {
36  return index;
37  }
38  }
39  return std::string::npos;
40 }
const string needle
static set< string > s
size_t folly::detail::qfind_first_byte_of_byteset ( const StringPieceLite  haystack,
const StringPieceLite  needles 
)

Definition at line 42 of file RangeCommon.cpp.

References folly::SparseByteSet::add(), folly::SparseByteSet::contains(), needle, s, folly::detail::StringPieceLite::size(), and uint8_t.

Referenced by BENCHMARK_RELATIVE(), ByteSetNeedleFinder::find_first_byte_of(), qfind_first_byte_of_nosse(), qfind_first_byte_of_sse42(), and qfind_first_byte_of_std().

44  {
45  SparseByteSet s;
46  for (auto needle : needles) {
47  s.add(uint8_t(needle));
48  }
49  for (size_t index = 0; index < haystack.size(); ++index) {
50  if (s.contains(uint8_t(haystack[index]))) {
51  return index;
52  }
53  }
54  return std::string::npos;
55 }
const string needle
static set< string > s
size_t folly::detail::qfind_first_byte_of_nosse ( const StringPieceLite  haystack,
const StringPieceLite  needles 
)
inline

Definition at line 92 of file RangeCommon.h.

References folly::detail::StringPieceLite::empty(), qfind_first_byte_of_byteset(), qfind_first_byte_of_std(), folly::detail::StringPieceLite::size(), and UNLIKELY.

Referenced by BENCHMARK_RELATIVE(), NoSseNeedleFinder::find_first_byte_of(), qfind_first_byte_of(), and qfind_first_byte_of_sse42().

94  {
95  if (UNLIKELY(needles.empty() || haystack.empty())) {
96  return std::string::npos;
97  }
98  // The thresholds below were empirically determined by benchmarking.
99  // This is not an exact science since it depends on the CPU, the size of
100  // needles, and the size of haystack.
101  if ((needles.size() >= 4 && haystack.size() <= 10) ||
102  (needles.size() >= 16 && haystack.size() <= 64) || needles.size() >= 32) {
103  return qfind_first_byte_of_byteset(haystack, needles);
104  }
105  return qfind_first_byte_of_std(haystack, needles);
106 }
size_t qfind_first_byte_of_std(const StringPieceLite haystack, const StringPieceLite needles)
Definition: RangeCommon.h:72
size_t qfind_first_byte_of_byteset(const StringPieceLite haystack, const StringPieceLite needles)
Definition: RangeCommon.cpp:42
#define UNLIKELY(x)
Definition: Likely.h:48
size_t folly::detail::qfind_first_byte_of_sse42 ( const StringPieceLite  haystack,
const StringPieceLite  needles 
)
size_t folly::detail::qfind_first_byte_of_std ( const StringPieceLite  haystack,
const StringPieceLite  needles 
)
inline

Definition at line 72 of file RangeCommon.h.

References a, b, folly::detail::StringPieceLite::begin(), folly::detail::StringPieceLite::end(), qfind_first_byte_of_bitset(), and qfind_first_byte_of_byteset().

Referenced by BENCHMARK_RELATIVE(), qfind_first_byte_of_nosse(), and qfind_first_byte_of_sse42().

74  {
75  auto ret = std::find_first_of(
76  haystack.begin(),
77  haystack.end(),
78  needles.begin(),
79  needles.end(),
80  [](char a, char b) { return a == b; });
81  return ret == haystack.end() ? std::string::npos : ret - haystack.begin();
82 }
char b
char a
template<typename ReturnType = double, typename Duration = std::chrono::seconds, typename Interval = Duration>
ReturnType folly::detail::rateHelper ( ReturnType  count,
Duration  elapsed 
)

Definition at line 65 of file Bucket.h.

65  {
66  if (elapsed == Duration(0)) {
67  return 0;
68  }
69 
70  // Use std::chrono::duration_cast to convert between the native
71  // duration and the desired interval. However, convert the rates,
72  // rather than just converting the elapsed duration. Converting the
73  // elapsed time first may collapse it down to 0 if the elapsed interval
74  // is less than the desired interval, which will incorrectly result in
75  // an infinite rate.
76  typedef std::chrono::duration<
77  ReturnType,
78  std::ratio<Duration::period::den, Duration::period::num>>
79  NativeRate;
80  typedef std::chrono::duration<
81  ReturnType,
82  std::ratio<Interval::period::den, Interval::period::num>>
83  DesiredRate;
84 
85  NativeRate native(count / elapsed.count());
86  DesiredRate desired = std::chrono::duration_cast<DesiredRate>(native);
87  return desired.count();
88 }
int * count
StatsClock::duration Duration
template<typename Alloc , size_t kAlign, bool kAllocate>
void folly::detail::rawOverAlignedImpl ( Alloc const &  alloc,
size_t  n,
void *&  raw 
)

Definition at line 97 of file Memory.h.

References a, folly::aligned_free(), folly::aligned_malloc(), folly::constexpr_min(), folly::T, and folly::value().

97  {
98  static_assert((kAlign & (kAlign - 1)) == 0, "Align must be a power of 2");
99 
100  using AllocTraits = std::allocator_traits<Alloc>;
101  using T = typename AllocTraits::value_type;
102 
103  constexpr bool kCanBypass = std::is_same<Alloc, std::allocator<T>>::value;
104 
105  // BaseType is a type that gives us as much alignment as we need if
106  // we can get it naturally, otherwise it is aligned as max_align_t.
107  // kBaseAlign is both the alignment and size of this type.
108  constexpr size_t kBaseAlign = constexpr_min(kAlign, alignof(max_align_t));
109  using BaseType = std::aligned_storage_t<kBaseAlign, kBaseAlign>;
110  using BaseAllocTraits =
111  typename AllocTraits::template rebind_traits<BaseType>;
112  using BaseAlloc = typename BaseAllocTraits::allocator_type;
113  static_assert(
114  sizeof(BaseType) == kBaseAlign && alignof(BaseType) == kBaseAlign, "");
115 
116 #if __cpp_sized_deallocation
117  if (kCanBypass && kAlign == kBaseAlign) {
118  // until std::allocator uses sized deallocation, it is worth the
119  // effort to bypass it when we are able
120  if (kAllocate) {
121  raw = ::operator new(n * sizeof(T));
122  } else {
123  ::operator delete(raw, n * sizeof(T));
124  }
125  return;
126  }
127 #endif
128 
129  if (kCanBypass && kAlign > kBaseAlign) {
130  // allocating as BaseType isn't sufficient to get alignment, but
131  // since we can bypass Alloc we can use something like posix_memalign
132  if (kAllocate) {
133  raw = aligned_malloc(n * sizeof(T), kAlign);
134  } else {
135  aligned_free(raw);
136  }
137  return;
138  }
139 
140  // we're not allowed to bypass Alloc, or we don't want to
141  BaseAlloc a(alloc);
142 
143  // allocation size is counted in sizeof(BaseType)
144  size_t quanta = (n * sizeof(T) + kBaseAlign - 1) / sizeof(BaseType);
145  if (kAlign <= kBaseAlign) {
146  // rebinding Alloc to BaseType is sufficient to get us the alignment
147  // we want, happy path
148  if (kAllocate) {
149  raw = static_cast<void*>(
150  std::addressof(*BaseAllocTraits::allocate(a, quanta)));
151  } else {
152  BaseAllocTraits::deallocate(
153  a,
154  std::pointer_traits<typename BaseAllocTraits::pointer>::pointer_to(
155  *static_cast<BaseType*>(raw)),
156  quanta);
157  }
158  return;
159  }
160 
161  // Overaligned and custom allocator, our only option is to
162  // overallocate and store a delta to the actual allocation just
163  // before the returned ptr.
164  //
165  // If we give ourselves kAlign extra bytes, then since
166  // sizeof(BaseType) divides kAlign we can meet alignment while
167  // getting a prefix of one BaseType. If we happen to get a
168  // kAlign-aligned block, then we can return a pointer to underlying
169  // + kAlign, otherwise there will be at least kBaseAlign bytes in
170  // the unused prefix of the first kAlign-aligned block.
171  if (kAllocate) {
172  char* base = reinterpret_cast<char*>(std::addressof(
173  *BaseAllocTraits::allocate(a, quanta + kAlign / sizeof(BaseType))));
174  size_t byteDelta =
175  kAlign - (reinterpret_cast<uintptr_t>(base) & (kAlign - 1));
176  raw = static_cast<void*>(base + byteDelta);
177  static_cast<size_t*>(raw)[-1] = byteDelta;
178  } else {
179  size_t byteDelta = static_cast<size_t*>(raw)[-1];
180  char* base = static_cast<char*>(raw) - byteDelta;
181  BaseAllocTraits::deallocate(
182  a,
183  std::pointer_traits<typename BaseAllocTraits::pointer>::pointer_to(
184  *reinterpret_cast<BaseType*>(base)),
185  quanta + kAlign / sizeof(BaseType));
186  }
187 }
#define T(v)
Definition: http_parser.c:233
constexpr T constexpr_min(T a)
Definition: ConstexprMath.h:79
void aligned_free(void *aligned_ptr)
Definition: Memory.h:89
void * aligned_malloc(size_t size, size_t align)
Definition: Memory.h:85
char a
static const char *const value
Definition: Conv.cpp:50
template<typename Synchronized , typename... Args>
auto folly::detail::rlock ( Synchronized synchronized,
Args &&...  args 
)

Definition at line 935 of file Synchronized.h.

References a, testing::Args(), makeSynchronizedLocker(), and s.

Referenced by folly::rlock(), and runFairness().

935  {
937  synchronized,
938  [](auto& s, auto&&... a) {
939  return s.rlock(std::forward<decltype(a)>(a)...);
940  },
941  [](auto& s) { return s.tryRLock(); },
942  std::forward<Args>(args)...);
943 }
auto makeSynchronizedLocker(Synchronized &synchronized, LockFunc &&lockFunc, TryLockFunc &&tryLockFunc, Args &&...args)
Definition: Synchronized.h:837
char a
static set< string > s
std::unique_lock< std::mutex > folly::detail::sharedMutexAnnotationGuard ( void *  ptr)

Definition at line 25 of file SharedMutex.cpp.

References folly::kIsSanitizeThread, and ptr.

Referenced by folly::SharedMutexImpl< true >::annotateLazyCreate().

25  {
27  // On TSAN builds, we have an array of mutexes and index into them based on
28  // the address. If the array is of prime size things will work out okay
29  // without a complicated hash function.
30  static constexpr std::size_t kNumAnnotationMutexes = 251;
31  static std::array<std::mutex, kNumAnnotationMutexes> kAnnotationMutexes{};
32  auto index = reinterpret_cast<uintptr_t>(ptr) % kNumAnnotationMutexes;
33  return std::unique_lock<std::mutex>(kAnnotationMutexes[index]);
34  } else {
35  return std::unique_lock<std::mutex>();
36  }
37 }
void * ptr
constexpr bool kIsSanitizeThread
Definition: Portability.h:124
template<typename... Arguments>
std::vector<std::string> folly::detail::shellify ( StringPiece  format,
Arguments &&...  arguments 
)

Definition at line 43 of file Shell.h.

References folly::sformat(), and folly::shellQuote().

Referenced by folly::shellify().

45  {
46  auto command = sformat(
47  format,
48  shellQuote(to<std::string>(std::forward<Arguments>(arguments)))...);
49  return {"/bin/sh", "-c", command};
50 }
std::string sformat(StringPiece fmt, Args &&...args)
Definition: Format.h:280
std::string shellQuote(StringPiece argument)
Definition: Shell.cpp:21
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
Definition: Format.h:271
void* folly::detail::shiftPointer ( void *  p,
size_t  sizeBytes 
)
inline
static void folly::detail::singleton_hs_init_weak ( int *  argc,
char **  argv[] 
)
static
void folly::detail::singletonPrintDestructionStackTrace ( const TypeDescriptor type)

Definition at line 159 of file Singleton.cpp.

References folly::detail::TypeDescriptor::name(), gmock_output_test::output, folly::SingletonVault::stackTraceGetter(), and string.

Referenced by folly::detail::SingletonHolder< T >::createInstance(), and folly::detail::TypeDescriptorHasher::operator()().

159  {
160  std::string output = "Singleton " + type.name() + " was released.\n";
161 
162  auto stack_trace_getter = SingletonVault::stackTraceGetter().load();
163  auto stack_trace = stack_trace_getter ? stack_trace_getter() : "";
164  if (stack_trace.empty()) {
165  output += "Failed to get release stack trace.";
166  } else {
167  output += "Release stack trace:\n";
168  output += stack_trace;
169  }
170 
171  LOG(ERROR) << output;
172 }
PskType type
const char * string
Definition: Conv.cpp:212
void folly::detail::singletonThrowGetInvokedAfterDestruction ( const TypeDescriptor type)

Definition at line 181 of file Singleton.cpp.

References folly::DFATAL, leakedSingletons_, folly::detail::TypeDescriptor::name(), folly::singleton, and string.

Referenced by folly::detail::SingletonHolder< T >::get(), and folly::detail::TypeDescriptorHasher::operator()().

182  {
183  throw std::runtime_error(
184  "Raw pointer to a singleton requested after its destruction."
185  " Singleton type is: " +
186  type.name());
187 }
PskType type
void folly::detail::singletonThrowNullCreator ( const std::type_info &  type)

Definition at line 174 of file Singleton.cpp.

References folly::demangle(), and folly::sformat().

Referenced by folly::Singleton< folly::observer_detail::ObserverManager >::make_mock(), folly::LeakySingleton< T, Tag >::make_mock(), folly::detail::TypeDescriptorHasher::operator()(), and folly::Singleton< folly::observer_detail::ObserverManager >::Singleton().

174  {
175  auto const msg = sformat(
176  "nullptr_t should be passed if you want {} to be default constructed",
177  demangle(type));
178  throw std::logic_error(msg);
179 }
std::string sformat(StringPiece fmt, Args &&...args)
Definition: Format.h:280
PskType type
fbstring demangle(const char *name)
Definition: Demangle.cpp:111
void folly::detail::singletonWarnCreateBeforeRegistrationCompleteAndAbort ( const TypeDescriptor type)

Definition at line 143 of file Singleton.cpp.

References folly::FATAL, folly::detail::TypeDescriptor::name(), and folly::SingletonVault::stackTraceGetter().

Referenced by folly::detail::SingletonHolder< T >::createInstance(), and folly::detail::TypeDescriptorHasher::operator()().

144  {
145  auto stack_trace_getter = SingletonVault::stackTraceGetter().load();
146  auto stack_trace = stack_trace_getter ? stack_trace_getter() : "";
147  if (!stack_trace.empty()) {
148  stack_trace = "Stack trace:\n" + stack_trace;
149  }
150 
151  LOG(FATAL) << "Singleton " << type.name() << " requested before "
152  << "registrationComplete() call.\n"
153  << "This usually means that either main() never called "
154  << "folly::init, or singleton was requested before main() "
155  << "(which is not allowed).\n"
156  << stack_trace;
157 }
PskType type
void folly::detail::singletonWarnCreateCircularDependencyAndAbort ( const TypeDescriptor type)

Definition at line 128 of file Singleton.cpp.

References folly::FATAL, and folly::detail::TypeDescriptor::name().

Referenced by folly::detail::SingletonHolder< T >::createInstance(), and folly::detail::TypeDescriptorHasher::operator()().

129  {
130  LOG(FATAL) << "circular singleton dependency: " << type.name();
131 }
PskType type
void folly::detail::singletonWarnCreateUnregisteredAndAbort ( const TypeDescriptor type)

Definition at line 133 of file Singleton.cpp.

References folly::FATAL, folly::detail::TypeDescriptor::name(), ptr, and folly::SingletonVault::stackTraceGetter().

Referenced by folly::detail::SingletonHolder< T >::createInstance(), and folly::detail::TypeDescriptorHasher::operator()().

134  {
135  auto ptr = SingletonVault::stackTraceGetter().load();
136  LOG(FATAL) << "Creating instance for unregistered singleton: " << type.name()
137  << "\n"
138  << "Stacktrace:"
139  << "\n"
140  << (ptr ? (*ptr)() : "(not available)");
141 }
void * ptr
PskType type
void folly::detail::singletonWarnDestroyInstanceLeak ( const TypeDescriptor type,
const void *  ptr 
)

Definition at line 115 of file Singleton.cpp.

References folly::detail::TypeDescriptor::name().

Referenced by folly::detail::SingletonHolder< T >::destroyInstance(), and folly::detail::TypeDescriptorHasher::operator()().

117  {
118  LOG(ERROR) << "Singleton of type " << type.name() << " has a "
119  << "living reference at destroyInstances time; beware! Raw "
120  << "pointer is " << ptr << ". It is very likely "
121  << "that some other singleton is holding a shared_ptr to it. "
122  << "This singleton will be leaked (even if a shared_ptr to it "
123  << "is eventually released)."
124  << "Make sure dependencies between these singletons are "
125  << "properly defined.";
126 }
void * ptr
PskType type
void folly::detail::singletonWarnDoubleRegistrationAndAbort ( const TypeDescriptor type)

Definition at line 77 of file Singleton.cpp.

References folly::detail::TypeDescriptor::name().

Referenced by folly::detail::SingletonHolder< T >::registerSingleton(), and folly::detail::SingletonHolder< T >::singleton().

78  {
79  // Ensure the availability of std::cerr
80  std::ios_base::Init ioInit;
81  std::cerr << "Double registration of singletons of the same "
82  "underlying type; check for multiple definitions "
83  "of type folly::Singleton<"
84  << type.name() << ">\n";
85  std::abort();
86 }
PskType type
void folly::detail::singletonWarnLeakyDoubleRegistrationAndAbort ( const TypeDescriptor type)

Definition at line 88 of file Singleton.cpp.

References folly::detail::TypeDescriptor::name().

Referenced by folly::LeakySingleton< T, Tag >::LeakySingleton(), and folly::detail::TypeDescriptorHasher::operator()().

89  {
90  // Ensure the availability of std::cerr
91  std::ios_base::Init ioInit;
92  std::cerr << "Double registration of singletons of the same "
93  "underlying type; check for multiple definitions "
94  "of type folly::LeakySingleton<"
95  << type.name() << ">\n";
96  std::abort();
97 }
PskType type
void folly::detail::singletonWarnLeakyInstantiatingNotRegisteredAndAbort ( const TypeDescriptor type)

Definition at line 99 of file Singleton.cpp.

References folly::FATAL, folly::detail::TypeDescriptor::name(), ptr, and folly::SingletonVault::stackTraceGetter().

Referenced by folly::LeakySingleton< T, Tag >::createInstance(), and folly::detail::TypeDescriptorHasher::operator()().

100  {
101  auto ptr = SingletonVault::stackTraceGetter().load();
102  LOG(FATAL) << "Creating instance for unregistered singleton: " << type.name()
103  << "\n"
104  << "Stacktrace:"
105  << "\n"
106  << (ptr ? (*ptr)() : "(not available)");
107 }
void * ptr
PskType type
void folly::detail::singletonWarnRegisterMockEarlyAndAbort ( const TypeDescriptor type)

Definition at line 109 of file Singleton.cpp.

References folly::FATAL, and folly::detail::TypeDescriptor::name().

Referenced by folly::detail::TypeDescriptorHasher::operator()(), and folly::detail::SingletonHolder< T >::registerSingletonMock().

110  {
111  LOG(FATAL) << "Registering mock before singleton was registered: "
112  << type.name();
113 }
PskType type
template<typename Clock , typename Duration , typename F >
spin_result folly::detail::spin_pause_until ( std::chrono::time_point< Clock, Duration > const &  deadline,
WaitOptions const &  opt,
f 
)

Definition at line 36 of file Spin.h.

References advance, folly::asm_volatile_pause(), f, min, now(), folly::WaitOptions::spin_max(), success, and timeout.

Referenced by folly::UnboundedQueue< T, false, 6 >::getAllocNextSegment(), folly::RelaxedConcurrentPriorityQueue< T, MayBlock, SupportsSize, PopBatch, ListTargetSize, Mutex, Atom >::trySpinBeforeBlock(), folly::RelaxedConcurrentPriorityQueue< T, MayBlock, SupportsSize, PopBatch, ListTargetSize, Mutex, Atom >::tryWait(), folly::Baton< MayBlock, Atom >::tryWaitSlow(), and folly::SaturatingSemaphore< MayBlock, Atom >::tryWaitSlow().

39  {
40  if (opt.spin_max() <= opt.spin_max().zero()) {
41  return spin_result::advance;
42  }
43 
44  auto tbegin = Clock::now();
45  while (true) {
46  if (f()) {
47  return spin_result::success;
48  }
49 
50  auto const tnow = Clock::now();
51  if (tnow >= deadline) {
52  return spin_result::timeout;
53  }
54 
55  // Backward time discontinuity in Clock? revise pre_block starting point
56  tbegin = std::min(tbegin, tnow);
57  if (tnow >= tbegin + opt.spin_max()) {
58  return spin_result::advance;
59  }
60 
61  // The pause instruction is the polite way to spin, but it doesn't
62  // actually affect correctness to omit it if we don't have it. Pausing
63  // donates the full capabilities of the current core to its other
64  // hyperthreads for a dozen cycles or so.
66  }
67 }
auto f
std::chrono::steady_clock::time_point now()
LogLevel min
Definition: LogLevel.cpp:30
void asm_volatile_pause()
Definition: Asm.h:37
template<typename Clock , typename Duration , typename F >
spin_result folly::detail::spin_yield_until ( std::chrono::time_point< Clock, Duration > const &  deadline,
f 
)

Definition at line 70 of file Spin.h.

References f, max, now(), success, timeout, and folly::fibers::yield().

Referenced by TEST(), folly::RelaxedConcurrentPriorityQueue< T, MayBlock, SupportsSize, PopBatch, ListTargetSize, Mutex, Atom >::tryWait(), folly::Baton< MayBlock, Atom >::tryWaitSlow(), and folly::SaturatingSemaphore< MayBlock, Atom >::tryWaitSlow().

72  {
73  while (true) {
74  if (f()) {
75  return spin_result::success;
76  }
77 
79  if (deadline != max && Clock::now() >= deadline) {
80  return spin_result::timeout;
81  }
82 
84  }
85 }
auto f
LogLevel max
Definition: LogLevel.cpp:31
std::chrono::steady_clock::time_point now()
template<bool exact, class Delim , class OutputType >
bool folly::detail::splitFixed ( const Delim &  delimiter,
StringPiece  input,
OutputType output 
)

Definition at line 343 of file String-inl.h.

References folly::Range< Iter >::find(), toOrIgnore(), UNLIKELY, value, and folly::value().

343  {
344  static_assert(
347  std::is_same<OutputType, decltype(std::ignore)>::value,
348  "split<false>() requires that the last argument be a string type "
349  "or std::ignore");
350  if (exact && UNLIKELY(std::string::npos != input.find(delimiter))) {
351  return false;
352  }
353  toOrIgnore(input, output);
354  return true;
355 }
static const char *const value
Definition: Conv.cpp:50
void toOrIgnore(StringPiece, decltype(std::ignore)&)
Definition: String-inl.h:340
#define UNLIKELY(x)
Definition: Likely.h:48
template<bool exact, class Delim , class OutputType , class... OutputTypes>
bool folly::detail::splitFixed ( const Delim &  delimiter,
StringPiece  input,
OutputType outHead,
OutputTypes &...  outTail 
)

Definition at line 358 of file String-inl.h.

References folly::Range< Iter >::begin(), delimSize(), folly::Range< Iter >::end(), folly::Range< Iter >::find(), LIKELY, toOrIgnore(), and UNLIKELY.

362  {
363  size_t cut = input.find(delimiter);
364  if (UNLIKELY(cut == std::string::npos)) {
365  return false;
366  }
367  StringPiece head(input.begin(), input.begin() + cut);
368  StringPiece tail(
369  input.begin() + cut + detail::delimSize(delimiter), input.end());
370  if (LIKELY(splitFixed<exact>(delimiter, tail, outTail...))) {
371  toOrIgnore(head, outHead);
372  return true;
373  }
374  return false;
375 }
size_t delimSize(StringPiece s)
Definition: String-inl.h:252
#define LIKELY(x)
Definition: Likely.h:47
void toOrIgnore(StringPiece, decltype(std::ignore)&)
Definition: String-inl.h:340
Range< const char * > StringPiece
#define UNLIKELY(x)
Definition: Likely.h:48
Expected<bool, ConversionCode> folly::detail::str_to_bool ( StringPiece src)
noexcept

Definition at line 266 of file Conv.cpp.

References b, folly::BOOL_INVALID_VALUE, folly::BOOL_OVERFLOW, folly::EMPTY_INPUT_STRING, and folly::makeUnexpected().

Referenced by folly::toAppendStrImpl().

266  {
267  auto b = src->begin(), e = src->end();
268  for (;; ++b) {
269  if (b >= e) {
270  return makeUnexpected(ConversionCode::EMPTY_INPUT_STRING);
271  }
272  if (!std::isspace(*b)) {
273  break;
274  }
275  }
276 
277  bool result;
278  size_t len = size_t(e - b);
279  switch (*b) {
280  case '0':
281  case '1': {
282  result = false;
283  for (; b < e && isdigit(*b); ++b) {
284  if (result || (*b != '0' && *b != '1')) {
285  return makeUnexpected(ConversionCode::BOOL_OVERFLOW);
286  }
287  result = (*b == '1');
288  }
289  break;
290  }
291  case 'y':
292  case 'Y':
293  result = true;
294  if (!bool_str_cmp(&b, len, "yes")) {
295  ++b; // accept the single 'y' character
296  }
297  break;
298  case 'n':
299  case 'N':
300  result = false;
301  if (!bool_str_cmp(&b, len, "no")) {
302  ++b;
303  }
304  break;
305  case 't':
306  case 'T':
307  result = true;
308  if (!bool_str_cmp(&b, len, "true")) {
309  ++b;
310  }
311  break;
312  case 'f':
313  case 'F':
314  result = false;
315  if (!bool_str_cmp(&b, len, "false")) {
316  ++b;
317  }
318  break;
319  case 'o':
320  case 'O':
321  if (bool_str_cmp(&b, len, "on")) {
322  result = true;
323  } else if (bool_str_cmp(&b, len, "off")) {
324  result = false;
325  } else {
326  return makeUnexpected(ConversionCode::BOOL_INVALID_VALUE);
327  }
328  break;
329  default:
330  return makeUnexpected(ConversionCode::BOOL_INVALID_VALUE);
331  }
332 
333  src->assign(b, e);
334 
335  return result;
336 }
char b
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
template<class Tgt >
Expected<Tgt, ConversionCode> folly::detail::str_to_floating ( StringPiece src)
noexcept

StringPiece to double, with progress information. Alters the StringPiece parameter to munch the already-parsed characters.

Definition at line 343 of file Conv.cpp.

References b, c, folly::EMPTY_INPUT_STRING, folly::makeUnexpected(), folly::pushmi::__adl::noexcept(), folly::size(), str_to_floating< double >(), str_to_floating< float >(), folly::STRING_TO_FLOAT_ERROR, suffix, and value.

Referenced by folly::toAppendStrImpl().

343  {
344  using namespace double_conversion;
345  static StringToDoubleConverter conv(
346  StringToDoubleConverter::ALLOW_TRAILING_JUNK |
347  StringToDoubleConverter::ALLOW_LEADING_SPACES,
348  0.0,
349  // return this for junk input string
350  std::numeric_limits<double>::quiet_NaN(),
351  nullptr,
352  nullptr);
353 
354  if (src->empty()) {
355  return makeUnexpected(ConversionCode::EMPTY_INPUT_STRING);
356  }
357 
358  int length;
359  auto result = conv.StringToDouble(
360  src->data(),
361  static_cast<int>(src->size()),
362  &length); // processed char count
363 
364  if (!std::isnan(result)) {
365  // If we get here with length = 0, the input string is empty.
366  // If we get here with result = 0.0, it's either because the string
367  // contained only whitespace, or because we had an actual zero value
368  // (with potential trailing junk). If it was only whitespace, we
369  // want to raise an error; length will point past the last character
370  // that was processed, so we need to check if that character was
371  // whitespace or not.
372  if (length == 0 ||
373  (result == 0.0 && std::isspace((*src)[size_t(length) - 1]))) {
374  return makeUnexpected(ConversionCode::EMPTY_INPUT_STRING);
375  }
376  if (length >= 2) {
377  const char* suffix = src->data() + length - 1;
378  // double_conversion doesn't update length correctly when there is an
379  // incomplete exponent specifier. Converting "12e-f-g" shouldn't consume
380  // any more than "12", but it will consume "12e-".
381 
382  // "123-" should only parse "123"
383  if (*suffix == '-' || *suffix == '+') {
384  --suffix;
385  --length;
386  }
387  // "12e-f-g" or "12euro" should only parse "12"
388  if (*suffix == 'e' || *suffix == 'E') {
389  --length;
390  }
391  }
392  src->advance(size_t(length));
393  return Tgt(result);
394  }
395 
396  auto* e = src->end();
397  auto* b =
398  std::find_if_not(src->begin(), e, [](char c) { return std::isspace(c); });
399 
400  // There must be non-whitespace, otherwise we would have caught this above
401  assert(b < e);
402  size_t size = size_t(e - b);
403 
404  bool negative = false;
405  if (*b == '-') {
406  negative = true;
407  ++b;
408  --size;
409  }
410 
411  result = 0.0;
412 
413  switch (tolower_ascii(*b)) {
414  case 'i':
415  if (size >= 3 && tolower_ascii(b[1]) == 'n' &&
416  tolower_ascii(b[2]) == 'f') {
417  if (size >= 8 && tolower_ascii(b[3]) == 'i' &&
418  tolower_ascii(b[4]) == 'n' && tolower_ascii(b[5]) == 'i' &&
419  tolower_ascii(b[6]) == 't' && tolower_ascii(b[7]) == 'y') {
420  b += 8;
421  } else {
422  b += 3;
423  }
424  result = std::numeric_limits<Tgt>::infinity();
425  }
426  break;
427 
428  case 'n':
429  if (size >= 3 && tolower_ascii(b[1]) == 'a' &&
430  tolower_ascii(b[2]) == 'n') {
431  b += 3;
432  result = std::numeric_limits<Tgt>::quiet_NaN();
433  }
434  break;
435 
436  default:
437  break;
438  }
439 
440  if (result == 0.0) {
441  // All bets are off
442  return makeUnexpected(ConversionCode::STRING_TO_FLOAT_ERROR);
443  }
444 
445  if (negative) {
446  result = -result;
447  }
448 
449  src->assign(b, e);
450 
451  return Tgt(result);
452 }
char b
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
const char * suffix
Definition: String.cpp:272
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
char c
template Expected<double, ConversionCode> folly::detail::str_to_floating< double > ( StringPiece src)
noexcept
template Expected<float, ConversionCode> folly::detail::str_to_floating< float > ( StringPiece src)
noexcept
template<class Tgt >
Expected<Tgt, ConversionCode> folly::detail::str_to_integral ( StringPiece src)
noexcept

StringPiece to integrals, with progress information. Alters the StringPiece parameter to munch the already-parsed characters.

Definition at line 683 of file Conv.cpp.

References b, folly::EMPTY_INPUT_STRING, m, folly::makeUnexpected(), folly::NO_DIGITS, folly::pushmi::__adl::noexcept(), folly::NON_DIGIT_CHAR, folly::POSITIVE_OVERFLOW, str_to_integral< char >(), str_to_integral< int >(), str_to_integral< long >(), str_to_integral< long long >(), str_to_integral< short >(), str_to_integral< signed char >(), str_to_integral< unsigned char >(), str_to_integral< unsigned int >(), str_to_integral< unsigned long >(), str_to_integral< unsigned long long >(), str_to_integral< unsigned short >(), folly::SUCCESS, type, UNLIKELY, and value.

Referenced by folly::toAppendStrImpl().

683  {
684  using UT = typename std::make_unsigned<Tgt>::type;
685 
686  auto b = src->data(), past = src->data() + src->size();
687 
688  for (;; ++b) {
689  if (UNLIKELY(b >= past)) {
690  return makeUnexpected(ConversionCode::EMPTY_INPUT_STRING);
691  }
692  if (!std::isspace(*b)) {
693  break;
694  }
695  }
696 
697  SignedValueHandler<Tgt> sgn;
698  auto err = sgn.init(b);
699 
700  if (UNLIKELY(err != ConversionCode::SUCCESS)) {
701  return makeUnexpected(err);
702  }
703  if (std::is_signed<Tgt>::value && UNLIKELY(b >= past)) {
704  return makeUnexpected(ConversionCode::NO_DIGITS);
705  }
706  if (UNLIKELY(!isdigit(*b))) {
707  return makeUnexpected(ConversionCode::NON_DIGIT_CHAR);
708  }
709 
710  auto m = findFirstNonDigit(b + 1, past);
711 
712  auto tmp = digits_to<UT>(b, m);
713 
714  if (UNLIKELY(!tmp.hasValue())) {
715  return makeUnexpected(
716  tmp.error() == ConversionCode::POSITIVE_OVERFLOW ? sgn.overflow()
717  : tmp.error());
718  }
719 
720  auto res = sgn.finalize(tmp.value());
721 
722  if (res.hasValue()) {
723  src->advance(size_t(m - src->data()));
724  }
725 
726  return res;
727 }
char b
PskType type
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
static map< string, int > m
static const char *const value
Definition: Conv.cpp:50
#define UNLIKELY(x)
Definition: Likely.h:48
template Expected<char, ConversionCode> folly::detail::str_to_integral< char > ( StringPiece src)
noexcept
template Expected<long, ConversionCode> folly::detail::str_to_integral< long > ( StringPiece src)
noexcept
template Expected<long long, ConversionCode> folly::detail::str_to_integral< long long > ( StringPiece src)
noexcept
template Expected<short, ConversionCode> folly::detail::str_to_integral< short > ( StringPiece src)
noexcept
template Expected<signed char, ConversionCode> folly::detail::str_to_integral< signed char > ( StringPiece src)
noexcept
template Expected<unsigned char, ConversionCode> folly::detail::str_to_integral< unsigned char > ( StringPiece src)
noexcept
template Expected<unsigned int, ConversionCode> folly::detail::str_to_integral< unsigned int > ( StringPiece src)
noexcept
template Expected<unsigned long, ConversionCode> folly::detail::str_to_integral< unsigned long > ( StringPiece src)
noexcept
template Expected<unsigned long long, ConversionCode> folly::detail::str_to_integral< unsigned long long > ( StringPiece src)
noexcept
template Expected<unsigned short, ConversionCode> folly::detail::str_to_integral< unsigned short > ( StringPiece src)
noexcept
int folly::detail::sysMembarrier ( )

Definition at line 58 of file SysMembarrier.cpp.

Referenced by folly::asymmetricHeavyBarrier().

58  {
59 #if FOLLY_USE_SYS_MEMBARRIER
60  return syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, /* flags = */ 0);
61 #else
62  return -1;
63 #endif
64 }
bool folly::detail::sysMembarrierAvailable ( )

Definition at line 41 of file SysMembarrier.cpp.

References folly::kIsLinux.

Referenced by folly::asymmetricHeavyBarrier().

41  {
42  if (!kIsLinux) {
43  return false;
44  }
45 
46 #if FOLLY_USE_SYS_MEMBARRIER
47  auto r = syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, /* flags = */ 0);
48  if (r == -1) {
49  return false;
50  }
51 
52  return r & MEMBARRIER_CMD_SHARED;
53 #else
54  return false;
55 #endif
56 }
constexpr auto kIsLinux
Definition: Portability.h:361
template<typename Ex , typename... Args>
FOLLY_NOINLINE FOLLY_COLD void folly::detail::terminate_with_ ( Args &&...  args)
noexcept

Definition at line 65 of file Exception.h.

References testing::Args(), FOLLY_ALWAYS_INLINE, FOLLY_ATTR_VISIBILITY_HIDDEN, and folly::throw_exception().

66  {
67  throw_exception(Ex(static_cast<Args&&>(args)...));
68 }
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN void throw_exception(Args &&...args)
Definition: Exception.h:80
folly::detail::TEST_F ( StaticSingletonManagerTest  ,
example   
)

Definition at line 29 of file StaticSingletonManagerTest.cpp.

References ASSERT_NE, EXPECT_EQ, EXPECT_NE, i, k, and folly::gen::move.

29  {
30  auto make3 = [n = 3] { return new int(n); };
31  auto i = createGlobal<int, Tag<char>>(make3);
32  ASSERT_NE(nullptr, i);
33  EXPECT_EQ(3, *i);
34 
35  auto const make4 = [n = 4] { return new int(n); };
36  auto j = createGlobal<int, Tag<char>>(make4);
37  ASSERT_NE(nullptr, j);
38  EXPECT_EQ(i, j);
39  EXPECT_EQ(3, *j);
40 
41  auto make5 = [n = 5] { return new int(n); };
42  auto k = createGlobal<int, Tag<char*>>(std::move(make5));
43  ASSERT_NE(nullptr, k);
44  EXPECT_NE(i, k);
45  EXPECT_EQ(5, *k);
46 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define ASSERT_NE(val1, val2)
Definition: gtest.h:1960
KeyT k
int folly::detail::tfo_enable ( int  sockfd,
size_t  max_queue_size 
)

Enable TFO on a listening socket.

Definition at line 113 of file SocketFastOpen.cpp.

Referenced by folly::AsyncServerSocket::setupSocket(), and TestServer::TestServer().

113  {
114  errno = ENOPROTOOPT;
115  return -1;
116 }
ssize_t folly::detail::tfo_sendmsg ( int  sockfd,
const struct msghdr *  msg,
int  flags 
)

tfo_sendto has the same semantics as sendmsg, but is used to send with TFO data.

Definition at line 108 of file SocketFastOpen.cpp.

Referenced by folly::AsyncSocket::tfoSendMsg().

108  {
109  errno = EOPNOTSUPP;
110  return -1;
111 }
bool folly::detail::tfo_succeeded ( int  sockfd)

Check if TFO succeeded in being used.

Definition at line 118 of file SocketFastOpen.cpp.

Referenced by folly::AsyncSocket::getTFOSucceded().

118  {
119  errno = EOPNOTSUPP;
120  return false;
121 }
template<typename Ex , typename... Args>
FOLLY_NOINLINE FOLLY_COLD void folly::detail::throw_exception_ ( Args &&...  args)

Definition at line 61 of file Exception.h.

References testing::Args(), and folly::throw_exception().

61  {
62  throw_exception(Ex(static_cast<Args&&>(args)...));
63 }
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN void throw_exception(Args &&...args)
Definition: Exception.h:80
template<typename TargetClock , typename Clock , typename Duration >
TargetClock::time_point folly::detail::time_point_conv ( std::chrono::time_point< Clock, Duration > const &  time)

Optimal when TargetClock is the same type as Clock.

Otherwise, both Clock::now() and TargetClock::now() must be invoked.

Definition at line 29 of file Futex-inl.h.

References count, futexWaitImpl(), futexWakeImpl(), max, now(), type, uint32_t, and value.

30  {
31  using std::chrono::duration_cast;
32  using TimePoint = std::chrono::time_point<Clock, Duration>;
33  using TargetDuration = typename TargetClock::duration;
34  using TargetTimePoint = typename TargetClock::time_point;
35  if (time == TimePoint::max()) {
36  return TargetTimePoint::max();
38  // in place of time_point_cast, which cannot compile without if-constexpr
39  auto const delta = time.time_since_epoch();
40  return TargetTimePoint(duration_cast<TargetDuration>(delta));
41  } else {
42  // different clocks with different epochs, so non-optimal case
43  auto const delta = time - Clock::now();
44  return TargetClock::now() + duration_cast<TargetDuration>(delta);
45  }
46 }
LogLevel max
Definition: LogLevel.cpp:31
std::chrono::steady_clock::time_point now()
static const char *const value
Definition: Conv.cpp:50
StatsClock::time_point TimePoint
std::chrono::nanoseconds time()
template<typename T >
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T&& folly::detail::to_exception_arg_ ( T &&  t)

Definition at line 52 of file Exception.h.

References folly::pushmi::detail::t, and folly::T.

Referenced by folly::terminate_with(), and folly::throw_exception().

52  {
53  return static_cast<T&&>(t);
54 }
#define T(v)
Definition: http_parser.c:233
template<std::size_t N>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN char const* folly::detail::to_exception_arg_ ( char const (&)  array[N])

Definition at line 56 of file Exception.h.

References testing::Args(), and upload::const.

57  {
58  return static_cast<char const*>(array);
59 }
const
Definition: upload.py:398
template<class OutputType >
void folly::detail::toOrIgnore ( StringPiece  input,
OutputType output 
)

Definition at line 336 of file String-inl.h.

Referenced by splitFixed().

336  {
337  output = folly::to<OutputType>(input);
338 }
void folly::detail::toOrIgnore ( StringPiece  ,
decltype(std::ignore)&   
)
inline

Definition at line 340 of file String-inl.h.

340 {}
std::string folly::detail::toPseudoJson ( const folly::dynamic d)

Definition at line 194 of file DynamicParser.cpp.

Referenced by folly::DynamicParser::reportError(), and folly::DynamicParser::required().

194  {
195  std::stringstream ss;
196  ss << d;
197  return ss.str();
198 }
template<typename F >
exception_wrapper folly::detail::try_and_catch_ ( F &&  f)
inline

Definition at line 653 of file ExceptionWrapper.h.

References f.

Referenced by folly::try_and_catch().

653  {
654  return (f(), exception_wrapper());
655 }
auto f
template<typename F , typename Ex , typename... Exs>
exception_wrapper folly::detail::try_and_catch_ ( F &&  f)
inline

Definition at line 658 of file ExceptionWrapper.h.

References f.

658  {
659  try {
660  return try_and_catch_<F, Exs...>(std::forward<F>(f));
661  } catch (Ex& ex) {
662  return exception_wrapper(std::current_exception(), ex);
663  }
664 }
auto f
exception_wrapper try_and_catch_(F &&f)
template<typename Tgt , typename SubsecondRatio , typename Seconds , typename Subseconds >
Expected<Tgt, ConversionCode> folly::detail::tryPosixTimeToDuration ( Seconds  seconds,
Subseconds  subseconds 
)

Definition at line 557 of file Conv.h.

References folly::makeUnexpected(), max, folly::NEGATIVE_OVERFLOW, folly::POSITIVE_OVERFLOW, type, and UNLIKELY.

559  {
560  static_assert(
561  SubsecondRatio::num == 1, "subsecond numerator should always be 1");
562 
563  // Normalize the input if required
564  if (UNLIKELY(subseconds < 0)) {
565  const auto overflowSeconds = (subseconds / SubsecondRatio::den);
566  const auto remainder = (subseconds % SubsecondRatio::den);
567  if (std::numeric_limits<Seconds>::lowest() + 1 - overflowSeconds >
568  seconds) {
569  return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
570  }
571  seconds = seconds - 1 + overflowSeconds;
572  subseconds = remainder + SubsecondRatio::den;
573  } else if (UNLIKELY(subseconds >= SubsecondRatio::den)) {
574  const auto overflowSeconds = (subseconds / SubsecondRatio::den);
575  const auto remainder = (subseconds % SubsecondRatio::den);
576  if (std::numeric_limits<Seconds>::max() - overflowSeconds < seconds) {
577  return makeUnexpected(ConversionCode::POSITIVE_OVERFLOW);
578  }
579  seconds += overflowSeconds;
580  subseconds = remainder;
581  }
582 
583  return posixTimeToDuration<SubsecondRatio>(seconds, subseconds, Tgt{});
584 }
LogLevel max
Definition: LogLevel.cpp:31
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
#define UNLIKELY(x)
Definition: Likely.h:48
template<class Uint >
size_t folly::detail::uintToBinary ( char *  buffer,
size_t  bufLen,
Uint  v 
)

Convert an unsigned to binary.

Just like folly::detail::uintToBuffer in Conv.h, writes at the end of the supplied buffer and returns the offset of the beginning of the string from the start of the buffer. The formatted string will be in range [buf+begin, buf+bufLen).

Definition at line 142 of file Format-inl.h.

References testing::Args(), b, formatBinary, and v.

Referenced by compareBinary(), and folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::doFormat().

142  {
143  auto& repr = formatBinary;
144  if (v == 0) {
145  buffer[--bufLen] = '0';
146  return bufLen;
147  }
148  for (; v; v >>= 7, v >>= 1) {
149  auto b = v & 0xff;
150  bufLen -= 8;
151  memcpy(buffer + bufLen, &(repr[b][0]), 8);
152  }
153  while (buffer[bufLen] == '0') {
154  ++bufLen;
155  }
156  return bufLen;
157 }
std::vector< uint8_t > buffer(kBufferSize+16)
auto v
char b
const std::array< std::array< char, 8 >, 256 > formatBinary
Definition: Format.cpp:88
template<class Uint >
size_t folly::detail::uintToHex ( char *  buffer,
size_t  bufLen,
Uint  v,
std::array< std::array< char, 2 >, 256 > const &  repr 
)

Convert an unsigned to hex, using repr (which maps from each possible 2-hex-bytes value to the 2-character representation).

Just like folly::detail::uintToBuffer in Conv.h, writes at the end of the supplied buffer and returns the offset of the beginning of the string from the start of the buffer. The formatted string will be in range [buf+begin, buf+bufLen).

Definition at line 65 of file Format-inl.h.

References b, and v.

Referenced by uintToHexLower(), and uintToHexUpper().

69  {
70  // 'v >>= 7, v >>= 1' is no more than a work around to get rid of shift size
71  // warning when Uint = uint8_t (it's false as v >= 256 implies sizeof(v) > 1).
72  for (; !less_than<unsigned, 256>(v); v >>= 7, v >>= 1) {
73  auto b = v & 0xff;
74  bufLen -= 2;
75  buffer[bufLen] = repr[b][0];
76  buffer[bufLen + 1] = repr[b][1];
77  }
78  buffer[--bufLen] = repr[v][1];
79  if (v >= 16) {
80  buffer[--bufLen] = repr[v][0];
81  }
82  return bufLen;
83 }
std::vector< uint8_t > buffer(kBufferSize+16)
auto v
char b
template<class Uint >
size_t folly::detail::uintToHexLower ( char *  buffer,
size_t  bufLen,
Uint  v 
)
inline

Convert an unsigned to hex, using lower-case letters for the digits above 9. See the comments for uintToHex.

Definition at line 90 of file Format-inl.h.

References uintToHex().

Referenced by BENCHMARK_RELATIVE(), compareHex(), and folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::doFormat().

90  {
91  return uintToHex(buffer, bufLen, v, formatHexLower);
92 }
std::vector< uint8_t > buffer(kBufferSize+16)
size_t uintToHex(char *buffer, size_t bufLen, Uint v, std::array< std::array< char, 2 >, 256 > const &repr)
Definition: Format-inl.h:65
const std::array< std::array< char, 2 >, 256 > formatHexLower
Definition: Format.cpp:82
template<class Uint >
size_t folly::detail::uintToHexUpper ( char *  buffer,
size_t  bufLen,
Uint  v 
)
inline

Convert an unsigned to hex, using upper-case letters for the digits above 9. See the comments for uintToHex.

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

References uintToHex().

Referenced by folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::doFormat().

99  {
100  return uintToHex(buffer, bufLen, v, formatHexUpper);
101 }
std::vector< uint8_t > buffer(kBufferSize+16)
const std::array< std::array< char, 2 >, 256 > formatHexUpper
Definition: Format.cpp:84
size_t uintToHex(char *buffer, size_t bufLen, Uint v, std::array< std::array< char, 2 >, 256 > const &repr)
Definition: Format-inl.h:65
template<class Uint >
size_t folly::detail::uintToOctal ( char *  buffer,
size_t  bufLen,
Uint  v 
)

Convert an unsigned to octal.

Just like folly::detail::uintToBuffer in Conv.h, writes at the end of the supplied buffer and returns the offset of the beginning of the string from the start of the buffer. The formatted string will be in range [buf+begin, buf+bufLen).

Definition at line 112 of file Format-inl.h.

References b, formatOctal, and v.

Referenced by BENCHMARK_RELATIVE(), compareOctal(), and folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::doFormat().

112  {
113  auto& repr = formatOctal;
114  // 'v >>= 7, v >>= 2' is no more than a work around to get rid of shift size
115  // warning when Uint = uint8_t (it's false as v >= 512 implies sizeof(v) > 1).
116  for (; !less_than<unsigned, 512>(v); v >>= 7, v >>= 2) {
117  auto b = v & 0x1ff;
118  bufLen -= 3;
119  buffer[bufLen] = repr[b][0];
120  buffer[bufLen + 1] = repr[b][1];
121  buffer[bufLen + 2] = repr[b][2];
122  }
123  buffer[--bufLen] = repr[v][2];
124  if (v >= 8) {
125  buffer[--bufLen] = repr[v][1];
126  }
127  if (v >= 64) {
128  buffer[--bufLen] = repr[v][0];
129  }
130  return bufLen;
131 }
std::vector< uint8_t > buffer(kBufferSize+16)
auto v
char b
const std::array< std::array< char, 3 >, 512 > formatOctal
Definition: Format.cpp:86
template<typename Synchronized , typename... Args>
auto folly::detail::ulock ( Synchronized synchronized,
Args &&...  args 
)

Definition at line 945 of file Synchronized.h.

References a, testing::Args(), makeSynchronizedLocker(), and s.

Referenced by folly::ulock().

945  {
947  synchronized,
948  [](auto& s, auto&&... a) {
949  return s.ulock(std::forward<decltype(a)>(a)...);
950  },
951  [](auto& s) { return s.tryULock(); },
952  std::forward<Args>(args)...);
953 }
auto makeSynchronizedLocker(Synchronized &synchronized, LockFunc &&lockFunc, TryLockFunc &&tryLockFunc, Args &&...args)
Definition: Synchronized.h:837
char a
static set< string > s
void folly::detail::unsafeStringSetLargerSize ( std::string s,
std::size_t  n 
)
template<typename T >
void folly::detail::unsafeVectorSetLargerSize ( std::vector< T > &  v,
std::size_t  n 
)
template<typename Arg >
decltype(auto) folly::detail::unwrap_emplace_arg ( Arg &&  arg)
noexcept
Examples:
/facebook/proxygen/proxygen/folly/folly/container/Iterator.h.

Definition at line 99 of file Iterator.h.

Referenced by folly::get_emplace_arg().

99  {
100  return std::forward<Arg>(arg);
101 }
template<typename Arg >
decltype(auto) folly::detail::unwrap_emplace_arg ( std::reference_wrapper< Arg >  arg)
noexcept

Definition at line 103 of file Iterator.h.

103  {
104  return arg.get();
105 }
template<typename Arg >
decltype(auto) folly::detail::unwrap_emplace_arg ( folly::rvalue_reference_wrapper< Arg >  arg)
noexcept

Definition at line 107 of file Iterator.h.

References testing::Args(), and folly::gen::move.

108  {
109  return std::move(arg).get();
110 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class Iter >
std::enable_if< std::is_same< typename std::iterator_traits<Iter>::iterator_category, std::random_access_iterator_tag>::value, typename std::iterator_traits<Iter>::reference>::type folly::detail::value_before ( Iter  i)

For random-access iterators, the value before is simply i[-1].

Definition at line 123 of file Range.h.

References type, and value.

123  {
124  return i[-1];
125 }
template<class Iter >
std::enable_if< !std::is_same< typename std::iterator_traits<Iter>::iterator_category, std::random_access_iterator_tag>::value, typename std::iterator_traits<Iter>::reference>::type folly::detail::value_before ( Iter  i)

For all other iterators, we need to use the decrement operator.

Definition at line 136 of file Range.h.

References i.

Referenced by folly::Range< unsigned char * >::back().

136  {
137  return *--i;
138 }
template<typename Synchronized , typename... Args>
auto folly::detail::wlock ( Synchronized synchronized,
Args &&...  args 
)

Definition at line 925 of file Synchronized.h.

References a, testing::Args(), makeSynchronizedLocker(), and s.

Referenced by folly::wlock().

925  {
927  synchronized,
928  [](auto& s, auto&&... a) {
929  return s.wlock(std::forward<decltype(a)>(a)...);
930  },
931  [](auto& s) { return s.tryWLock(); },
932  std::forward<Args>(args)...);
933 }
auto makeSynchronizedLocker(Synchronized &synchronized, LockFunc &&lockFunc, TryLockFunc &&tryLockFunc, Args &&...args)
Definition: Synchronized.h:837
char a
static set< string > s
template<class IntegralType , IntegralType DigitCount, IntegralType Base = IntegralType(10), bool PrintAllDigits = false, class = typename std::enable_if< std::is_integral<IntegralType>::value && std::is_unsigned<IntegralType>::value, bool>::type>
void folly::detail::writeIntegerString ( IntegralType  val,
char **  buffer 
)
inline

Definition at line 185 of file IPAddressSource.h.

References buffer(), i, and folly::value().

Referenced by fastIpv6ToBufferUnsafe().

185  {
186  char* buf = *buffer;
187 
188  if (!PrintAllDigits && val == 0) {
189  *(buf++) = '0';
190  *buffer = buf;
191  return;
192  }
193 
194  IntegralType powerToPrint = 1;
195  for (IntegralType i = 1; i < DigitCount; ++i) {
196  powerToPrint *= Base;
197  }
198 
199  bool found = PrintAllDigits;
200  while (powerToPrint) {
201  if (found || powerToPrint <= val) {
202  IntegralType value = IntegralType(val / powerToPrint);
203  if (Base == 10 || value < 10) {
204  value += '0';
205  } else {
206  value += ('a' - 10);
207  }
208  *(buf++) = char(value);
209  val %= powerToPrint;
210  found = true;
211  }
212 
213  powerToPrint /= Base;
214  }
215 
216  *buffer = buf;
217 }
std::vector< uint8_t > buffer(kBufferSize+16)
double val
Definition: String.cpp:273
AtomicCounter< T, DeterministicAtomic > Base
static const char *const value
Definition: Conv.cpp:50
constexpr const char* folly::detail::xlogStripFilenameMatchFound ( const char *  filename,
const char *  prefixes,
size_t  prefixIdx,
size_t  filenameIdx 
)

Definition at line 519 of file xlog.h.

References folly::xlogIsDirSeparator(), and xlogStripFilenameRecursive().

Referenced by xlogStripFilenameRecursive().

523  {
524  return (filename[filenameIdx] == '\0')
525  ? xlogStripFilenameRecursive(filename, prefixes, prefixIdx + 1, 0, true)
526  : (xlogIsDirSeparator(filename[filenameIdx])
528  filename, prefixes, prefixIdx, filenameIdx + 1)
529  : (filename + filenameIdx));
530 }
constexpr bool xlogIsDirSeparator(char c)
Definition: xlog.h:508
constexpr const char * xlogStripFilenameRecursive(const char *filename, const char *prefixes, size_t prefixIdx, size_t filenameIdx, bool match)
Definition: xlog.h:531
constexpr const char * xlogStripFilenameMatchFound(const char *filename, const char *prefixes, size_t prefixIdx, size_t filenameIdx)
Definition: xlog.h:519
constexpr const char * folly::detail::xlogStripFilenameRecursive ( const char *  filename,
const char *  prefixes,
size_t  prefixIdx,
size_t  filenameIdx,
bool  match 
)

Definition at line 531 of file xlog.h.

References folly::xlogIsDirSeparator(), and xlogStripFilenameMatchFound().

Referenced by folly::xlogIsDirSeparator(), folly::xlogStripFilename(), and xlogStripFilenameMatchFound().

536  {
537  // This would be much easier to understand if written as a while loop.
538  // However, in order to maintain compatibility with pre-C++14 compilers we
539  // have implemented it recursively to adhere to C++11 restrictions for
540  // constexpr functions.
541  return (prefixes[prefixIdx] == ':' || prefixes[prefixIdx] == '\0')
542  ? ((match && filenameIdx > 0 &&
543  (xlogIsDirSeparator(prefixes[filenameIdx - 1]) ||
544  xlogIsDirSeparator(filename[filenameIdx])))
546  filename, prefixes, prefixIdx, filenameIdx))
547  : ((prefixes[prefixIdx] == '\0')
548  ? filename
550  filename, prefixes, prefixIdx + 1, 0, true)))
551  : ((match && (prefixes[prefixIdx] == filename[filenameIdx]))
553  filename, prefixes, prefixIdx + 1, filenameIdx + 1, true)
555  filename, prefixes, prefixIdx + 1, 0, false));
556 }
constexpr bool xlogIsDirSeparator(char c)
Definition: xlog.h:508
constexpr const char * xlogStripFilenameRecursive(const char *filename, const char *prefixes, size_t prefixIdx, size_t filenameIdx, bool match)
Definition: xlog.h:531
constexpr const char * xlogStripFilenameMatchFound(const char *filename, const char *prefixes, size_t prefixIdx, size_t filenameIdx)
Definition: xlog.h:519

Variable Documentation

decltype(cEscapeTable) FOLLY_STORAGE_CONSTEXPR folly::detail::cEscapeTable
Initial value:
=
make_array_with<256>(string_table_c_escape_make_item{})

Definition at line 116 of file String.cpp.

Referenced by folly::cEscape().

decltype(cUnescapeTable) FOLLY_STORAGE_CONSTEXPR folly::detail::cUnescapeTable
Initial value:
=
make_array_with<256>(string_table_c_unescape_make_item{})

Definition at line 118 of file String.cpp.

Referenced by folly::cEscape(), and folly::cUnescape().

FOLLY_STORAGE_CONSTEXPR auto folly::detail::formatAlignTable
Initial value:

Definition at line 78 of file Format.cpp.

Referenced by folly::FormatArg::initSlow().

decltype(formatBinary) FOLLY_STORAGE_CONSTEXPR folly::detail::formatBinary
Initial value:
=
make_array_with<256>(format_table_conv_make_item<2, 8>{})

Definition at line 88 of file Format.cpp.

Referenced by uintToBinary().

decltype(formatHexLower) FOLLY_STORAGE_CONSTEXPR folly::detail::formatHexLower
Initial value:
=
make_array_with<256>(format_table_conv_make_item<16, 2, false>{})

Definition at line 82 of file Format.cpp.

decltype(formatHexUpper) FOLLY_STORAGE_CONSTEXPR folly::detail::formatHexUpper
Initial value:
=
make_array_with<256>(format_table_conv_make_item<16, 2, true>{})

Definition at line 84 of file Format.cpp.

decltype(formatOctal) FOLLY_STORAGE_CONSTEXPR folly::detail::formatOctal
Initial value:
=
make_array_with<512>(format_table_conv_make_item<8, 3>{})

Definition at line 86 of file Format.cpp.

Referenced by uintToOctal().

FOLLY_STORAGE_CONSTEXPR auto folly::detail::formatSignTable
Initial value:

Definition at line 80 of file Format.cpp.

Referenced by folly::FormatArg::initSlow().

decltype(hexTable) FOLLY_STORAGE_CONSTEXPR folly::detail::hexTable
Initial value:
=
make_array_with<256>(string_table_hex_make_item{})

Definition at line 120 of file String.cpp.

Referenced by folly::cEscape(), folly::cUnescape(), folly::MacAddress::parse(), folly::unhexlify(), and folly::uriUnescape().

template<typename T >
constexpr auto folly::detail::is_atomic< std::atomic< Integer > > = false

A simple trait to determine if the given type is an instantiation of std::atomic

Definition at line 67 of file AtomicUtil-inl.h.

constexpr double folly::detail::kClampCastLowerBoundDoubleToInt64F = -9223372036854774784.0

Definition at line 345 of file ConstexprMath.h.

Referenced by folly::constexpr_clamp_cast().

constexpr float folly::detail::kClampCastLowerBoundFloatToInt32F = -2147483520.0f

Definition at line 349 of file ConstexprMath.h.

Referenced by folly::constexpr_clamp_cast().

constexpr double folly::detail::kClampCastUpperBoundDoubleToInt64F = 9223372036854774784.0

Definition at line 346 of file ConstexprMath.h.

Referenced by folly::constexpr_clamp_cast().

constexpr double folly::detail::kClampCastUpperBoundDoubleToUInt64F = 18446744073709549568.0

Definition at line 347 of file ConstexprMath.h.

Referenced by folly::constexpr_clamp_cast().

constexpr float folly::detail::kClampCastUpperBoundFloatToInt32F = 2147483520.0f

Definition at line 350 of file ConstexprMath.h.

Referenced by folly::constexpr_clamp_cast().

constexpr float folly::detail::kClampCastUpperBoundFloatToUInt32F = 4294967040.0f

Definition at line 351 of file ConstexprMath.h.

Referenced by folly::constexpr_clamp_cast().

const size_t folly::detail::kMaxBinaryLength = 8 * sizeof(uintmax_t)

Definition at line 53 of file Format-inl.h.

Referenced by compareBinary().

const size_t folly::detail::kMaxHexLength = 2 * sizeof(uintmax_t)

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

Referenced by BENCHMARK_RELATIVE(), and compareHex().

const size_t folly::detail::kMaxOctalLength = 3 * sizeof(uintmax_t)

Definition at line 52 of file Format-inl.h.

Referenced by BENCHMARK_RELATIVE(), and compareOctal().

std::array< std::array< std::uint8_t, 256 >, 8 > const folly::detail::kSelectInByte
Initial value:
= makeSelectInByteArray(
make_index_sequence<256>{},
make_index_sequence<8>{})

Definition at line 57 of file Select64.cpp.

Referenced by folly::select64(), and TEST_F().

FOLLY_PUSH_WARNING RHS folly::detail::rhs

Definition at line 649 of file Traits.h.

Referenced by testing::internal::ArrayEq(), folly::LockedPtrBase< SynchronizedType, SynchronizedType::MutexType, LockPolicy >::assignImpl(), folly::LockedPtrBase< SynchronizedType, std::mutex, LockPolicy >::assignImpl(), BENCHMARK(), folly::BenchmarkSuspender::BenchmarkSuspender(), PreCalculatedPrimeTable::CalculatePrimesUpTo(), CheckedInt::CheckedInt(), testing::internal::CmpHelperEQ(), testing::internal::CmpHelperFloatingPointEQ(), testing::internal::RefMatcher< T & >::Impl< Super >::DescribeNegationTo(), testing::gmock_matchers_test::IsHalfOfMatcher::DescribeNegationTo(), testing::DoubleEq(), testing::DoubleNear(), folly::detail::EmulatedFutexAtomic< T >::EmulatedFutexAtomic(), folly::Synchronized< std::vector< detail::folly::detail::TypeDescriptor >, folly::SharedMutexImpl >::exchange(), testing::FloatEq(), testing::internal::FloatingPointLE(), testing::FloatNear(), folly::exception_tracer::getExceptionStatistics(), folly::hazptr_holder< Atom >::hazptr_holder(), testing::UnitTest::impl(), folly::detail::IndexedMemPoolRecycler< Pool >::IndexedMemPoolRecycler(), folly::fbstring_core< char >::isShared(), folly::LockedPtr< SynchronizedType, LockPolicy >::LockedPtr(), folly::LockedPtrBase< SynchronizedType, SynchronizedType::MutexType, LockPolicy >::LockedPtrBase(), folly::LockedPtrBase< SynchronizedType, std::mutex, LockPolicy >::LockedPtrBase(), testing::internal::BoundSecondMatcher< Tuple2Matcher, Second >::Impl< T >::MatchAndExplain(), folly::MPMCQueue< T, Atom, true >::MPMCQueue(), folly::detail::MPMCQueueBase< Derived< T, Atom, Dynamic > >::MPMCQueueBase(), testing::NanSensitiveDoubleEq(), testing::NanSensitiveDoubleNear(), testing::NanSensitiveFloatEq(), testing::NanSensitiveFloatNear(), folly::f14::MoveOnlyTestInt::operator!=(), folly::f14::Counts::operator!=(), folly::AtomicUnorderedInsertMap< Key, Value, Hash, KeyEqual, SkipKeyValueDeletion, Atom, IndexType, Allocator >::ConstIterator::operator!=(), folly::f14::Tracked< 0 >::operator!=(), folly::detail::LifoSemHead::operator!=(), testing::Expectation::operator!=(), folly::f14::GenericAlloc< T >::operator!=(), testing::ExpectationSet::operator!=(), folly::operator!=(), folly::detail::DynamicKeyEqual::operator()(), folly::detail::TransparentRangeEqualTo< detail::ValueTypeForTransparentConversionToRange< T >::type >::operator()(), folly::f14::GenericEqual< T >::operator()(), folly::AsciiCaseSensitive::operator()(), folly::AsciiCaseInsensitive::operator()(), testing::internal::LessComparator::operator()(), folly::operator+(), folly::operator<=(), folly::hazptr_holder< Atom >::operator=(), folly::f14::MoveOnlyTestInt::operator=(), folly::BenchmarkSuspender::operator=(), folly::F14VectorSet< Key, Hasher, KeyEqual, Alloc >::operator=(), folly::F14VectorMap< Key, Mapped, Hasher, KeyEqual, Alloc >::operator=(), folly::f14::Tracked< 0 >::operator=(), folly::MPMCQueue< T, Atom, true >::operator=(), folly::Synchronized< std::vector< detail::folly::detail::TypeDescriptor >, folly::SharedMutexImpl >::operator=(), folly::detail::MPMCQueueBase< Derived< T, Atom, Dynamic > >::operator=(), CheckedInt::operator=(), folly::LockedPtrBase< SynchronizedType, SynchronizedType::MutexType, LockPolicy >::operator=(), folly::LockedPtrBase< SynchronizedType, std::mutex, LockPolicy >::operator=(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::ReadHolder::operator=(), folly::LockedPtr< SynchronizedType, LockPolicy >::operator=(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::UpgradeHolder::operator=(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::WriteHolder::operator=(), folly::detail::IteratorFacade< dynamic::const_key_iterator, dynamic const , std::forward_iterator_tag >::operator==(), folly::StringKeyedMap< Value, Compare, Alloc >::operator==(), folly::StringKeyedSetBase< Compare, Alloc >::operator==(), folly::operator>=(), folly::parseLeadingNumber(), testing::Pointwise(), folly::Range< unsigned char * >::Range(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::ReadHolder::ReadHolder(), testing::internal::ShouldRunTestCase(), folly::hazptr_holder< Atom >::swap(), folly::Expected< int, E >::swap(), folly::swap(), TEST(), testing::TEST(), testing::gmock_matchers_test::TEST(), folly::f14::Tracked< 0 >::Tracked(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::UpgradeHolder::UpgradeHolder(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::WriteHolder::WriteHolder(), and folly::fibers::TimedMutex::~TimedMutex().

struct folly::detail::LastElementImpl folly::detail::sizeof
FOLLY_TLS uint32_t folly::detail::tls_lastCpuBufferSlot = 0
static
decltype(uriEscapeTable) FOLLY_STORAGE_CONSTEXPR folly::detail::uriEscapeTable
Initial value:
=
make_array_with<256>(string_table_uri_escape_make_item{})

Definition at line 122 of file String.cpp.

Referenced by folly::cUnescape(), and folly::uriEscape().