Summary: [Folly] Consistent indentation for class visibility labels (`public:`, `protected:`, `private:`). Style is +1 column relative to the `class` keyword.
Reviewed By: andrewjcg
Differential Revision:
D5524869
fbshipit-source-id:
53e4b6cbda10d5b63bafbd535794a8b7ae01a8e0
45 files changed:
uint32_t entryCountThreadCacheSize;
size_t capacity; // if positive, overrides maxLoadFactor
uint32_t entryCountThreadCacheSize;
size_t capacity; // if positive, overrides maxLoadFactor
// Cannot have constexpr ctor because some compilers rightly complain.
Config() : emptyKey((KeyT)-1),
lockedKey((KeyT)-2),
// Cannot have constexpr ctor because some compilers rightly complain.
Config() : emptyKey((KeyT)-1),
lockedKey((KeyT)-2),
template <class Char>
class fbstring_core_model {
template <class Char>
class fbstring_core_model {
fbstring_core_model();
fbstring_core_model(const fbstring_core_model &);
~fbstring_core_model();
fbstring_core_model();
fbstring_core_model(const fbstring_core_model &);
~fbstring_core_model();
// the string without reallocation. For reference-counted strings,
// it should fork the data even if minCapacity < size().
void reserve(size_t minCapacity);
// the string without reallocation. For reference-counted strings,
// it should fork the data even if minCapacity < size().
void reserve(size_t minCapacity);
// Do not implement
fbstring_core_model& operator=(const fbstring_core_model &);
};
// Do not implement
fbstring_core_model& operator=(const fbstring_core_model &);
};
* to extract capacity/category.
*/
template <class Char> class fbstring_core {
* to extract capacity/category.
*/
template <class Char> class fbstring_core {
// It's MSVC, so we just have to guess ... and allow an override
#ifdef _MSC_VER
# ifdef FOLLY_ENDIAN_BE
// It's MSVC, so we just have to guess ... and allow an override
#ifdef _MSC_VER
# ifdef FOLLY_ENDIAN_BE
static constexpr auto kIsLittleEndian =
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__;
#endif
static constexpr auto kIsLittleEndian =
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__;
#endif
fbstring_core() noexcept { reset(); }
fbstring_core(const fbstring_core & rhs) {
fbstring_core() noexcept { reset(); }
fbstring_core(const fbstring_core & rhs) {
return category() == Category::isLarge && RefCounted::refs(ml_.data_) > 1;
}
return category() == Category::isLarge && RefCounted::refs(ml_.data_) > 1;
}
// Disabled
fbstring_core & operator=(const fbstring_core & rhs);
// Disabled
fbstring_core & operator=(const fbstring_core & rhs);
*/
template <class Char>
class dummy_fbstring_core {
*/
template <class Char>
class dummy_fbstring_core {
dummy_fbstring_core() {
}
dummy_fbstring_core(const dummy_fbstring_core& another)
dummy_fbstring_core() {
}
dummy_fbstring_core(const dummy_fbstring_core& another)
backend_.reserve(minCapacity);
}
backend_.reserve(minCapacity);
}
std::basic_string<Char> backend_;
};
#endif // !_LIBSTDCXX_FBSTRING
std::basic_string<Char> backend_;
};
#endif // !_LIBSTDCXX_FBSTRING
static constexpr size_type npos = size_type(-1);
typedef std::true_type IsRelocatable;
static constexpr size_type npos = size_type(-1);
typedef std::true_type IsRelocatable;
static void procrustes(size_type& n, size_type nmax) {
if (n > nmax) {
n = nmax;
static void procrustes(size_type& n, size_type nmax) {
if (n > nmax) {
n = nmax;
static size_type traitsLength(const value_type* s);
static size_type traitsLength(const value_type* s);
// C++11 21.4.2 construct/copy/destroy
// Note: while the following two constructors can be (and previously were)
// C++11 21.4.2 construct/copy/destroy
// Note: while the following two constructors can be (and previously were)
-private:
- iterator
- insertImplDiscr(const_iterator i, size_type n, value_type c, std::true_type);
-
- template <class InputIter>
- iterator
- insertImplDiscr(const_iterator i, InputIter b, InputIter e, std::false_type);
-
- template <class FwdIterator>
- iterator insertImpl(
- const_iterator i,
- FwdIterator s1,
- FwdIterator s2,
- std::forward_iterator_tag);
-
- template <class InputIterator>
- iterator insertImpl(
- const_iterator i,
- InputIterator b,
- InputIterator e,
- std::input_iterator_tag);
-
-public:
+ private:
+ iterator
+ insertImplDiscr(const_iterator i, size_type n, value_type c, std::true_type);
+
+ template <class InputIter>
+ iterator
+ insertImplDiscr(const_iterator i, InputIter b, InputIter e, std::false_type);
+
+ template <class FwdIterator>
+ iterator insertImpl(
+ const_iterator i,
+ FwdIterator s1,
+ FwdIterator s2,
+ std::forward_iterator_tag);
+
+ template <class InputIterator>
+ iterator insertImpl(
+ const_iterator i,
+ InputIterator b,
+ InputIterator e,
+ std::input_iterator_tag);
+
+ public:
template <class ItOrLength, class ItOrChar>
iterator insert(const_iterator p, ItOrLength first_or_n, ItOrChar last_or_c) {
using Sel = std::integral_constant<
template <class ItOrLength, class ItOrChar>
iterator insert(const_iterator p, ItOrLength first_or_n, ItOrChar last_or_c) {
using Sel = std::integral_constant<
return replace(i1, i2, s, traitsLength(s));
}
return replace(i1, i2, s, traitsLength(s));
}
-private:
- basic_fbstring& replaceImplDiscr(
- iterator i1,
- iterator i2,
- const value_type* s,
- size_type n,
- std::integral_constant<int, 2>);
-
- basic_fbstring& replaceImplDiscr(
- iterator i1,
- iterator i2,
- size_type n2,
- value_type c,
- std::integral_constant<int, 1>);
-
- template <class InputIter>
- basic_fbstring& replaceImplDiscr(
- iterator i1,
- iterator i2,
- InputIter b,
- InputIter e,
- std::integral_constant<int, 0>);
-
-private:
- template <class FwdIterator>
- bool replaceAliased(iterator /* i1 */,
- iterator /* i2 */,
- FwdIterator /* s1 */,
- FwdIterator /* s2 */,
- std::false_type) {
+ private:
+ basic_fbstring& replaceImplDiscr(
+ iterator i1,
+ iterator i2,
+ const value_type* s,
+ size_type n,
+ std::integral_constant<int, 2>);
+
+ basic_fbstring& replaceImplDiscr(
+ iterator i1,
+ iterator i2,
+ size_type n2,
+ value_type c,
+ std::integral_constant<int, 1>);
+
+ template <class InputIter>
+ basic_fbstring& replaceImplDiscr(
+ iterator i1,
+ iterator i2,
+ InputIter b,
+ InputIter e,
+ std::integral_constant<int, 0>);
+
+ private:
+ template <class FwdIterator>
+ bool replaceAliased(
+ iterator /* i1 */,
+ iterator /* i2 */,
+ FwdIterator /* s1 */,
+ FwdIterator /* s2 */,
+ std::false_type) {
return r != 0 ? r : n1 > n2 ? 1 : n1 < n2 ? -1 : 0;
}
return r != 0 ? r : n1 > n2 ? 1 : n1 < n2 ? -1 : 0;
}
// Data
Storage store_;
};
// Data
Storage store_;
};
//===========================================================================
//---------------------------------------------------------------------------
// implementation
//===========================================================================
//---------------------------------------------------------------------------
// implementation
typedef std::allocator_traits<Allocator> A;
struct Impl : public Allocator {
typedef std::allocator_traits<Allocator> A;
struct Impl : public Allocator {
//===========================================================================
//---------------------------------------------------------------------------
// types and constants
//===========================================================================
//---------------------------------------------------------------------------
// types and constants
typedef T value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef T value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::integral_constant<bool,
IsTriviallyCopyable<T>::value &&
sizeof(T) <= 16 // don't force large structures to be passed by value
typedef std::integral_constant<bool,
IsTriviallyCopyable<T>::value &&
sizeof(T) <= 16 // don't force large structures to be passed by value
//===========================================================================
//---------------------------------------------------------------------------
// allocator helpers
//===========================================================================
//---------------------------------------------------------------------------
// allocator helpers
//---------------------------------------------------------------------------
// allocate
//---------------------------------------------------------------------------
// allocate
//===========================================================================
//---------------------------------------------------------------------------
// algorithmic helpers
//===========================================================================
//---------------------------------------------------------------------------
// algorithmic helpers
//---------------------------------------------------------------------------
// destroy_range
//---------------------------------------------------------------------------
// destroy_range
//===========================================================================
//---------------------------------------------------------------------------
// relocation helpers
//===========================================================================
//---------------------------------------------------------------------------
// relocation helpers
// Relocation is divided into three parts:
//
// 1: relocate_move
// Relocation is divided into three parts:
//
// 1: relocate_move
//===========================================================================
//---------------------------------------------------------------------------
// construct/copy/destroy
//===========================================================================
//---------------------------------------------------------------------------
// construct/copy/destroy
fbvector() = default;
explicit fbvector(const Allocator& a) : impl_(a) {}
fbvector() = default;
explicit fbvector(const Allocator& a) : impl_(a) {}
// contract dispatch for iterator types fbvector(It first, It last)
template <class ForwardIterator>
fbvector(ForwardIterator first, ForwardIterator last,
// contract dispatch for iterator types fbvector(It first, It last)
template <class ForwardIterator>
fbvector(ForwardIterator first, ForwardIterator last,
//===========================================================================
//---------------------------------------------------------------------------
// iterators
//===========================================================================
//---------------------------------------------------------------------------
// iterators
iterator begin() noexcept {
return impl_.b_;
}
iterator begin() noexcept {
return impl_.b_;
}
//===========================================================================
//---------------------------------------------------------------------------
// capacity
//===========================================================================
//---------------------------------------------------------------------------
// capacity
size_type size() const noexcept {
return size_type(impl_.e_ - impl_.b_);
}
size_type size() const noexcept {
return size_type(impl_.e_ - impl_.b_);
}
bool reserve_in_place(size_type n) {
if (!usingStdAllocator::value || !usingJEMalloc()) return false;
bool reserve_in_place(size_type n) {
if (!usingStdAllocator::value || !usingJEMalloc()) return false;
//===========================================================================
//---------------------------------------------------------------------------
// element access
//===========================================================================
//---------------------------------------------------------------------------
// element access
reference operator[](size_type n) {
assert(n < size());
return impl_.b_[n];
reference operator[](size_type n) {
assert(n < size());
return impl_.b_[n];
//===========================================================================
//---------------------------------------------------------------------------
// data access
//===========================================================================
//---------------------------------------------------------------------------
// data access
T* data() noexcept {
return impl_.b_;
}
T* data() noexcept {
return impl_.b_;
}
//===========================================================================
//---------------------------------------------------------------------------
// modifiers (common)
//===========================================================================
//---------------------------------------------------------------------------
// modifiers (common)
template <class... Args>
void emplace_back(Args&&... args) {
if (impl_.e_ != impl_.z_) {
template <class... Args>
void emplace_back(Args&&... args) {
if (impl_.e_ != impl_.z_) {
M_destroy_range_e(impl_.b_);
}
M_destroy_range_e(impl_.b_);
}
// std::vector implements a similar function with a different growth
// strategy: empty() ? 1 : capacity() * 2.
//
// std::vector implements a similar function with a different growth
// strategy: empty() ? 1 : capacity() * 2.
//
//===========================================================================
//---------------------------------------------------------------------------
// modifiers (erase)
//===========================================================================
//---------------------------------------------------------------------------
// modifiers (erase)
iterator erase(const_iterator position) {
return erase(position, position + 1);
}
iterator erase(const_iterator position) {
return erase(position, position + 1);
}
//===========================================================================
//---------------------------------------------------------------------------
// modifiers (insert)
//===========================================================================
//---------------------------------------------------------------------------
// modifiers (insert)
-private: // we have the private section first because it defines some macros
-
+ private: // we have the private section first because it defines some macros
bool isValid(const_iterator it) {
return cbegin() <= it && it <= cend();
}
bool isValid(const_iterator it) {
return cbegin() <= it && it <= cend();
}
//---------------------------------------------------------------------------
// insert dispatch for iterator types
//---------------------------------------------------------------------------
// insert dispatch for iterator types
template <class FIt>
iterator insert(const_iterator cpos, FIt first, FIt last,
std::forward_iterator_tag) {
template <class FIt>
iterator insert(const_iterator cpos, FIt first, FIt last,
std::forward_iterator_tag) {
//===========================================================================
//---------------------------------------------------------------------------
// lexicographical functions
//===========================================================================
//---------------------------------------------------------------------------
// lexicographical functions
bool operator==(const fbvector& other) const {
return size() == other.size() && std::equal(begin(), end(), other.begin());
}
bool operator==(const fbvector& other) const {
return size() == other.size() && std::equal(begin(), end(), other.begin());
}
//===========================================================================
//---------------------------------------------------------------------------
// friends
//===========================================================================
//---------------------------------------------------------------------------
// friends
template <class _T, class _A>
friend _T* relinquish(fbvector<_T, _A>&);
template <class _T, class _A>
friend _T* relinquish(fbvector<_T, _A>&);
struct BiggerThanChar { char unused[2]; };
template <typename C, typename D> static char test(decltype(C() < D())*);
template <typename, typename> static BiggerThanChar test(...);
struct BiggerThanChar { char unused[2]; };
template <typename C, typename D> static char test(decltype(C() < D())*);
template <typename, typename> static BiggerThanChar test(...);
enum { value = sizeof(test<T, U>(0)) == 1 };
};
enum { value = sizeof(test<T, U>(0)) == 1 };
};
// items in the pair.
template <typename T1, typename T2>
struct hash<std::pair<T1, T2> > {
// items in the pair.
template <typename T1, typename T2>
struct hash<std::pair<T1, T2> > {
size_t operator()(const std::pair<T1, T2>& x) const {
return folly::hash::hash_combine(x.first, x.second);
}
size_t operator()(const std::pair<T1, T2>& x) const {
return folly::hash::hash_combine(x.first, x.second);
}
Optional<result_type> value_;
Func func_;
};
Optional<result_type> value_;
Func func_;
};
{
typedef typename std::remove_reference<Allocator>::type allocator_type;
{
typedef typename std::remove_reference<Allocator>::type allocator_type;
typedef typename Allocator::pointer pointer;
allocator_delete() = default;
typedef typename Allocator::pointer pointer;
allocator_delete() = default;
typedef typename std::remove_reference<T>::type value_type;
typedef value_type* pointer;
typedef typename std::remove_reference<T>::type value_type;
typedef value_type* pointer;
constexpr static bool value = !has_destroy<allocator, void(pointer)>::value
&& !has_destroy<allocator, void(void*)>::value;
};
constexpr static bool value = !has_destroy<allocator, void(pointer)>::value
&& !has_destroy<allocator, void(void*)>::value;
};
*/
template <typename T>
class enable_shared_from_this : public std::enable_shared_from_this<T> {
*/
template <typename T>
class enable_shared_from_this : public std::enable_shared_from_this<T> {
constexpr enable_shared_from_this() noexcept = default;
std::weak_ptr<T> weak_from_this() noexcept {
constexpr enable_shared_from_this() noexcept = default;
std::weak_ptr<T> weak_from_this() noexcept {
return weak_from_this_<T>(this);
}
return weak_from_this_<T>(this);
}
// Uses SFINAE to detect and call
// std::enable_shared_from_this<T>::weak_from_this() if available. Falls
// back to std::enable_shared_from_this<T>::shared_from_this() otherwise.
// Uses SFINAE to detect and call
// std::enable_shared_from_this<T>::weak_from_this() if available. Falls
// back to std::enable_shared_from_this<T>::shared_from_this() otherwise.
// still properly result in a compile error.
typedef typename std::add_lvalue_reference<T>::type reference;
// still properly result in a compile error.
typedef typename std::add_lvalue_reference<T>::type reference;
/*
* If you default construct one of these, you must call this init()
* function before using it.
/*
* If you default construct one of these, you must call this init()
* function before using it.
-private:
- char pad0_[CacheLocality::kFalseSharingRange];
- const uint32_t size_;
- T* const records_;
+ private:
+ char pad0_[CacheLocality::kFalseSharingRange];
+ const uint32_t size_;
+ T* const records_;
- FOLLY_ALIGN_TO_AVOID_FALSE_SHARING std::atomic<unsigned int> readIndex_;
- FOLLY_ALIGN_TO_AVOID_FALSE_SHARING std::atomic<unsigned int> writeIndex_;
+ FOLLY_ALIGN_TO_AVOID_FALSE_SHARING std::atomic<unsigned int> readIndex_;
+ FOLLY_ALIGN_TO_AVOID_FALSE_SHARING std::atomic<unsigned int> writeIndex_;
- char pad1_[CacheLocality::kFalseSharingRange - sizeof(writeIndex_)];
+ char pad1_[CacheLocality::kFalseSharingRange - sizeof(writeIndex_)];
*/
template <class Iter>
class Range : private boost::totally_ordered<Range<Iter> > {
*/
template <class Iter>
class Range : private boost::totally_ordered<Range<Iter> > {
typedef std::size_t size_type;
typedef Iter iterator;
typedef Iter const_iterator;
typedef std::size_t size_type;
typedef Iter iterator;
typedef Iter const_iterator;
constexpr Range(const Range&) = default;
constexpr Range(Range&&) = default;
constexpr Range(const Range&) = default;
constexpr Range(Range&&) = default;
// Works for all iterators
constexpr Range(Iter start, Iter end) : b_(start), e_(end) {
}
// Works for all iterators
constexpr Range(Iter start, Iter end) : b_(start), e_(end) {
}
-> decltype(process(std::declval<Range>(), std::forward<Args>(args)...))
{ return process(split_step(delimiter), std::forward<Args>(args)...); }
-> decltype(process(std::declval<Range>(), std::forward<Args>(args)...))
{ return process(split_step(delimiter), std::forward<Args>(args)...); }
Sleeper() : spinCount(0) {}
void wait() {
Sleeper() : spinCount(0) {}
void wait() {
return std::move(*this);
}
return std::move(*this);
}
* Object value iterators dereference as the values in the object.
* Object item iterators dereference as pairs of (key, value).
*/
* Object value iterators dereference as the values in the object.
* Object item iterators dereference as pairs of (key, value).
*/
typedef std::vector<dynamic> Array;
typedef std::vector<dynamic> Array;
typedef Array::iterator iterator;
typedef Array::const_iterator const_iterator;
typedef dynamic value_type;
typedef Array::iterator iterator;
typedef Array::const_iterator const_iterator;
typedef dynamic value_type;
* d["key"] = 12;
* d["something_else"] = dynamic::array(1, 2, 3, nullptr);
*/
* d["key"] = 12;
* d["something_else"] = dynamic::array(1, 2, 3, nullptr);
*/
struct EmptyArrayTag {};
struct ObjectMaker;
struct EmptyArrayTag {};
struct ObjectMaker;
static void array(EmptyArrayTag);
template <class... Args>
static dynamic array(Args&& ...args);
static void array(EmptyArrayTag);
template <class... Args>
static dynamic array(Args&& ...args);
iterator begin();
iterator end();
iterator begin();
iterator end();
/*
* Helper object returned by keys(), values(), and items().
*/
template <class T> struct IterableProxy;
/*
* Helper object returned by keys(), values(), and items().
*/
template <class T> struct IterableProxy;
/*
* You can iterate over the keys, values, or items (std::pair of key and
* value) in an object. Calling these on non-objects will throw a TypeError.
/*
* You can iterate over the keys, values, or items (std::pair of key and
* value) in an object. Calling these on non-objects will throw a TypeError.
*/
std::size_t hash() const;
*/
std::size_t hash() const;
friend struct TypeError;
struct ObjectImpl;
template <class T> struct TypeInfo;
friend struct TypeError;
struct ObjectImpl;
template <class T> struct TypeInfo;
void print(std::ostream&) const;
void print_as_pseudo_json(std::ostream&) const; // see json.cpp
void print(std::ostream&) const;
void print_as_pseudo_json(std::ostream&) const; // see json.cpp
Type type_;
union Data {
explicit Data() : nul(nullptr) {}
Type type_;
union Data {
explicit Data() : nul(nullptr) {}
// DynamicParser.h.
namespace detail {
class IdentifyCallable {
// DynamicParser.h.
namespace detail {
class IdentifyCallable {
enum class Kind { Function, MemberFunction };
template <typename Fn>
constexpr static Kind getKind() { return test<Fn>(nullptr); }
enum class Kind { Function, MemberFunction };
template <typename Fn>
constexpr static Kind getKind() { return test<Fn>(nullptr); }
template <typename Fn>
using IsMemFn = typename boost::function_types::template is_member_pointer<
decltype(&Fn::operator())
template <typename Fn>
using IsMemFn = typename boost::function_types::template is_member_pointer<
decltype(&Fn::operator())
* {"nested": {"key1": {"key_errors": {"key3": "err"}, "value": 7}}}
*/
const folly::dynamic& error() const { return error_; }
* {"nested": {"key1": {"key_errors": {"key3": "err"}, "value": 7}}}
*/
const folly::dynamic& error() const { return error_; }
folly::dynamic error_;
};
folly::dynamic error_;
};
enum class OnError {
// After parsing, releaseErrors() reports all parse errors.
// Throws DynamicParserLogicError on programmer errors.
enum class OnError {
// After parsing, releaseErrors() reports all parse errors.
// Throws DynamicParserLogicError on programmer errors.
/**
* If `fn` throws an exception, wrapError() catches it and inserts an
* enriched description into stack_.errors_. If lookup_key is non-null,
/**
* If `fn` throws an exception, wrapError() catches it and inserts an
* enriched description into stack_.errors_. If lookup_key is non-null,
explicit Pop(ParserStack* sp)
: key_(sp->key_), value_(sp->value_), stackPtr_(sp) {}
void operator()() noexcept; // ScopeGuard requires noexcept
explicit Pop(ParserStack* sp)
: key_(sp->key_), value_(sp->value_), stackPtr_(sp) {}
void operator()() noexcept; // ScopeGuard requires noexcept
const folly::dynamic* key_;
const folly::dynamic* value_;
ParserStack* stackPtr_;
const folly::dynamic* key_;
const folly::dynamic* value_;
ParserStack* stackPtr_;
template <typename T, template <typename> class Atom = std::atomic>
class LockFreeRingBuffer: boost::noncopyable {
template <typename T, template <typename> class Atom = std::atomic>
class LockFreeRingBuffer: boost::noncopyable {
+ static_assert(
+ std::is_nothrow_default_constructible<T>::value,
+ "Element type must be nothrow default constructible");
- static_assert(std::is_nothrow_default_constructible<T>::value,
- "Element type must be nothrow default constructible");
+ static_assert(
+ FOLLY_IS_TRIVIALLY_COPYABLE(T),
+ "Element type must be trivially copyable");
- static_assert(FOLLY_IS_TRIVIALLY_COPYABLE(T),
- "Element type must be trivially copyable");
-
-public:
/// Opaque pointer to a past or future write.
/// Can be moved relative to its current location but not in absolute terms.
struct Cursor {
/// Opaque pointer to a past or future write.
/// Can be moved relative to its current location but not in absolute terms.
struct Cursor {
return prevTicket != ticket;
}
return prevTicket != ticket;
}
- protected: // for test visibility reasons
+ protected: // for test visibility reasons
uint64_t ticket;
friend class LockFreeRingBuffer;
};
uint64_t ticket;
friend class LockFreeRingBuffer;
};
~LockFreeRingBuffer() {
}
~LockFreeRingBuffer() {
}
const uint32_t capacity_;
const std::unique_ptr<detail::RingBufferSlot<T,Atom>[]> slots_;
const uint32_t capacity_;
const std::unique_ptr<detail::RingBufferSlot<T,Atom>[]> slots_;
namespace detail {
template <typename T, template <typename> class Atom>
class RingBufferSlot {
namespace detail {
template <typename T, template <typename> class Atom>
class RingBufferSlot {
explicit RingBufferSlot() noexcept
: sequencer_()
, data()
explicit RingBufferSlot() noexcept
: sequencer_()
, data()
return sequencer_.isTurn((turn + 1) * 2);
}
return sequencer_.isTurn((turn + 1) * 2);
}
TurnSequencer<Atom> sequencer_;
T data;
}; // RingBufferSlot
TurnSequencer<Atom> sequencer_;
T data;
}; // RingBufferSlot
class Alloc = std::allocator<std::pair<const StringPiece, Value>>>
class StringKeyedMap
: private std::map<StringPiece, Value, Compare, Alloc> {
class Alloc = std::allocator<std::pair<const StringPiece, Value>>>
class StringKeyedMap
: private std::map<StringPiece, Value, Compare, Alloc> {
using Base = std::map<StringPiece, Value, Compare, Alloc>;
using Base = std::map<StringPiece, Value, Compare, Alloc>;
typedef typename Base::key_type key_type;
typedef typename Base::mapped_type mapped_type;
typedef typename Base::value_type value_type;
typedef typename Base::key_type key_type;
typedef typename Base::mapped_type mapped_type;
typedef typename Base::value_type value_type;
class Alloc = std::allocator<StringPiece>>
class StringKeyedSetBase
: private std::set<StringPiece, Compare, Alloc> {
class Alloc = std::allocator<StringPiece>>
class StringKeyedSetBase
: private std::set<StringPiece, Compare, Alloc> {
using Base = std::set<StringPiece, Compare, Alloc>;
using Base = std::set<StringPiece, Compare, Alloc>;
typedef typename Base::key_type key_type;
typedef typename Base::value_type value_type;
typedef typename Base::key_compare key_compare;
typedef typename Base::key_type key_type;
typedef typename Base::value_type value_type;
typedef typename Base::key_compare key_compare;
private:
using Base = std::unordered_map<StringPiece, Value, Hash, Eq, Alloc>;
private:
using Base = std::unordered_map<StringPiece, Value, Hash, Eq, Alloc>;
typedef typename Base::key_type key_type;
typedef typename Base::mapped_type mapped_type;
typedef typename Base::value_type value_type;
typedef typename Base::key_type key_type;
typedef typename Base::mapped_type mapped_type;
typedef typename Base::value_type value_type;
: private std::unordered_set<StringPiece, Hasher, Eq, Alloc> {
using Base = std::unordered_set<StringPiece, Hasher, Eq, Alloc>;
: private std::unordered_set<StringPiece, Hasher, Eq, Alloc> {
using Base = std::unordered_set<StringPiece, Hasher, Eq, Alloc>;
typedef typename Base::key_type key_type;
typedef typename Base::value_type value_type;
typedef typename Base::hasher hasher;
typedef typename Base::key_type key_type;
typedef typename Base::value_type value_type;
typedef typename Base::hasher hasher;
* upon destruction, also changing back to the original working directory.
*/
class ChangeToTempDir {
* upon destruction, also changing back to the original working directory.
*/
class ChangeToTempDir {
ChangeToTempDir();
~ChangeToTempDir();
ChangeToTempDir();
~ChangeToTempDir();
const fs::path& path() const { return dir_.path(); }
const fs::path& path() const { return dir_.path(); }
fs::path initialPath_;
TemporaryDirectory dir_;
};
fs::path initialPath_;
TemporaryDirectory dir_;
};
* Great for testing logging (see also glog*Pattern()).
*/
class CaptureFD {
* Great for testing logging (see also glog*Pattern()).
*/
class CaptureFD {
struct NoOpChunkCob { void operator()(StringPiece) {} };
struct NoOpChunkCob { void operator()(StringPiece) {} };
using ChunkCob = std::function<void(folly::StringPiece)>;
/**
using ChunkCob = std::function<void(folly::StringPiece)>;
/**
*/
std::string readIncremental();
*/
std::string readIncremental();
ChunkCob chunkCob_;
TemporaryFile file_;
ChunkCob chunkCob_;
TemporaryFile file_;
return alloc_ == other.alloc_;
}
return alloc_ == other.alloc_;
}
*/
template <class T>
class SharedPromise {
*/
template <class T>
class SharedPromise {
SharedPromise() = default;
~SharedPromise() = default;
SharedPromise() = default;
~SharedPromise() = default;
std::mutex mutex_;
size_t size_{0};
bool hasValue_{false};
std::mutex mutex_;
size_t size_{0};
bool hasValue_{false};
/// For best results, use an "enum class" for Enum.
template <class Enum>
class FSM {
/// For best results, use an "enum class" for Enum.
template <class Enum>
class FSM {
// I am not templatizing this because folly::MicroSpinLock needs to be
// zero-initialized (or call init) which isn't generic enough for something
// that behaves like std::mutex. :(
// I am not templatizing this because folly::MicroSpinLock needs to be
// zero-initialized (or call init) which isn't generic enough for something
// that behaves like std::mutex. :(
// An optimization would be to use a static conditional on the Enum type.
std::atomic<Enum> state_;
// An optimization would be to use a static conditional on the Enum type.
std::atomic<Enum> state_;
explicit FSM(Enum startState) : state_(startState) {}
Enum getState() const noexcept {
explicit FSM(Enum startState) : state_(startState) {}
Enum getState() const noexcept {
template <class Ret, class... Params>
static
typename std::enable_if<!isFuture<Ret>::value, Ret>::type
template <class Ret, class... Params>
static
typename std::enable_if<!isFuture<Ret>::value, Ret>::type
namespace gen {
class Less {
namespace gen {
class Less {
template <class First, class Second>
auto operator()(const First& first, const Second& second) const ->
decltype(first < second) {
template <class First, class Second>
auto operator()(const First& first, const Second& second) const ->
decltype(first < second) {
template <class First, class Second>
auto operator()(const First& first, const Second& second) const ->
decltype(first > second) {
template <class First, class Second>
auto operator()(const First& first, const Second& second) const ->
decltype(first > second) {
template <int n>
class Get {
template <int n>
class Get {
template <class Value>
auto operator()(Value&& value) const ->
decltype(std::get<n>(std::forward<Value>(value))) {
template <class Value>
auto operator()(Value&& value) const ->
decltype(std::get<n>(std::forward<Value>(value))) {
template <class Value>
auto operator()(Value&& value) const ->
decltype(std::move(std::forward<Value>(value))) {
template <class Value>
auto operator()(Value&& value) const ->
decltype(std::move(std::forward<Value>(value))) {
static_assert(std::is_same<const Value&, ConstRefType>::value,
"Only matching types may be interleaved");
static_assert(std::is_same<const Value&, ConstRefType>::value,
"Only matching types may be interleaved");
explicit Generator(Source source,
const std::shared_ptr<const Container> container)
: source_(std::move(source)),
explicit Generator(Source source,
const std::shared_ptr<const Container> container)
: source_(std::move(source)),
Generator<Value1,Source,Value2,Result>> {
Source source_;
const std::shared_ptr<const Container> container_;
Generator<Value1,Source,Value2,Result>> {
Source source_;
const std::shared_ptr<const Container> container_;
explicit Generator(Source source,
const std::shared_ptr<const Container> container)
: source_(std::move(source)),
explicit Generator(Source source,
const std::shared_ptr<const Container> container)
: source_(std::move(source)),
static constexpr bool testArgs(...) {
return false;
}
static constexpr bool testArgs(...) {
return false;
}
static constexpr bool value = testArgs<Candidate>(nullptr);
};
static constexpr bool value = testArgs<Candidate>(nullptr);
};
Chain<Value, First, Second>> {
First first_;
Second second_;
Chain<Value, First, Second>> {
First first_;
Second second_;
explicit Chain(First first, Second second)
: first_(std::move(first))
, second_(std::move(second)) {}
explicit Chain(First first, Second second)
: first_(std::move(first))
, second_(std::move(second)) {}
Generator(Source source, const Predicate& pred, size_t nThreads)
: source_(std::move(source)),
pred_(pred),
Generator(Source source, const Predicate& pred, size_t nThreads)
: source_(std::move(source)),
pred_(pred),
*/
class RemoteAcceptor
: private NotificationQueue<QueueMessage>::Consumer {
*/
class RemoteAcceptor
: private NotificationQueue<QueueMessage>::Consumer {
explicit RemoteAcceptor(AcceptCallback *callback,
ConnectionEventCallback *connectionEventCallback)
: callback_(callback),
explicit RemoteAcceptor(AcceptCallback *callback,
ConnectionEventCallback *connectionEventCallback)
: callback_(callback),
AcceptCallback *callback_;
ConnectionEventCallback* connectionEventCallback_;
AcceptCallback *callback_;
ConnectionEventCallback* connectionEventCallback_;
class WriteCallbackBase :
public AsyncTransportWrapper::WriteCallback {
class WriteCallbackBase :
public AsyncTransportWrapper::WriteCallback {
explicit WriteCallbackBase(SendMsgParamsCallbackBase* mcb = nullptr)
: state(STATE_WAITING)
, bytesWritten(0)
explicit WriteCallbackBase(SendMsgParamsCallbackBase* mcb = nullptr)
: state(STATE_WAITING)
, bytesWritten(0)
class ExpectWriteErrorCallback :
public WriteCallbackBase {
class ExpectWriteErrorCallback :
public WriteCallbackBase {
explicit ExpectWriteErrorCallback(SendMsgParamsCallbackBase* mcb = nullptr)
: WriteCallbackBase(mcb) {}
explicit ExpectWriteErrorCallback(SendMsgParamsCallbackBase* mcb = nullptr)
: WriteCallbackBase(mcb) {}
};
class WriteCheckTimestampCallback :
};
class WriteCheckTimestampCallback :
- public WriteCallbackBase {
-public:
+ public WriteCallbackBase {
+ public:
explicit WriteCheckTimestampCallback(SendMsgParamsCallbackBase* mcb = nullptr)
: WriteCallbackBase(mcb) {}
explicit WriteCheckTimestampCallback(SendMsgParamsCallbackBase* mcb = nullptr)
: WriteCallbackBase(mcb) {}
};
class ReadCallback : public ReadCallbackBase {
};
class ReadCallback : public ReadCallbackBase {
explicit ReadCallback(WriteCallbackBase *wcb)
: ReadCallbackBase(wcb)
, buffers() {}
explicit ReadCallback(WriteCallbackBase *wcb)
: ReadCallbackBase(wcb)
, buffers() {}
Buffer() : buffer(nullptr), length(0) {}
Buffer(char* buf, size_t len) : buffer(buf), length(len) {}
Buffer() : buffer(nullptr), length(0) {}
Buffer(char* buf, size_t len) : buffer(buf), length(len) {}
};
class ReadErrorCallback : public ReadCallbackBase {
};
class ReadErrorCallback : public ReadCallbackBase {
explicit ReadErrorCallback(WriteCallbackBase *wcb)
: ReadCallbackBase(wcb) {}
explicit ReadErrorCallback(WriteCallbackBase *wcb)
: ReadCallbackBase(wcb) {}
};
class WriteErrorCallback : public ReadCallback {
};
class WriteErrorCallback : public ReadCallback {
explicit WriteErrorCallback(WriteCallbackBase *wcb)
: ReadCallback(wcb) {}
explicit WriteErrorCallback(WriteCallbackBase *wcb)
: ReadCallback(wcb) {}
};
class EmptyReadCallback : public ReadCallback {
};
class EmptyReadCallback : public ReadCallback {
explicit EmptyReadCallback()
: ReadCallback(nullptr) {}
explicit EmptyReadCallback()
: ReadCallback(nullptr) {}
class HandshakeCallback :
public AsyncSSLSocket::HandshakeCB {
class HandshakeCallback :
public AsyncSSLSocket::HandshakeCB {
enum ExpectType {
EXPECT_SUCCESS,
EXPECT_ERROR
enum ExpectType {
EXPECT_SUCCESS,
EXPECT_ERROR
};
class SSLServerAcceptCallback: public SSLServerAcceptCallbackBase {
};
class SSLServerAcceptCallback: public SSLServerAcceptCallbackBase {
uint32_t timeout_;
explicit SSLServerAcceptCallback(HandshakeCallback *hcb,
uint32_t timeout_;
explicit SSLServerAcceptCallback(HandshakeCallback *hcb,
};
class SSLServerAcceptCallbackDelay: public SSLServerAcceptCallback {
};
class SSLServerAcceptCallbackDelay: public SSLServerAcceptCallback {
explicit SSLServerAcceptCallbackDelay(HandshakeCallback *hcb):
SSLServerAcceptCallback(hcb) {}
explicit SSLServerAcceptCallbackDelay(HandshakeCallback *hcb):
SSLServerAcceptCallback(hcb) {}
};
class SSLServerAsyncCacheAcceptCallback: public SSLServerAcceptCallback {
};
class SSLServerAsyncCacheAcceptCallback: public SSLServerAcceptCallback {
explicit SSLServerAsyncCacheAcceptCallback(HandshakeCallback *hcb,
uint32_t timeout = 0):
SSLServerAcceptCallback(hcb, timeout) {}
explicit SSLServerAsyncCacheAcceptCallback(HandshakeCallback *hcb,
uint32_t timeout = 0):
SSLServerAcceptCallback(hcb, timeout) {}
class HandshakeErrorCallback: public SSLServerAcceptCallbackBase {
class HandshakeErrorCallback: public SSLServerAcceptCallbackBase {
explicit HandshakeErrorCallback(HandshakeCallback *hcb):
SSLServerAcceptCallbackBase(hcb) {}
explicit HandshakeErrorCallback(HandshakeCallback *hcb):
SSLServerAcceptCallbackBase(hcb) {}
};
class HandshakeTimeoutCallback: public SSLServerAcceptCallbackBase {
};
class HandshakeTimeoutCallback: public SSLServerAcceptCallbackBase {
explicit HandshakeTimeoutCallback(HandshakeCallback *hcb):
SSLServerAcceptCallbackBase(hcb) {}
explicit HandshakeTimeoutCallback(HandshakeCallback *hcb):
SSLServerAcceptCallbackBase(hcb) {}
}
class PipeHandler : public EventHandler {
}
class PipeHandler : public EventHandler {
PipeHandler(EventBase* eventBase, int fd)
: EventHandler(eventBase, fd) {}
PipeHandler(EventBase* eventBase, int fd)
: EventHandler(eventBase, fd) {}
}
class EventHandlerMock : public EventHandler {
}
class EventHandlerMock : public EventHandler {
EventHandlerMock(EventBase* eb, int fd) : EventHandler(eb, fd) {}
// gmock can't mock noexcept methods, so we need an intermediary
MOCK_METHOD1(_handlerReady, void(uint16_t));
EventHandlerMock(EventBase* eb, int fd) : EventHandler(eb, fd) {}
// gmock can't mock noexcept methods, so we need an intermediary
MOCK_METHOD1(_handlerReady, void(uint16_t));
};
class EventHandlerTest : public Test {
};
class EventHandlerTest : public Test {
int efd = 0;
void SetUp() override {
int efd = 0;
void SetUp() override {
namespace test {
class MockAsyncServerSocket : public AsyncServerSocket {
namespace test {
class MockAsyncServerSocket : public AsyncServerSocket {
typedef std::unique_ptr<MockAsyncServerSocket, Destructor> UniquePtr;
// We explicitly do not mock destroy(), since the base class implementation
typedef std::unique_ptr<MockAsyncServerSocket, Destructor> UniquePtr;
// We explicitly do not mock destroy(), since the base class implementation
void printKV(const std::pair<const dynamic, dynamic>& p) const {
if (!opts_.allow_non_string_keys && !p.first.isString()) {
throw std::runtime_error("folly::toJson: JSON object key was not a "
void printKV(const std::pair<const dynamic, dynamic>& p) const {
if (!opts_.allow_non_string_keys && !p.first.isString()) {
throw std::runtime_error("folly::toJson: JSON object key was not a "
void outdent() const {
if (indentLevel_) {
--*indentLevel_;
void outdent() const {
if (indentLevel_) {
--*indentLevel_;
out_ += indentLevel_ ? " : " : ":";
}
out_ += indentLevel_ ? " : " : ":";
}
-private:
- std::string& out_;
- unsigned* const indentLevel_;
- serialization_opts const& opts_;
+ private:
+ std::string& out_;
+ unsigned* const indentLevel_;
+ serialization_opts const& opts_;
};
//////////////////////////////////////////////////////////////////////
};
//////////////////////////////////////////////////////////////////////
current_ = range_.empty() ? EOF : range_.front();
}
current_ = range_.empty() ? EOF : range_.front();
}
StringPiece range_;
json::serialization_opts const& opts_;
unsigned lineNum_;
StringPiece range_;
json::serialization_opts const& opts_;
unsigned lineNum_;
IntegralSizePolicy() : size_(0) {}
IntegralSizePolicy() : size_(0) {}
static constexpr std::size_t policyMaxSize() {
return SizeType(~kExternMask);
}
static constexpr std::size_t policyMaxSize() {
return SizeType(~kExternMask);
}
std::swap(size_, o.size_);
}
std::swap(size_, o.size_);
}
static bool const kShouldUseHeap = ShouldUseHeap;
static bool const kShouldUseHeap = ShouldUseHeap;
static SizeType const kExternMask =
kShouldUseHeap ? SizeType(1) << (sizeof(SizeType) * 8 - 1)
: 0;
static SizeType const kExternMask =
kShouldUseHeap ? SizeType(1) << (sizeof(SizeType) * 8 - 1)
: 0;
static iterator unconst(const_iterator it) {
return const_cast<iterator>(it);
}
static iterator unconst(const_iterator it) {
return const_cast<iterator>(it);
}
struct HeapPtrWithCapacity {
void* heap_;
InternalSizeType capacity_;
struct HeapPtrWithCapacity {
void* heap_;
InternalSizeType capacity_;
detail::growth_policy_wrapper<GrowthPolicy>&
get_growth_policy() { return *this; }
detail::growth_policy_wrapper<GrowthPolicy>&
get_growth_policy() { return *this; }
typedef T value_type;
typedef T key_type;
typedef Compare key_compare;
typedef T value_type;
typedef T key_type;
typedef Compare key_compare;
return m_.cont_ < other.m_.cont_;
}
return m_.cont_ < other.m_.cont_;
}
/*
* This structure derives from the comparison object in order to
* make use of the empty base class optimization if our comparison
/*
* This structure derives from the comparison object in order to
* make use of the empty base class optimization if our comparison
detail::growth_policy_wrapper<GrowthPolicy>&
get_growth_policy() { return *this; }
detail::growth_policy_wrapper<GrowthPolicy>&
get_growth_policy() { return *this; }
typedef Key key_type;
typedef Value mapped_type;
typedef std::pair<key_type,mapped_type> value_type;
typedef Key key_type;
typedef Value mapped_type;
typedef std::pair<key_type,mapped_type> value_type;
return Compare::operator()(a.first, b.first);
}
return Compare::operator()(a.first, b.first);
}
friend class sorted_vector_map;
explicit value_compare(const Compare& c) : Compare(c) {}
};
friend class sorted_vector_map;
explicit value_compare(const Compare& c) : Compare(c) {}
};
return m_.cont_ < other.m_.cont_;
}
return m_.cont_ < other.m_.cont_;
}
// This is to get the empty base optimization; see the comment in
// sorted_vector_set.
struct EBO : value_compare {
// This is to get the empty base optimization; see the comment in
// sorted_vector_set.
struct EBO : value_compare {
GuardObj(const GuardObj&) = delete;
GuardObj& operator=(const GuardObj&) = delete;
GuardObj(const GuardObj&) = delete;
GuardObj& operator=(const GuardObj&) = delete;
unsigned count() const { return count_; }
unsigned count() const { return count_; }
global_counter& counter_;
};
global_counter& counter_;
};
// Note: Unfortunately can't currently put a std::atomic<int64_t> in
// the value in ahm since it doesn't support types that are both non-copy
// and non-move constructible yet.
AtomicHashMap<int64_t,int64_t> ahm;
// Note: Unfortunately can't currently put a std::atomic<int64_t> in
// the value in ahm since it doesn't support types that are both non-copy
// and non-move constructible yet.
AtomicHashMap<int64_t,int64_t> ahm;
explicit Counters(size_t numCounters) : ahm(numCounters) {}
void increment(int64_t obj_id) {
explicit Counters(size_t numCounters) : ahm(numCounters) {}
void increment(int64_t obj_id) {
template <class T>
class VectorWrapper {
template <class T>
class VectorWrapper {
using value_type = T;
vector<T>& underlying;
explicit VectorWrapper(vector<T>& v) : underlying(v) {}
using value_type = T;
vector<T>& underlying;
explicit VectorWrapper(vector<T>& v) : underlying(v) {}
/* implicit */ MoveTester(const char* s) : s_(s) {}
MoveTester(const MoveTester&) = default;
MoveTester(MoveTester&& other) noexcept {
/* implicit */ MoveTester(const char* s) : s_(s) {}
MoveTester(const MoveTester&) = default;
MoveTester(MoveTester&& other) noexcept {
other.s_ = "";
return *this;
}
other.s_ = "";
return *this;
}
friend bool operator==(const MoveTester& o1, const MoveTester& o2);
std::string s_;
};
friend bool operator==(const MoveTester& o1, const MoveTester& o2);
std::string s_;
};
Data& operator=(const Data&) = default;
Data& operator=(Data&&) = default;
Data& operator=(const Data&) = default;
Data& operator=(Data&&) = default;
int operator&() const;
};
int operator&() const;
};
typedef typename Vector::size_type size_type;
size_type size_;
int* data_;
typedef typename Vector::size_type size_type;
size_type size_;
int* data_;
/* implicit */ DataState(const Vector& v) {
size_ = v.size();
if (size_ != 0) {
/* implicit */ DataState(const Vector& v) {
size_ = v.size();
if (size_ != 0) {
friend class boost::iterator_core_access;
shared_ptr<set<It>> dereferenced;
friend class boost::iterator_core_access;
shared_ptr<set<It>> dereferenced;
explicit Transformer(const It& it)
: Transformer::iterator_adaptor_(it)
, dereferenced(new set<It>()) {}
explicit Transformer(const It& it)
: Transformer::iterator_adaptor_(it)
, dereferenced(new set<It>()) {}