template <typename D, typename... TList>
using return_type = std::
array<typename return_type_helper<D, TList...>::type, sizeof...(TList)>;
-} // !array_detail
+} // namespace array_detail
template <typename D = void, typename... TList>
constexpr array_detail::return_type<D, TList...> make_array(TList&&... t) {
return {{static_cast<value_type>(std::forward<TList>(t))...}};
}
-} // !folly
+} // namespace folly
CHECK(cond) << "compiler-hint assumption fails at runtime";
}
-}
+} // namespace detail
-}
+} // namespace folly
extern void assume_check(bool cond);
-}
+} // namespace detail
/**
* Inform the compiler that the argument can be assumed true. It is
namespace detail {
template <int N> struct AtomicStructIntPick {};
-}
+} // namespace detail
/// AtomicStruct<T> work like C++ atomics, but can be used on any POD
/// type <= 8 bytes.
explicit MutableData(const T& init) : data(init) {}
};
-
-}
+} // namespace folly
T inner_;
char paddingPost_[paddingSize()];
};
-}
+} // namespace folly
constexpr To round_impl(Duration const& d, To const& t0) {
return round_impl(d, t0, t0 + To{1});
}
-}
+} // namespace detail
// mimic: std::chrono::ceil, C++17
// from: http://en.cppreference.com/w/cpp/chrono/duration/ceil, CC-BY-SA
std::chrono::time_point<Clock, Duration> const& tp) {
return std::chrono::time_point<Clock, To>{round<To>(tp.time_since_epoch())};
}
-}
-}
+} // namespace chrono
+} // namespace folly
#endif
};
static const VdsoInitializer vdso_initializer;
-}
+} // namespace
#endif
-}
-}
+} // namespace chrono
+} // namespace folly
extern int (*clock_gettime)(clockid_t, timespec* ts);
extern int64_t (*clock_gettime_ns)(clockid_t);
-}
-}
+} // namespace chrono
+} // namespace folly
NodeAlloc alloc_;
};
-}} // namespaces
+} // namespace detail
+} // namespace folly
container.push_back(v(std::forward<Args>(args)...));
}
-}
+} // namespace folly
throw makeConversionError(err, sp);
}
}
-}
+} // namespace detail
/**
* The identity conversion function.
return p;
}
-}
+} // namespace detail
#endif
/**
// glibc doesn't have strlcpy
size_t strlcpy(char* dest, const char* const src, size_t size);
-}
+} // namespace folly
#include <folly/dynamic.h>
namespace folly {
- template <typename T> T convertTo(const dynamic&);
- template <typename T> dynamic toDynamic(const T&);
-}
+template <typename T>
+T convertTo(const dynamic&);
+template <typename T>
+dynamic toDynamic(const T&);
+} // namespace folly
/**
* convertTo returns a well-typed representation of the input dynamic.
"be sliced when storing in exception_wrapper.");
return std::forward<Ex>(ex);
}
-}
+} // namespace exception_wrapper_detail
template <
class Ex,
return nullptr;
}
}
-}
+} // namespace
exception_wrapper exception_wrapper::from_exception_ptr(
std::exception_ptr const& ptr) noexcept {
LOG(FATAL) << __func__ << "() should not be called for folly::Executor types "
<< "which do not override getKeepAliveToken()";
}
-}
+} // namespace folly
}
FOLLY_POP_WARNING
};
-}
+} // namespace expected_detail_ExpectedHelper
/* using override */ using expected_detail_ExpectedHelper::ExpectedHelper;
struct UnexpectedTag {};
// forward declaration
namespace folly {
- template <class T, class Allocator = std::allocator<T>>
- class fbvector;
-}
+template <class T, class Allocator = std::allocator<T>>
+class fbvector;
+} // namespace folly
//=============================================================================
// unrolling
// "const std::size_t&" is so that folly::npos has the same address in every
// translation unit. This is to avoid potential violations of the ODR.
constexpr const std::size_t& npos = detail::fixedstring::FixedStringBase::npos;
-}
+} // namespace
#if defined(__GNUC__)
#pragma GCC diagnostic push
FOLLY_DEFINE_FIXED_STRING_UDL(128)
#undef FOLLY_DEFINE_FIXED_STRING_UDL
-}
-}
+} // namespace string_literals
+} // namespace literals
// TODO:
// // numeric conversions:
// constexpr FixedString</*...*/> to_fixed_string_ll() noexcept
// template <unsigned long long val>
// constexpr FixedString</*...*/> to_fixed_string_ull() noexcept;
-}
+} // namespace folly
// meta-attribute to identify formatters in this sea of template weirdness
namespace detail {
class FormatterTag {};
-};
+} // namespace detail
/**
* Formatter class.
const Container& container;
const Value& defaultValue;
};
-} // namespace
+} // namespace detail
template <class Container, class Value>
detail::DefaultValueWrapper<Container, Value> defaulted(
[[noreturn]] void throwBadFormatArg(std::string const& msg) {
throw BadFormatArg(msg);
}
-}
+} // namespace folly
}
};
-}} // namespaces
+} // namespace detail
+} // namespace folly
template <typename Fun, typename FunctionType>
struct IsCallableAs : IsCallableAsImpl<Fun, FunctionType> {};
-}
-}
+} // namespace function
+} // namespace detail
/**
* @class FunctionRef
}
template <typename T>
rvalue_reference_wrapper<T> rref(T&) noexcept = delete;
-}
+} // namespace folly
Storage storage_{};
bool erased_{false};
};
-}
+} // namespace folly
namespace detail {
template <typename Pool>
struct IndexedMemPoolRecycler;
-}
+} // namespace detail
template <
typename T,
}
};
-}
+} // namespace detail
} // namespace folly
Func func_;
};
-}
+} // namespace detail
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly
ShutdownSemError::~ShutdownSemError() noexcept {
}
-}
+} // namespace folly
const std::chrono::duration<Rep, std::ratio<Num, Denom>>& d) {
return boost::chrono::duration<Rep, boost::ratio<Num, Denom>>(d.count());
}
-}
+} // namespace detail
/**
* LockTraits specialization for boost::shared_mutex
typename DefaultType<KeysDefault...>::type const& {
return std::get<sizeof...(KeysDefault)-1>(std::tie(keysDefault...));
}
-}
+} // namespace detail
/**
* Given a map of maps and a path of keys, return a pointer to the nested value,
!std::is_same<N, bool>::value &&
!std::is_same<D, bool>::value,
decltype(N{1} / D{1})>::type;
-}
+} // namespace detail
#if defined(__arm__) && !FOLLY_AARCH64
constexpr auto kIntegerDivisionGivesRemainder = false;
inline void SysFree(void* p) {
::free(p);
}
-}
+} // namespace detail
using SysBufferDeleter = static_function_deleter<void, &detail::SysFree>;
using SysBufferUniquePtr = std::unique_ptr<void, SysBufferDeleter>;
goto retry;
}
}
-}
+} // namespace folly
}
typedef MicroLockBase<> MicroLock;
-}
+} // namespace folly
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly
return MoveWrapper<T0>(std::forward<T0>(t));
}
-} // namespace
+} // namespace folly
struct coroutine_traits<folly::Optional<Value>, Args...> {
using promise_type = folly::detail::OptionalPromise<Value>;
};
-} // experimental
+} // namespace experimental
FOLLY_NAMESPACE_STD_END
#endif // FOLLY_HAS_COROUTINES
os << "PackedSyncPtr(" << ptr.get() << ", " << ptr.extra() << ")";
return os;
}
-}
+} // namespace folly
}
};
-}
+} // namespace folly
char32_t,
wchar_t,
std::nullptr_t>;
-} // namespace detail
+} // namespace portability_detail
constexpr size_t max_align_v = portability_detail::max_basic_alignment::value;
constexpr bool kIsArchAmd64 = FOLLY_X64 == 1;
constexpr bool kIsArchAArch64 = FOLLY_AARCH64 == 1;
constexpr bool kIsArchPPC64 = FOLLY_PPC64 == 1;
-}
+} // namespace folly
namespace folly {
#else
constexpr bool kIsSanitizeThread = false;
#endif
-}
+} // namespace folly
// packing is very ugly in msvc
#ifdef _MSC_VER
#else
constexpr auto kIsDebug = true;
#endif
-}
+} // namespace folly
// Endianness
namespace folly {
constexpr auto kIsLittleEndian = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__;
#endif
constexpr auto kIsBigEndian = !kIsLittleEndian;
-}
+} // namespace folly
#ifndef FOLLY_SSE
# if defined(__SSE4_2__)
constexpr auto kIsWindows = false;
constexpr auto kMscVer = 0;
#endif
-}
+} // namespace folly
// Define FOLLY_USE_CPP14_CONSTEXPR to be true if the compiler's C++14
// constexpr support is "good enough".
char pad1_[CacheLocality::kFalseSharingRange - sizeof(writeIndex_)];
};
-}
+} // namespace folly
uint32_t ThreadLocalPRNG::getImpl(LocalInstancePRNG* local) {
return local->rng();
}
-}
+} // namespace folly
return Random::rand32();
}
-}
+} // namespace folly
#include <folly/Random-inl.h>
size_t len) noexcept {
return Range<wchar_t const*>(str, len);
}
-} // inline namespace string_piece_literals
-} // inline namespace literals
+} // namespace string_piece_literals
+} // namespace literals
} // namespace folly
abort();
}
-}} // namespaces
+} // namespace detail
+} // namespace folly
const char* file,
unsigned int line,
const char* function);
-}} // namespace folly
+} // namespace detail
+} // namespace folly
// Explicitly instantiate SharedMutex here:
template class SharedMutexImpl<true>;
template class SharedMutexImpl<false>;
-}
+} // namespace folly
vault_.creationOrder_.wlock()->push_back(type());
}
-}
+} // namespace detail
-}
+} // namespace folly
<< type.name() << ">\n";
std::abort();
}
-}
+} // namespace detail
namespace {
FatalHelper __attribute__ ((__init_priority__ (101))) fatalHelper;
#endif
-}
+} // namespace
SingletonVault::~SingletonVault() { destroyInstances(); }
static SingletonVaultDestructor singletonVaultDestructor;
}
-}
+} // namespace folly
SingletonHolder(SingletonHolder&&) = delete;
};
-}
+} // namespace detail
class SingletonVault {
public:
entry.state = State::Living;
}
};
-}
+} // namespace folly
#include <folly/Singleton-inl.h>
#else
SetStackTraceGetter __attribute__((__init_priority__(101))) setStackTraceGetter;
#endif
-}
-}
+} // namespace
+} // namespace folly
#endif
SingletonT singleton_;
};
-}
+} // namespace folly
size_t hash_value(const SocketAddress& address);
std::ostream& operator<<(std::ostream& os, const SocketAddress& addr);
-}
+} // namespace folly
namespace std {
return addr.hash();
}
};
-}
+} // namespace std
typedef SpinLockGuardImpl<SpinLock> SpinLockGuard;
-}
+} // namespace folly
return false;
}
-}
+} // namespace detail
//////////////////////////////////////////////////////////////////////
};
};
-}
+} // namespace folly
using TokenBucket = ParameterizedTokenBucket<>;
using DynamicTokenBucket = ParameterizedDynamicTokenBucket<>;
-}
+} // namespace folly
template <class T>
using is_trivially_copyable = std::is_trivially_copyable<T>;
#endif
-}
+} // namespace traits_detail
struct Ignore {
template <class T>
decltype(std::declval<T>() == std::declval<U>()),
bool
> {};
-}
+} // namespace traits_detail_IsEqualityComparable
/* using override */ using traits_detail_IsEqualityComparable::
IsEqualityComparable;
decltype(std::declval<T>() < std::declval<U>()),
bool
> {};
-}
+} // namespace traits_detail_IsLessThanComparable
/* using override */ using traits_detail_IsLessThanComparable::
IsLessThanComparable;
noexcept(swap(std::declval<T&>(), std::declval<T&>()))
> {};
#endif
-}
+} // namespace traits_detail_IsNothrowSwappable
/* using override */ using traits_detail_IsNothrowSwappable::IsNothrowSwappable;
struct __cxa_eh_globals;
// declared in cxxabi.h from libstdc++-v3
extern "C" __cxa_eh_globals* __cxa_get_globals() noexcept;
-}
+} // namespace __cxxabiv1
#elif defined(_MSC_VER) && (_MSC_VER >= 1400) && \
(_MSC_VER < 1900) // MSVC++ 8.0 or greater
#define FOLLY_EXCEPTION_COUNT_USE_GETPTD
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly
constexpr Unit unit {};
-}
+} // namespace folly
template <typename S0, typename S1>
using apply = S0;
};
-}
+} // namespace utility_detail
#if __cpp_lib_integer_sequence || _MSC_VER
void zstdFreeDStream(ZSTD_DStream* zds) {
ZSTD_freeDStream(zds);
}
-}
+} // namespace
/**
* ZSTD compression
std::string prefix_;
std::unique_ptr<Codec> codec_;
};
-}
+} // namespace
TEST_P(AutomaticCodecTest, CustomCodec) {
const uint64_t length = 42;
size_t max_size_{0};
};
-} // namespace
+} // namespace folly
std::atomic<Slots*> slots_{nullptr};
};
-} // namespace
+} // namespace folly
return true;
}
-} }
+} // namespace detail
+} // namespace folly
/*
* Look at the Ranges-v3 views and you'll probably find an easier way to build
folly::rvalue_reference_wrapper<Arg> arg) noexcept {
return std::move(arg).get();
}
-}
+} // namespace detail
/**
* Getter function for unpacking a single emplace argument.
back_emplace_iterator<Container, implicit_unpack> back_emplacer(Container& c) {
return back_emplace_iterator<Container, implicit_unpack>(c);
}
-}
+} // namespace folly
return std::copy(first2, last2, d_first);
}
-}
+} // namespace folly
uint8_t dense_[kCapacity];
};
-}
+} // namespace folly
EXPECT_EQ(gMoveOpCnt, 0);
EXPECT_EQ(gConvertOpCnt, 0);
}
-}
+} // namespace
using namespace folly;
}
}
-}
+} // namespace
int main(int argc, char** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
SparseByteSet s;
};
-}
+} // namespace
TEST_F(SparseByteSetTest, empty) {
for (auto c = lims::min(); c < lims::max(); ++c) {
}
}
-}} // namespace folly::detail
+} // namespace detail
+} // namespace folly
template <>
struct GivesZeroFilledMemory<MMapAlloc> : public std::true_type{};
-}}
+} // namespace detail
+} // namespace folly
return successMode;
}
}
-}
-} // namespace
+} // namespace detail
+} // namespace folly
return totalBytes;
}
-}} // namespaces
+} // namespace fileutil_detail
+} // namespace folly
std::chrono::time_point<std::chrono::steady_clock>* absSteadyTime,
uint32_t waitMask);
-}}
+} // namespace detail
+} // namespace folly
char str[sizeof("2001:0db8:0000:0000:0000:ff00:0042:8329")];
out.append(str, fastIpv6ToBufferUnsafe(in6Addr, str));
}
-}
-}
+} // namespace detail
+} // namespace folly
AmplificationProduct<std::tuple<Ts...>>::value;
};
-}} // namespaces
+} // namespace detail
+} // namespace folly
#endif
-}}
+} // namespace detail
+} // namespace folly
struct IsTriviallyCopyable<std::chrono::steady_clock::duration>
: std::true_type {};
-}
+} // namespace folly
namespace folly { namespace detail {
}
};
-}} // namespace folly::detail
+} // namespace detail
+} // namespace folly
}
return std::string::npos;
}
-}
-}
+} // namespace detail
+} // namespace folly
}
return qfind_first_byte_of_std(haystack, needles);
}
-}
-}
+} // namespace detail
+} // namespace folly
const StringPieceLite needles) {
return qfind_first_byte_of_nosse(haystack, needles);
}
-}
-}
+} // namespace detail
+} // namespace folly
#else
#include <cstdint>
#include <limits>
size_t qfind_first_byte_of_sse42(
const StringPieceLite haystack,
const StringPieceLite needles);
-}
-}
+} // namespace detail
+} // namespace folly
namespace detail {
- /*
- * A helper object for the contended case. Starts off with eager
- * spinning, and falls back to sleeping for small quantums.
- */
- class Sleeper {
- static const uint32_t kMaxActiveSpin = 4000;
+/*
+ * A helper object for the contended case. Starts off with eager
+ * spinning, and falls back to sleeping for small quantums.
+ */
+class Sleeper {
+ static const uint32_t kMaxActiveSpin = 4000;
- uint32_t spinCount;
+ uint32_t spinCount;
- public:
- Sleeper() : spinCount(0) {}
+ public:
+ Sleeper() : spinCount(0) {}
- void wait() {
- if (spinCount < kMaxActiveSpin) {
- ++spinCount;
- asm_volatile_pause();
- } else {
- /*
- * Always sleep 0.5ms, assuming this will make the kernel put
- * us down for whatever its minimum timer resolution is (in
- * linux this varies by kernel version from 1ms to 10ms).
- */
- struct timespec ts = { 0, 500000 };
- nanosleep(&ts, nullptr);
- }
+ void wait() {
+ if (spinCount < kMaxActiveSpin) {
+ ++spinCount;
+ asm_volatile_pause();
+ } else {
+ /*
+ * Always sleep 0.5ms, assuming this will make the kernel put
+ * us down for whatever its minimum timer resolution is (in
+ * linux this varies by kernel version from 1ms to 10ms).
+ */
+ struct timespec ts = {0, 500000};
+ nanosleep(&ts, nullptr);
}
- };
+ }
+};
-}
-}
+} // namespace detail
+} // namespace folly
}
#endif
-}
-}
+} // namespace detail
+} // namespace folly
* Check if TFO succeeded in being used.
*/
bool tfo_succeeded(int sockfd);
-}
-}
+} // namespace detail
+} // namespace folly
static StaticSingletonManager* instance = new StaticSingletonManager();
return *instance;
}
-}
-}
+} // namespace detail
+} // namespace folly
inline T* createGlobal() {
return createGlobal<T, Tag>([]() { return new T(); });
}
-}
-}
+} // namespace detail
+} // namespace folly
#endif
}
};
-}
+} // namespace
void StaticMetaBase::initAtFork() {
AtForkList::instance();
FOLLY_STATIC_CTOR_PRIORITY_MAX
PthreadKeyUnregister PthreadKeyUnregister::instance_;
-}}
+} // namespace threadlocal_detail
+} // namespace folly
int exceptionCount_;
};
-}} // namespaces
+} // namespace detail
+} // namespace folly
}
};
-}
+} // namespace std
//////////////////////////////////////////////////////////////////////
namespace detail {
- // This helper is used in destroy() to be able to run destructors on
- // types like "int64_t" without a compiler error.
- struct Destroy {
- template <class T> static void destroy(T* t) { t->~T(); }
- };
-
- /*
- * Helper for implementing numeric conversions in operators on
- * numbers. Just promotes to double when one of the arguments is
- * double, or throws if either is not a numeric type.
- */
- template <template <class> class Op>
- dynamic numericOp(dynamic const& a, dynamic const& b) {
- if (!a.isNumber() || !b.isNumber()) {
- throwTypeError_("numeric", a.type(), b.type());
- }
- if (a.type() != b.type()) {
- auto& integ = a.isInt() ? a : b;
- auto& nonint = a.isInt() ? b : a;
- return Op<double>()(to<double>(integ.asInt()), nonint.asDouble());
- }
- if (a.isDouble()) {
- return Op<double>()(a.asDouble(), b.asDouble());
- }
- return Op<int64_t>()(a.asInt(), b.asInt());
+// This helper is used in destroy() to be able to run destructors on
+// types like "int64_t" without a compiler error.
+struct Destroy {
+ template <class T>
+ static void destroy(T* t) {
+ t->~T();
}
+};
+/*
+ * Helper for implementing numeric conversions in operators on
+ * numbers. Just promotes to double when one of the arguments is
+ * double, or throws if either is not a numeric type.
+ */
+template <template <class> class Op>
+dynamic numericOp(dynamic const& a, dynamic const& b) {
+ if (!a.isNumber() || !b.isNumber()) {
+ throwTypeError_("numeric", a.type(), b.type());
+ }
+ if (a.type() != b.type()) {
+ auto& integ = a.isInt() ? a : b;
+ auto& nonint = a.isInt() ? b : a;
+ return Op<double>()(to<double>(integ.asInt()), nonint.asDouble());
+ }
+ if (a.isDouble()) {
+ return Op<double>()(a.asDouble(), b.asDouble());
+ }
+ return Op<int64_t>()(a.asInt(), b.asInt());
}
+} // namespace detail
+
//////////////////////////////////////////////////////////////////////
/*
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly
#include <folly/dynamic-inl.h>
sysconf(_SC_NPROCESSORS_ONLN),
std::make_shared<NamedThreadFactory>("GlobalIOThreadPool")));
});
-}
+} // namespace
namespace folly {
this, std::this_thread::get_id());
}
-} // folly
+} // namespace folly
ThreadPoolListHook();
};
-} // folly
+} // namespace folly
namespace folly {
class EventBase;
-}
+} // namespace folly
namespace folly {
TimePoint now_ = TimePoint::min();
};
-}
+ } // namespace folly
}
}
-} // namespace
+} // namespace folly
return std::chrono::steady_clock::now();
}
};
-}
+ } // namespace folly
controlLaunchEnqueuedTasks();
return !stopping || !running_.empty();
}
-}
+} // namespace folly
std::mutex finishedm_;
std::deque<std::thread::id> finished_;
};
-}
+} // namespace folly
namespace {
class FiberIOExecutorTest : public testing::Test {};
-}
+} // namespace
TEST_F(FiberIOExecutorTest, event_base) {
auto tpe = std::make_shared<folly::IOThreadPoolExecutor>(1);
namespace {
class ThreadedExecutorTest : public testing::Test {};
-}
+} // namespace
TEST_F(ThreadedExecutorTest, example) {
folly::ThreadedExecutor x;
int priority_;
};
-} // folly
+} // namespace folly
r = mprotect(dummyPage, 1, PROT_READ);
checkUnixError(r, "mprotect");
}
-}
+} // namespace
void asymmetricHeavyBarrier(AMBFlags flags) {
if (kIsLinux) {
std::atomic_thread_fence(std::memory_order_seq_cst);
}
}
-}
+} // namespace folly
}
void asymmetricHeavyBarrier(AMBFlags flags = AMBFlags::NORMAL);
-}
+} // namespace folly
}
}
};
-}
+} // namespace folly
ValueType upperBound_;
};
-}} // namespaces
+} // namespace compression
+} // namespace folly
explicit SkipPointers(const unsigned char*) {}
constexpr static const unsigned char* const skipPointers_{};
};
-}
-}
-}
+} // namespace detail
+} // namespace compression
+} // namespace folly
uint8_t numLowerBits_;
};
-}} // namespaces
+} // namespace compression
+} // namespace folly
threadName_ = threadName.str();
}
-}
+} // namespace folly
bool cancellingCurrentFunction_{false};
};
-}
+} // namespace folly
folly::Singleton<Validator> schemaValidator([]() {
return makeValidator(parseJson(metaschemaJson)).release();
});
-}
+} // namespace
Validator::~Validator() = default;
std::shared_ptr<Validator> makeSchemaValidator() {
return schemaValidator.try_get();
}
-}
-}
+} // namespace jsonschema
+} // namespace folly
* this before you use makeValidator().
*/
std::shared_ptr<Validator> makeSchemaValidator();
-}
-}
+} // namespace jsonschema
+} // namespace folly
std::atomic<int64_t> globalCount_{1};
};
-}
+} // namespace folly
bool alive{false};
};
-}
+} // namespace
bool RCURegisterThread() {
static folly::ThreadLocal<RCURegisterThreadHelper>* rcuRegisterThreadHelper =
static RCUReadLock instance;
return instance;
}
-}
+} // namespace folly
RCUReadLock() {}
};
-}
+} // namespace folly
std::shared_ptr<T> ptr_;
};
-}
+} // namespace detail
template <typename T, typename RefCount = DefaultRefCount>
class ReadMostlyMainPtr {
const ReadMostlySharedPtr<T, RefCount>& ptr) {
return !(ptr == nullptr);
}
-}
+} // namespace folly
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7
};
-}}
+} // namespace detail
+} // namespace folly
std::shared_ptr<void> collectGuard_;
};
-}
+} // namespace folly
};
SavedState disableInvalidParameters();
void enableInvalidParameters(SavedState state);
-}
+} // namespace detail
// Ok, so fun fact: The CRT on windows will actually abort
// on certain failed parameter validation checks in debug
std::unique_ptr<folly::IOBuf> toBserIOBuf(
folly::dynamic const&,
const serialization_opts&);
-}
-}
+} // namespace bser
+} // namespace folly
/* vim:ts=2:sw=2:et:
*/
auto buf = toBserIOBuf(dyn, opts);
return buf->moveToFbString();
}
-}
-}
+} // namespace bser
+} // namespace folly
/* vim:ts=2:sw=2:et:
*/
folly::dynamic parseBser(StringPiece str) {
return parseBser(ByteRange((uint8_t*)str.data(), str.size()));
}
-}
-}
+} // namespace bser
+} // namespace folly
/* vim:ts=2:sw=2:et:
*/
void dummyCxaRethrow() noexcept;
void dummyCxaEndCatch() noexcept;
void dummyRethrowException(std::exception_ptr) noexcept;
-}
+} // namespace detail
using CxaThrowType = decltype(&detail::dummyCxaThrow);
using CxaBeginCatchType = decltype(&detail::dummyCxaBeginCatch);
void registerCxaRethrowCallback(CxaRethrowType callback);
void registerCxaEndCatchCallback(CxaEndCatchType callback);
void registerRethrowExceptionCallback(RethrowExceptionType callback);
-}
-}
+} // namespace exception_tracer
+} // namespace folly
std::atomic<Node*> head_ = {nullptr};
};
-} // namespace folly
} // namespace hazptr
+} // namespace folly
}
};
-} // namespace folly
} // namespace hazptr
+} // namespace folly
}
};
-} // namespace folly
} // namespace hazptr
+} // namespace folly
}
};
-} // namespace folly
} // namespace hazptr
+} // namespace folly
tls_state_ = TLS_DESTROYED;
}
-} // namespace folly
} // namespace hazptr
+} // namespace folly
void set_default_resource(memory_resource*);
memory_resource* new_delete_resource();
-} // namespace folly
} // namespace hazptr
+} // namespace folly
char a[100];
};
-} // namespace folly
} // namespace hazptr
+} // namespace folly
delete p;
}
-} // namespace folly
} // namespace hazptr
+} // namespace folly
numDiscarded,
" log messages discarded: logging faster than we can write\n");
}
-}
+} // namespace folly
*/
std::thread ioThread_;
};
-}
+} // namespace folly
}
return "CRITICAL";
}
-}
+} // namespace
namespace folly {
return buffer;
}
-}
+} // namespace folly
const LogMessage& message,
const LogCategory* handlerCategory) override;
};
-}
+} // namespace folly
}
void ImmediateFileWriter::flush() {}
-}
+} // namespace folly
folly::File file_;
};
-}
+} // namespace folly
}
return msg;
}
-}
+} // namespace folly
private:
std::string computeMessage(const std::vector<std::string>& errors);
};
-}
+} // namespace folly
void LogCategory::registerXlogLevel(std::atomic<LogLevel>* levelPtr) {
xlogLevels_.push_back(levelPtr);
}
-}
+} // namespace folly
*/
std::vector<std::atomic<LogLevel>*> xlogLevels_;
};
-}
+} // namespace folly
const LogMessage& message,
const LogCategory* handlerCategory) = 0;
};
-}
+} // namespace folly
*/
virtual void flush() = 0;
};
-}
+} // namespace folly
os << logLevelToString(level);
return os;
}
-}
+} // namespace folly
return folly::kIsDebug ? (level >= LogLevel::DFATAL)
: (level >= LogLevel::FATAL);
}
-}
+} // namespace folly
}
}
}
-}
+} // namespace folly
*/
std::string message_;
};
-}
+} // namespace folly
return StringPiece(name.begin(), idx);
}
-}
+} // namespace folly
}
};
};
-}
+} // namespace folly
}
LogStream::~LogStream() {}
-}
+} // namespace folly
LogStreamBuffer buffer_;
LogStreamProcessor* const processor_;
};
-}
+} // namespace folly
}
return categoryInfo->getCategory(&xlog_detail::xlogFileScopeInfo);
}
-}
+} // namespace
/**
* Construct a LogStreamProcessor from an XlogCategoryInfo.
// Therefore we never need to check if it is initialized here.
return fileScopeInfo->category;
}
-}
+} // namespace
/**
* Construct a LogStreamProcessor from an XlogFileScopeInfo.
// builds) or DFATAL (in debug builds).
abort();
}
-}
+} // namespace folly
#endif
str->append("<no_string_conversion>)");
}
-}
+} // namespace detail
template <bool IsInHeaderFile>
class XlogCategoryInfo;
[[noreturn]] void logDisabledHelper(
std::integral_constant<bool, true>) noexcept;
// clang-format on
-}
+} // namespace folly
*/
virtual void flush() = 0;
};
-}
+} // namespace folly
Logger::Logger(LoggerDB* db, StringPiece name)
: Logger{db->getCategory(name)} {}
-}
+} // namespace folly
private:
LogCategory* const category_{nullptr};
};
-}
+} // namespace folly
private:
LoggerDB* db_;
};
-}
+} // namespace
LoggerDB* LoggerDB::get() {
// Intentionally leaky singleton
folly::writeFull(STDERR_FILENO, fullMsg.data(), fullMsg.size());
}
}
-}
+} // namespace folly
static std::atomic<InternalWarningHandler> warningHandler_;
};
-}
+} // namespace folly
count_.store(1, std::memory_order_release);
return true;
}
-}
-}
+} // namespace logging
+} // namespace folly
// since time_point's constructor is not noexcept
std::atomic<std::chrono::steady_clock::rep> timestamp_;
};
-}
-}
+} // namespace logging
+} // namespace folly
void StandardLogHandler::flush() {
writer_->flush();
}
-}
+} // namespace folly
std::shared_ptr<LogFormatter> formatter_;
std::shared_ptr<LogWriter> writer_;
};
-}
+} // namespace folly
// folly.experimental.logging.example.lib
XLOGF(DBG1, "ExampleObject({}) at {} destroyed", value_, this);
}
-}
+} // namespace example
private:
std::string value_;
};
-}
+} // namespace example
"error formatting printf-style log message: ", format);
}
}
-}
+} // namespace folly
std::string loggingFormatPrintf(
FOLLY_PRINTF_FORMAT const char* format,
...) noexcept FOLLY_PRINTF_FORMAT_ATTR(1, 2);
-}
+} // namespace folly
/**
* Log a message to the specified logger using a printf-style format string.
std::string&& msg) {
internalWarnings->emplace_back(std::move(msg));
}
-}
+} // namespace
TEST(AsyncFileWriter, ioError) {
// Set the LoggerDB internal warning handler so we can record the messages
return totalBytes;
}
-}
+} // namespace
TEST(AsyncFileWriter, flush) {
// Set up a pipe(), then write data to the write endpoint until it fills up
};
static InitChecker initChecker;
-}
+} // namespace
namespace {
int runHelper() {
// should be able to detect that XLOG(FATAL) never returns. It shouldn't
// complain that we don't return an integer here.
}
-}
+} // namespace
std::string fbLogFatalCheck() {
folly::Logger logger("some.category");
std::string&& msg) {
internalWarnings->emplace_back(std::move(msg));
}
-}
+} // namespace
TEST(ImmediateFileWriter, ioError) {
std::array<int, 2> fds;
throw std::runtime_error("test");
}
};
-}
+} // namespace folly
TEST_F(LoggerTest, toStringError) {
// Use the folly::to<string> log API, with an object that will throw
private:
std::vector<std::string> messages_;
};
-}
+} // namespace
TEST(StandardLogHandler, simple) {
auto writer = make_shared<TestLogWriter>();
std::vector<std::pair<LogMessage, const LogCategory*>> messages_;
uint64_t flushCount_{0};
};
-}
+} // namespace folly
void testXlogFile1Dbg1(folly::StringPiece msg) {
XLOG(DBG1) << "file1: " << msg;
}
-}
+} // namespace logging_test
void testXlogFile2Dbg1(folly::StringPiece msg) {
XLOG(DBG1, "file2: ", msg);
}
-}
+} // namespace logging_test
// Prototypes for functions defined in XlogFile1.cpp and XlogFile2.cpp
void testXlogFile1Dbg1(folly::StringPiece msg);
void testXlogFile2Dbg1(folly::StringPiece msg);
-}
+} // namespace logging_test
inline void testXlogHdrFunction(folly::StringPiece str, int value) {
XLOG(DBG3, "test: ", str, "=", value);
}
-}
+} // namespace logging_test
// compiled or not.
template class XlogLevelInfo<true>;
template class XlogCategoryInfo<true>;
-}
+} // namespace folly
* XLOG_SET_CATEGORY_NAME() has not been used.
*/
std::string getXlogCategoryNameForFile(folly::StringPiece filename);
-}
+} // namespace folly
/*
* We intentionally use an unnamed namespace inside a header file here.
* statement.
*/
::folly::XlogFileScopeInfo xlogFileScopeInfo;
-}
-}
+} // namespace xlog_detail
+} // namespace
return observer;
}
-}
-}
+} // namespace observer
+} // namespace folly
std::shared_ptr<Context> context_;
};
-}
-}
+} // namespace observer
+} // namespace folly
#include <folly/experimental/observer/Observable-inl.h>
return snapshot;
}
-}
-}
+} // namespace observer
+} // namespace folly
template <typename T, bool CacheInThreadLocal>
using ObserverT = typename ObserverTraits<T, CacheInThreadLocal>::type;
-}
-}
+} // namespace observer
+} // namespace folly
#include <folly/experimental/observer/Observer-inl.h>
});
return *observer_;
}
-}
-}
+} // namespace observer
+} // namespace folly
std::once_flag observerInit_;
folly::Optional<Observer<T>> observer_;
};
-}
-}
+} // namespace observer
+} // namespace folly
#include <folly/experimental/observer/SimpleObservable-inl.h>
}
});
}
-}
-}
+} // namespace observer_detail
+} // namespace folly
std::mutex refreshMutex_;
};
-}
-}
+} // namespace observer_detail
+} // namespace folly
std::unordered_map<NodeId, NodeSet> edges_;
};
-}
-}
+} // namespace observer_detail
+} // namespace folly
template <typename F>
using ResultOfUnwrapSharedPtr =
typename UnwrapSharedPtr<typename std::result_of<F()>::type>::type;
-}
-}
+} // namespace observer_detail
+} // namespace folly
namespace {
constexpr size_t kCurrentQueueSize{10 * 1024};
constexpr size_t kNextQueueSize{10 * 1024};
-}
+} // namespace
class ObserverManager::CurrentQueue {
public:
std::shared_ptr<ObserverManager> ObserverManager::getInstance() {
return Singleton::instance.try_get();
}
-}
-}
+} // namespace observer_detail
+} // namespace folly
using CycleDetector = GraphCycleDetector<const Core*>;
folly::Synchronized<CycleDetector, std::mutex> cycleDetector_;
};
-}
-}
+} // namespace observer_detail
+} // namespace folly
}
}
-}} // namespaces
+} // namespace compression
+} // namespace folly
"a", "b"}));
}
-}} // namespaces
+} // namespace test
+} // namespace folly
"-xy"}));
}
-}} // namespaces
+} // namespace test
+} // namespace folly
benchmark<TLRefCount, 4>(n);
}
-}
+} // namespace folly
int main(int argc, char** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
// do it that many times.
stressTest<TLRefCount>(500);
}
-}
+} // namespace folly
#undef CHECK_TUPLE_TO
-}} // namespaces
+} // namespace test
+} // namespace folly
return std::move(iterator);
}
-}
-}
+} // namespace fibers
+} // namespace folly
folly::Try<T> awaitNextResult();
};
-}
-}
+} // namespace fibers
+} // namespace folly
#include <folly/fibers/AddTasks-inl.h>
ExecutorT& executor_;
std::shared_ptr<DispatchState> state_;
};
-}
-}
+} // namespace fibers
+} // namespace folly
return timed_wait(TimeoutController::Duration(0));
}
}
-}
-}
+} // namespace fibers
+} // namespace folly
fiberManager_->timeoutManager_->cancel(timeoutPtr_);
}
}
-}
-}
+} // namespace fibers
+} // namespace folly
} futex_;
};
};
-}
-}
+} // namespace fibers
+} // namespace folly
#include <folly/fibers/Baton-inl.h>
void Fiber::LocalData::freeHeapBuffer(void* buffer) {
delete[] reinterpret_cast<char*>(buffer);
}
-}
-}
+} // namespace fibers
+} // namespace folly
size_t asanMainStackSize_{0};
#endif
};
-}
-}
+} // namespace fibers
+} // namespace folly
#include <folly/fibers/Fiber-inl.h>
});
return f;
}
-}
-}
+} // namespace fibers
+} // namespace folly
using AltStackBuffer = std::array<char, kAltStackSize>;
std::unique_ptr<AltStackBuffer> stack_;
};
-}
+} // namespace
void FiberManager::registerAlternateSignalStack() {
static folly::SingletonThreadLocal<ScopedAlternateSignalStack> singleton;
alternateSignalStackRegistered_ = true;
}
#endif
-}
-}
+} // namespace fibers
+} // namespace folly
return Promise<Result, BatonT>::await(std::forward<F>(func));
}
-}
-}
+} // namespace fibers
+} // namespace folly
std::this_thread::yield();
}
}
-}
-}
+} // namespace fibers
+} // namespace folly
#include <folly/fibers/FiberManagerInternal-inl.h>
const FiberManager::Options& opts) {
return ThreadLocalCache<VirtualEventBase>::get(evb, opts);
}
-}
-}
+} // namespace fibers
+} // namespace folly
FiberManager& getFiberManager(
folly::VirtualEventBase& evb,
const FiberManager::Options& opts = FiberManager::Options());
-}
-}
+} // namespace fibers
+} // namespace folly
namespace fibers {
typedef Baton GenericBaton;
-}
-}
+} // namespace fibers
+} // namespace folly
sigaction(SIGSEGV, &sa, &oldSigsegvAction);
});
}
-}
+} // namespace
#endif
return std::move(result).value();
}
-}
-}
+} // namespace fibers
+} // namespace folly
std::is_same<T, void>::value>::type
fulfilHelper(F&& func);
};
-}
-}
+} // namespace fibers
+} // namespace folly
#include <folly/fibers/Promise-inl.h>
}
}
}
-}
-}
+} // namespace fibers
+} // namespace folly
MutexWaiterList read_waiters_; //< List of thread / fibers waiting for
// shared access
};
-}
-}
+} // namespace fibers
+} // namespace folly
#include "TimedMutex-inl.h"
list.pop();
}
}
-}
-}
+} // namespace fibers
+} // namespace folly
TimePoint nextTimeout_;
LoopController& loopController_;
};
-}
-}
+} // namespace fibers
+} // namespace folly
assert(result.size() == 1);
return std::move(result[0]);
}
-}
-}
+} // namespace fibers
+} // namespace folly
typename std::iterator_traits<InputIterator>::value_type()>::type,
void>::value,
size_t>::type inline collectAny(InputIterator first, InputIterator last);
-}
-}
+} // namespace fibers
+} // namespace folly
#include <folly/fibers/WhenN-inl.h>
EXPECT_FALSE(ran);
ran = true;
}
-}
+} // namespace
TEST(FiberManager, runInMainContext) {
FiberManager manager(std::make_unique<SimpleLoopController>());
}
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly
void move_only_func(Mover&&) {}
-}
+} // namespace
TEST(ApplyTuple, Test) {
auto argsTuple = std::make_tuple(1, 2, 3.0);
return future;
}
-}} // namespaces
+} // namespace futures
+} // namespace folly
std::atomic<ControlBlock*> controlBlock_;
};
-}} // namespaces
+} // namespace futures
+} // namespace folly
}
namespace futures {
- template <class It, class F, class ItT, class Result>
- std::vector<Future<Result>> map(It first, It last, F func) {
- std::vector<Future<Result>> results;
- for (auto it = first; it != last; it++) {
- results.push_back(it->then(func));
- }
- return results;
+template <class It, class F, class ItT, class Result>
+std::vector<Future<Result>> map(It first, It last, F func) {
+ std::vector<Future<Result>> results;
+ for (auto it = first; it != last; it++) {
+ results.push_back(it->then(func));
}
+ return results;
}
+} // namespace futures
// Instantiate the most common Future types to save compile time
extern template class Future<Unit>;
class Timekeeper;
-} // namespace
+} // namespace folly
template class Future<int64_t>;
template class Future<std::string>;
template class Future<double>;
-}
+} // namespace folly
namespace folly { namespace futures {
return tk->after(dur);
}
-}}
+} // namespace futures
+} // namespace folly
[[noreturn]] void throwNoFutureInSplitter() {
throw NoFutureInSplitter();
}
-}
+} // namespace folly
public:
NoTimekeeper() : FutureException("No timekeeper available") {}
};
-}
+} // namespace folly
FutureSplitter<T> splitFuture(Future<T>&& future) {
return FutureSplitter<T>{std::move(future)};
}
-}
+} // namespace folly
return true;
}
-}
+} // namespace folly
void detach();
};
-}
+} // namespace folly
#include <folly/futures/Future.h>
#include <folly/futures/Promise-inl.h>
return hasValue_;
}
-}
+} // namespace folly
std::function<void(exception_wrapper const&)> interruptHandler_;
};
-}
+} // namespace folly
#include <folly/futures/Future.h>
#include <folly/futures/SharedPromise-inl.h>
/// futures::sleep(std::chrono::seconds(1));
using Duration = std::chrono::milliseconds;
-}
+} // namespace folly
}
}
-}}} // namespaces
+} // namespace test
+} // namespace futures
+} // namespace folly
TestExecutor executor{2}; // need at least 2 threads for internal futures
};
-}
+} // namespace
TEST_F(CallbackLifetimeTest, thenReturnsValue) {
auto c = mkC();
return v_;
}
};
-}
+} // namespace
TEST(ConverstionOperator, DirectInitialization) {
auto future = makeFuture<Widget>(23);
Future<int> onErrorHelperGeneric(const std::exception&) {
return makeFuture(20);
}
-}
+} // namespace
TEST(Future, onError) {
bool theFlag = false;
}
};
-}
+} // namespace folly
throw std::logic_error("unexpected move assignment");
}
};
-}
+} // namespace
TEST(Then, tryConstructor) {
auto t = Try<Widget>(23);
return opt.value();
}
-} //::detail
+} // namespace detail
/**
* VirtualGen<T> - For wrapping template types in simple polymorphic wrapper.
class Unwrap;
-}
+} // namespace detail
/**
* Polymorphic wrapper
| resplit(delim, keepDelimiter);
}
-} // !detail
+} // namespace detail
/**
* Generator which reads lines from a file.
inline auto byLine(const char* f, char delim = '\n')
-> decltype(byLine(File(f), delim)) { return byLine(File(f), delim); }
-} // !gen
-} // !folly
+} // namespace gen
+} // namespace folly
S toFile(File file, std::unique_ptr<IOBuf> buffer) {
return S(std::move(file), std::move(buffer));
}
-} // !gen
-} // !folly
+} // namespace gen
+} // namespace folly
#include <folly/gen/File-inl.h>
template <class Iterator>
class ChunkedRangeSource;
-}
+} // namespace detail
/**
* chunked() - For producing values from a container in slices.
Sub sub(Sink sink) {
return Sub(std::move(sink));
}
-} // !namespace gen
-} // !namespace folly
+} // namespace gen
+} // namespace folly
#include <folly/gen/Parallel-inl.h>
void PrintTo(const DereferenceWrapper& a, std::ostream* o) {
*o << "Wrapper{\"" << cEscape<string>(a.data) << "\"}";
}
-}
+} // namespace
TEST(Gen, DereferenceWithLValueRef) {
auto original = vector<DereferenceWrapper>{{"foo"}, {"bar"}};
}
#endif
-}
-} // namespace
+} // namespace detail
+} // namespace folly
*/
uint32_t
crc32_sw(const uint8_t* data, size_t nbytes, uint32_t startingChecksum = ~0U);
-}} // folly::detail
+} // namespace detail
+} // namespace folly
folly::symbolizer::installFatalSignalCallbacks();
#endif
}
-} //!folly
+} // namespace folly
}
}
-} // namespace
+} // namespace folly
bool sessionIDResumed_{false};
};
-} // namespace
+} // namespace folly
namespace {
static AsyncSocket::SendMsgParamsCallback defaultSendMsgParamsCallback;
-}
+} // namespace
AsyncSocket::AsyncSocket()
: eventBase_(nullptr),
virtual void getAddress(SocketAddress*) const = 0;
};
-} // namespace
+} // namespace folly
typename T::UniquePtr transport_;
};
-}
+} // namespace folly
ForwardLink rootGuard_;
};
-}
+} // namespace folly
virtual void onEventBaseDestruction(EventBase& evb) = 0;
virtual ~EventBaseLocalBaseBase() = default;
};
-}
+} // namespace detail
template <typename T>
class EventBaseLocal;
}
std::atomic<uint64_t> EventBaseLocalBase::keyCounter_{0};
-}}
+} // namespace detail
+} // namespace folly
uint64_t key_{keyCounter_++};
};
-}
+} // namespace detail
/**
* A storage abstraction for data that should be tied to an EventBase.
}
};
-
-}
+} // namespace folly
void EventBaseThread::stop() {
th_ = nullptr;
}
-}
+} // namespace folly
EventBaseManager* ebm_;
std::unique_ptr<ScopedEventBaseThread> th_;
};
-}
+} // namespace folly
}
return context.get();
}
-}
+} // namespace folly
RequestContext::setContext(std::move(prev_));
}
};
-}
+} // namespace folly
void logDfatal(std::exception const& e) {
LOG(DFATAL) << exceptionStr(e);
}
-}
+} // namespace ssl_options_detail
constexpr std::array<const char*, 12> SSLCommonOptions::kCipherList;
constexpr std::array<const char*, 8> SSLCommonOptions::kSignatureAlgorithms;
namespace ssl_options_detail {
void logDfatal(std::exception const&);
-}
+} // namespace ssl_options_detail
struct SSLCommonOptions {
/**
th_.join();
}
-}
+} // namespace folly
folly::Baton<> stop_;
};
-}
+} // namespace folly
TimeoutManager::~TimeoutManager() {
clearCobTimeouts();
}
-}
+} // namespace folly
callbacks.push_back(*callback);
});
}
-}
+} // namespace folly
folly::Synchronized<LoopCallbackList> onDestructionCallbacks_;
};
-}
+} // namespace folly
folly::WriteFlags flags = folly::WriteFlags::NONE) override = 0;
};
-}
+} // namespace folly
static int boringssl_bio_fd_should_retry(int err);
#endif
-}
+} // namespace
namespace folly {
namespace ssl {
#endif // OEPNSSL_IS_BORINGSSL
-}
+} // namespace
return AsyncSocketException::SSL_ERROR;
}
}
-}
+} // namespace
namespace folly {
getSSLErrorString(error).str(),
0),
sslError(error) {}
-}
+} // namespace folly
private:
SSLError sslError;
};
-}
+} // namespace folly
#endif
-} // namespace
+} // namespace folly
#ifdef SIGPIPE
///////////////////////////////////////////////////////////////////////////
EventBase* eventBase_;
};
-}
+} // namespace folly
sock_->checkEor(0, 0);
}
-}
+} // namespace folly
bool called{false};
};
-}
+} // namespace
TEST(AsyncSignalHandler, basic) {
EventBase evb;
EXPECT_THROW(server2->bind(address.getPort()), std::exception);
}
-} // namespace
+} // namespace folly
std::deque<EventInfo> events_;
};
-}
-}
+} // namespace test
+} // namespace folly
ASSERT_EQ(transportAddr, sock);
}
-} // namespace
+} // namespace folly
void(size_t, const AsyncSocketException&));
};
-}}
+} // namespace test
+} // namespace folly
ctx.setCipherList(ciphers);
verifySSLCipherList(ciphers);
}
-}
+} // namespace folly
}
ASSERT_EQ(nullptr, SSL_get_cipher_list(ssl.get(), i));
}
-}
+} // namespace folly
auto sessID = sess->getSessionID();
ASSERT_GE(sessID.length(), 0);
}
-}
+} // namespace folly
SocketAddress ScopedBoundPort::getAddress() const {
return sock_->getAddress();
}
-}
+} // namespace folly
std::unique_ptr<ScopedEventBaseThread> ebth_;
std::shared_ptr<AsyncServerSocket> sock_;
};
-}
+} // namespace folly
}
}
-}
+} // namespace folly
int fds_[2];
};
-}
+} // namespace folly
});
LOG(INFO) << "Accepting connections on " << address_;
}
-}
+} // namespace folly
private:
void init(bool);
};
-}
+} // namespace folly
return true;
}
-}
+} // namespace folly
std::chrono::nanoseconds expected,
bool allowSmaller,
std::chrono::nanoseconds tolerance = std::chrono::milliseconds(5));
-}
+} // namespace folly
static inline void PrintTo(nanoseconds ns, ::std::ostream* os) {
*os << ns.count() << "ns";
}
-}
-}
+} // namespace chrono
+} // namespace std
#ifdef __linux__
void runThread(nanoseconds duration, nanoseconds* timeWaiting) {
UndelayedDestruction& operator=(UndelayedDestruction const &) = delete;
};
-}
+} // namespace folly
transport.write(nullptr, buf->data(), buf->length());
}
-}}
+} // namespace test
+} // namespace folly
ASSERT_EQ(flags, WriteFlags::NONE);
}
-} // namespace
+} // namespace folly
}
}
-}
+} // namespace
TEST(IOBufQueue, Simple) {
IOBufQueue queue(clOptions);
in.error("expected json value");
}
-}
+} // namespace
//////////////////////////////////////////////////////////////////////
return result;
}
-}
+} // namespace json
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly
namespace json {
- struct serialization_opts {
- explicit serialization_opts()
- : allow_non_string_keys(false),
- javascript_safe(false),
- pretty_formatting(false),
- encode_non_ascii(false),
- validate_utf8(false),
- allow_trailing_comma(false),
- sort_keys(false),
- skip_invalid_utf8(false),
- allow_nan_inf(false),
- double_mode(double_conversion::DoubleToStringConverter::SHORTEST),
- double_num_digits(0), // ignored when mode is SHORTEST
- double_fallback(false),
- parse_numbers_as_strings(false),
- recursion_limit(100) {}
-
- // If true, keys in an object can be non-strings. (In strict
- // JSON, object keys must be strings.) This is used by dynamic's
- // operator<<.
- bool allow_non_string_keys;
-
- /*
- * If true, refuse to serialize 64-bit numbers that cannot be
- * precisely represented by fit a double---instead, throws an
- * exception if the document contains this.
- */
- bool javascript_safe;
-
- // If true, the serialized json will contain space and newlines to
- // try to be minimally "pretty".
- bool pretty_formatting;
-
- // If true, non-ASCII utf8 characters would be encoded as \uXXXX.
- bool encode_non_ascii;
-
- // Check that strings are valid utf8
- bool validate_utf8;
-
- // Allow trailing comma in lists of values / items
- bool allow_trailing_comma;
-
- // Sort keys of all objects before printing out (potentially slow)
- // using dynamic::operator<.
- // Has no effect if sort_keys_by is set.
- bool sort_keys;
-
- // Sort keys of all objects before printing out (potentially slow)
- // using the provided less functor.
- Function<bool(dynamic const&, dynamic const&) const> sort_keys_by;
-
- // Replace invalid utf8 characters with U+FFFD and continue
- bool skip_invalid_utf8;
-
- // true to allow NaN or INF values
- bool allow_nan_inf;
-
- // Options for how to print floating point values. See Conv.h
- // toAppend implementation for floating point for more info
- double_conversion::DoubleToStringConverter::DtoaMode double_mode;
- unsigned int double_num_digits;
-
- // Fallback to double when a value that looks like integer is too big to
- // fit in an int64_t. Can result in loss a of precision.
- bool double_fallback;
-
- // Do not parse numbers. Instead, store them as strings and leave the
- // conversion up to the user.
- bool parse_numbers_as_strings;
-
- // Recursion limit when parsing.
- unsigned int recursion_limit;
- };
+struct serialization_opts {
+ explicit serialization_opts()
+ : allow_non_string_keys(false),
+ javascript_safe(false),
+ pretty_formatting(false),
+ encode_non_ascii(false),
+ validate_utf8(false),
+ allow_trailing_comma(false),
+ sort_keys(false),
+ skip_invalid_utf8(false),
+ allow_nan_inf(false),
+ double_mode(double_conversion::DoubleToStringConverter::SHORTEST),
+ double_num_digits(0), // ignored when mode is SHORTEST
+ double_fallback(false),
+ parse_numbers_as_strings(false),
+ recursion_limit(100) {}
+
+ // If true, keys in an object can be non-strings. (In strict
+ // JSON, object keys must be strings.) This is used by dynamic's
+ // operator<<.
+ bool allow_non_string_keys;
/*
- * Main JSON serialization routine taking folly::dynamic parameters.
- * For the most common use cases there are simpler functions in the
- * main folly namespace below.
+ * If true, refuse to serialize 64-bit numbers that cannot be
+ * precisely represented by fit a double---instead, throws an
+ * exception if the document contains this.
*/
- std::string serialize(dynamic const&, serialization_opts const&);
+ bool javascript_safe;
- /*
- * Escape a string so that it is legal to print it in JSON text and
- * append the result to out.
- */
+ // If true, the serialized json will contain space and newlines to
+ // try to be minimally "pretty".
+ bool pretty_formatting;
- void escapeString(
- StringPiece input,
- std::string& out,
- const serialization_opts& opts);
+ // If true, non-ASCII utf8 characters would be encoded as \uXXXX.
+ bool encode_non_ascii;
- /*
- * Strip all C99-like comments (i.e. // and / * ... * /)
- */
- std::string stripComments(StringPiece jsonC);
-}
+ // Check that strings are valid utf8
+ bool validate_utf8;
+
+ // Allow trailing comma in lists of values / items
+ bool allow_trailing_comma;
+
+ // Sort keys of all objects before printing out (potentially slow)
+ // using dynamic::operator<.
+ // Has no effect if sort_keys_by is set.
+ bool sort_keys;
+
+ // Sort keys of all objects before printing out (potentially slow)
+ // using the provided less functor.
+ Function<bool(dynamic const&, dynamic const&) const> sort_keys_by;
+
+ // Replace invalid utf8 characters with U+FFFD and continue
+ bool skip_invalid_utf8;
+
+ // true to allow NaN or INF values
+ bool allow_nan_inf;
+
+ // Options for how to print floating point values. See Conv.h
+ // toAppend implementation for floating point for more info
+ double_conversion::DoubleToStringConverter::DtoaMode double_mode;
+ unsigned int double_num_digits;
+
+ // Fallback to double when a value that looks like integer is too big to
+ // fit in an int64_t. Can result in loss a of precision.
+ bool double_fallback;
+
+ // Do not parse numbers. Instead, store them as strings and leave the
+ // conversion up to the user.
+ bool parse_numbers_as_strings;
+
+ // Recursion limit when parsing.
+ unsigned int recursion_limit;
+};
+
+/*
+ * Main JSON serialization routine taking folly::dynamic parameters.
+ * For the most common use cases there are simpler functions in the
+ * main folly namespace below.
+ */
+std::string serialize(dynamic const&, serialization_opts const&);
+
+/*
+ * Escape a string so that it is legal to print it in JSON text and
+ * append the result to out.
+ */
+
+void escapeString(
+ StringPiece input,
+ std::string& out,
+ const serialization_opts& opts);
+
+/*
+ * Strip all C99-like comments (i.e. // and / * ... * /)
+ */
+std::string stripComments(StringPiece jsonC);
+} // namespace json
//////////////////////////////////////////////////////////////////////
void PrintTo(const dynamic&, std::ostream*);
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly
asm volatile("or 27,27,27");
#endif
}
-}
+} // namespace folly
return std::strlen(s);
#endif
}
-}
+} // namespace folly
auto lfd = getLibeventFd(fd);
event_set(e, lfd, s, f, arg);
}
-}
+} // namespace folly
}
return path;
}
-}
-}
+} // namespace portability
+} // namespace folly
#ifdef _WIN32
extern "C" char* dirname(char* path) {
namespace folly {
namespace portability {
char* internal_dirname(char* path);
-}
-}
+} // namespace portability
+} // namespace folly
#ifndef _WIN32
#include <libgen.h>
#endif // __GNUC__
#endif // __ANDROID__
-}
+} // namespace folly
free(aligned_ptr);
}
#endif
-}
-}
+} // namespace detail
+} // namespace folly
namespace detail {
void* aligned_malloc(size_t size, size_t align);
void aligned_free(void* aligned_ptr);
-}
-}
+} // namespace detail
+} // namespace folly
}
#endif // !FOLLY_OPENSSL_IS_110
-}
-}
-}
+} // namespace ssl
+} // namespace portability
+} // namespace folly
// indicates it isn't supported.
#define OPENSSL_NO_SSL2
#endif
-}
-}
-}
+} // namespace ssl
+} // namespace portability
+} // namespace folly
FOLLY_PUSH_WARNING
#if __CLANG_PREREQ(3, 0)
const char* optval,
socklen_t optlen);
#endif
-}
-}
-}
+} // namespace sockets
+} // namespace portability
+} // namespace folly
#ifdef _WIN32
// Add our helpers to the overload set.
return -1;
#endif
}
-}
-}
+} // namespace detail
+} // namespace folly
int sysMembarrier();
bool sysMembarrierAvailable();
-}
-}
+} // namespace detail
+} // namespace folly
#else
constexpr size_t kIovMax = UIO_MAXIOV;
#endif
-}
+} // namespace folly
namespace {
class ConstexprTest : public testing::Test {};
-}
+} // namespace
TEST_F(ConstexprTest, constexpr_strlen_cstr) {
constexpr auto v = "hello";
inline void* shiftPointer(void* p, size_t sizeBytes) {
return static_cast<char*>(p) + sizeBytes;
}
-}
+} // namespace detail
//////////////////////////////////////////////////////////////////////
FOLLY_PACK_PUSH
namespace detail {
- // This wrapper goes around a GrowthPolicy and provides iterator
- // preservation semantics, but only if the growth policy is not the
- // default (i.e. nothing).
- template <class Policy>
- struct growth_policy_wrapper : private Policy {
- template <class Container, class Iterator>
- Iterator increase_capacity(Container& c, Iterator desired_insertion)
- {
- typedef typename Container::difference_type diff_t;
- diff_t d = desired_insertion - c.begin();
- Policy::increase_capacity(c);
- return c.begin() + d;
- }
- };
- template <>
- struct growth_policy_wrapper<void> {
- template <class Container, class Iterator>
- Iterator increase_capacity(Container&, Iterator it) {
- return it;
- }
- };
-
- /*
- * This helper returns the distance between two iterators if it is
- * possible to figure it out without messing up the range
- * (i.e. unless they are InputIterators). Otherwise this returns
- * -1.
- */
- template <class Iterator>
- int distance_if_multipass(Iterator first, Iterator last) {
- typedef typename std::iterator_traits<Iterator>::iterator_category categ;
- if (std::is_same<categ, std::input_iterator_tag>::value) {
- return -1;
- }
- return std::distance(first, last);
+// This wrapper goes around a GrowthPolicy and provides iterator
+// preservation semantics, but only if the growth policy is not the
+// default (i.e. nothing).
+template <class Policy>
+struct growth_policy_wrapper : private Policy {
+ template <class Container, class Iterator>
+ Iterator increase_capacity(Container& c, Iterator desired_insertion) {
+ typedef typename Container::difference_type diff_t;
+ diff_t d = desired_insertion - c.begin();
+ Policy::increase_capacity(c);
+ return c.begin() + d;
+ }
+};
+template <>
+struct growth_policy_wrapper<void> {
+ template <class Container, class Iterator>
+ Iterator increase_capacity(Container&, Iterator it) {
+ return it;
}
+};
- template <class OurContainer, class Vector, class GrowthPolicy>
- typename OurContainer::iterator
- insert_with_hint(OurContainer& sorted,
- Vector& cont,
- typename OurContainer::iterator hint,
- typename OurContainer::value_type&& value,
- GrowthPolicy& po)
- {
- const typename OurContainer::value_compare& cmp(sorted.value_comp());
- if (hint == cont.end() || cmp(value, *hint)) {
- if (hint == cont.begin() || cmp(*(hint - 1), value)) {
- hint = po.increase_capacity(cont, hint);
- return cont.insert(hint, std::move(value));
- } else {
- return sorted.insert(std::move(value)).first;
- }
- }
+/*
+ * This helper returns the distance between two iterators if it is
+ * possible to figure it out without messing up the range
+ * (i.e. unless they are InputIterators). Otherwise this returns
+ * -1.
+ */
+template <class Iterator>
+int distance_if_multipass(Iterator first, Iterator last) {
+ typedef typename std::iterator_traits<Iterator>::iterator_category categ;
+ if (std::is_same<categ, std::input_iterator_tag>::value) {
+ return -1;
+ }
+ return std::distance(first, last);
+}
- if (cmp(*hint, value)) {
- if (hint + 1 == cont.end() || cmp(value, *(hint + 1))) {
- hint = po.increase_capacity(cont, hint + 1);
- return cont.insert(hint, std::move(value));
- } else {
- return sorted.insert(std::move(value)).first;
- }
+template <class OurContainer, class Vector, class GrowthPolicy>
+typename OurContainer::iterator insert_with_hint(
+ OurContainer& sorted,
+ Vector& cont,
+ typename OurContainer::iterator hint,
+ typename OurContainer::value_type&& value,
+ GrowthPolicy& po) {
+ const typename OurContainer::value_compare& cmp(sorted.value_comp());
+ if (hint == cont.end() || cmp(value, *hint)) {
+ if (hint == cont.begin() || cmp(*(hint - 1), value)) {
+ hint = po.increase_capacity(cont, hint);
+ return cont.insert(hint, std::move(value));
+ } else {
+ return sorted.insert(std::move(value)).first;
}
-
- // Value and *hint did not compare, so they are equal keys.
- return hint;
}
- template <class OurContainer, class Vector, class InputIterator>
- void bulk_insert(
- OurContainer& sorted,
- Vector& cont,
- InputIterator first,
- InputIterator last) {
- // prevent deref of middle where middle == cont.end()
- if (first == last) {
- return;
+ if (cmp(*hint, value)) {
+ if (hint + 1 == cont.end() || cmp(value, *(hint + 1))) {
+ hint = po.increase_capacity(cont, hint + 1);
+ return cont.insert(hint, std::move(value));
+ } else {
+ return sorted.insert(std::move(value)).first;
}
+ }
- auto const& cmp(sorted.value_comp());
-
- int const d = distance_if_multipass(first, last);
- if (d != -1) {
- cont.reserve(cont.size() + d);
- }
- auto const prev_size = cont.size();
+ // Value and *hint did not compare, so they are equal keys.
+ return hint;
+}
- std::copy(first, last, std::back_inserter(cont));
- auto const middle = cont.begin() + prev_size;
- if (!std::is_sorted(middle, cont.end(), cmp)) {
- std::sort(middle, cont.end(), cmp);
- }
- if (middle != cont.begin() && !cmp(*(middle - 1), *middle)) {
- std::inplace_merge(cont.begin(), middle, cont.end(), cmp);
- cont.erase(
- std::unique(
- cont.begin(),
- cont.end(),
- [&](typename OurContainer::value_type const& a,
- typename OurContainer::value_type const& b) {
- return !cmp(a, b) && !cmp(b, a);
- }),
- cont.end());
- }
+template <class OurContainer, class Vector, class InputIterator>
+void bulk_insert(
+ OurContainer& sorted,
+ Vector& cont,
+ InputIterator first,
+ InputIterator last) {
+ // prevent deref of middle where middle == cont.end()
+ if (first == last) {
+ return;
+ }
+
+ auto const& cmp(sorted.value_comp());
+
+ int const d = distance_if_multipass(first, last);
+ if (d != -1) {
+ cont.reserve(cont.size() + d);
+ }
+ auto const prev_size = cont.size();
+
+ std::copy(first, last, std::back_inserter(cont));
+ auto const middle = cont.begin() + prev_size;
+ if (!std::is_sorted(middle, cont.end(), cmp)) {
+ std::sort(middle, cont.end(), cmp);
+ }
+ if (middle != cont.begin() && !cmp(*(middle - 1), *middle)) {
+ std::inplace_merge(cont.begin(), middle, cont.end(), cmp);
+ cont.erase(
+ std::unique(
+ cont.begin(),
+ cont.end(),
+ [&](typename OurContainer::value_type const& a,
+ typename OurContainer::value_type const& b) {
+ return !cmp(a, b) && !cmp(b, a);
+ }),
+ cont.end());
}
}
+} // namespace detail
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
-}
+} // namespace folly
OPENSSL_cleanup();
initialized_ = false;
}
-}
+} // namespace
void init() {
std::lock_guard<std::mutex> g(initMutex());
private:
static std::string getDateTimeStr(const ASN1_TIME* time);
};
-}
-}
+} // namespace ssl
+} // namespace folly
[[noreturn]] void OpenSSLHash::check_libssl_result_throw() {
throw std::runtime_error("openssl crypto function failed");
}
-}
-}
+} // namespace ssl
+} // namespace folly
}
[[noreturn]] static void check_libssl_result_throw();
};
-}
-}
+} // namespace ssl
+} // namespace folly
// SSL and SSL_CTX
using SSLDeleter = folly::static_function_deleter<SSL, &SSL_free>;
using SSLUniquePtr = std::unique_ptr<SSL, SSLDeleter>;
-}
-}
+} // namespace ssl
+} // namespace folly
void setLockTypes(std::map<int, LockType> inLockTypes);
void installThreadingLocks();
void cleanupThreadingLocks();
-}
-}
-}
+} // namespace detail
+} // namespace ssl
+} // namespace folly
namespace {
class OpenSSLHashTest : public testing::Test {};
-}
+} // namespace
TEST_F(OpenSSLHashTest, sha256) {
IOBuf buf;
namespace folly {
template class BucketedTimeSeries<int64_t>;
-}
+} // namespace folly
namespace folly {
template class MultiLevelTimeSeries<int64_t>;
-}
+} // namespace folly
namespace folly {
template class TimeseriesHistogram<int64_t>;
-}
+} // namespace folly
os << tp.time_since_epoch().count();
return os;
}
-}
+} // namespace std
namespace {
TimePoint mkTimePoint(int value) {
// 1 second x 1 buckets
{1, 1, {0}},
};
-}
+} // namespace
TEST(BucketedTimeSeries, getBucketInfo) {
for (const auto& data : testData) {
};
const seconds kMinuteHourDurations[] = {seconds(60), seconds(3600), seconds(0)};
-};
+} // namespace IntMHTS
TEST(MinuteHourTimeSeries, Basic) {
folly::MultiLevelTimeSeries<int> mhts(
seconds(3600),
seconds(0),
};
-};
+} // namespace IntMTMHTS
namespace IntMHTS {
enum Levels {
seconds(3600),
seconds(0),
};
-};
+} // namespace IntMHTS
typedef std::mt19937 RandomInt32;
StatsClock::time_point mkTimePoint(int value) {
return StatsClock::time_point(StatsClock::duration(value));
}
-}
+} // namespace
TEST(TimeseriesHistogram, Percentile) {
RandomInt32 random(5);
*/
template <typename Duration = monotonic_clock::duration>
using stop_watch = custom_stop_watch<monotonic_clock, Duration>;
-}
+} // namespace folly
flag.called_.store(true, std::memory_order_release);
}
-}
+} // namespace folly
std::size_t length) {
return {folly::StringPiece(name, length)};
}
-} // inline namespace shell_literals
-} // inline namespace literals
+} // namespace shell_literals
+} // namespace literals
/**
* Create argument array for `Subprocess()` for a process running in a
return uint64_t(syscall(FOLLY_SYS_gettid));
#endif
}
-}
+} // namespace folly
bool setThreadName(StringPiece name) {
return setThreadName(std::this_thread::get_id(), name);
}
-}
+} // namespace folly
* Equivalent to setThreadName(std::this_thread::get_id(), name);
*/
bool setThreadName(StringPiece name);
-}
+} // namespace folly
FOLLY_VERSION_CHECK(folly, FOLLY_VERSION)
-}} // namespaces
+} // namespace detail
+} // namespace folly
std::shared_ptr<MyMap> prev_;
};
-}
+} // namespace
//////////////////////////////////////////////////////////////////////
}
}
-}} // namespaces
+} // namespace test
+} // namespace folly
int main(int argc, char *argv[]) {
testing::InitGoogleTest(&argc, argv);
runThreads(mainFunc, FLAGS_numThreads, nullptr);
}
-}
+} // namespace
TEST(Ahm, collision_test) {
const int numInserts = 1000000 / 4;
return nullptr;
}
-}
+} // namespace
// Test for race conditions when inserting and iterating at the same time and
// creating multiple submaps.
return nullptr;
}
-}
+} // namespace
// Here we have a single thread inserting some values, and several threads
// racing to delete the values in the order they were inserted.
EXPECT_EQ(globalQPAHM->size(), FLAGS_numBMElements);
}
-}
+} // namespace
BENCHMARK(st_aha_find, iters) {
CHECK_LE(iters, FLAGS_numBMElements);
namespace {
template <typename T>
struct AtomicUnorderedInsertMapTest : public ::testing::Test {};
-}
+} // namespace
// uint16_t doesn't make sense for most platforms, but we might as well
// test it
long value_;
long otherStuff_[3];
};
-}
+} // namespace
BENCHMARK(optimizerCanDiscardNonTrivial, n) {
NonTrivialLong x(0);
}
}
-}
+} // namespace
TEST(BitIterator, SimpleFindFirstSet) {
runSimpleFFSTest(1);
namespace {
class ChronoTest : public testing::Test {};
-}
+} // namespace
TEST_F(ChronoTest, ceil_duration) {
EXPECT_EQ(seconds(7), ceil<seconds>(seconds(7)));
BENCHMARK_PARAM(BM_ContentionCSL, 1048576);
BENCHMARK_DRAW_LINE();
-}
+} // namespace
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
ParentAlloc* arena_;
std::set<void*> allocated_;
};
-}
+} // namespace
namespace folly {
template <>
struct IsArenaAllocator<ParanoidArenaAlloc<SysArena>> : std::true_type {};
-}
+} // namespace folly
namespace {
namespace {
class ConstexprMathTest : public testing::Test {};
-}
+} // namespace
TEST_F(ConstexprMathTest, constexpr_min) {
constexpr auto x = uint16_t(3);
};
#endif
-}
-}
+} // namespace conv_bench_detail
+} // namespace folly
using namespace folly::conv_bench_detail;
void checkArrayIndex(const T& array, size_t index) {
DCHECK_LT(index, sizeof(array) / sizeof(array[0]));
}
-}
+} // namespace
////////////////////////////////////////////////////////////////////////////////
// Benchmarks for ASCII to int conversion
std::string stdString = "std::strings are very nice";
float fValue = 1.2355f;
double dValue = 345345345.435;
-}
-}
+} // namespace conv_bench_detail
+} // namespace folly
BENCHMARK(preallocateTestNoFloat, n) {
for (size_t i = 0; i < n; ++i) {
static_cast<uint64_t>(1) << 50,
static_cast<uint64_t>(1) << 63,
};
-}
-}
+} // namespace conv_bench_detail
+} // namespace folly
BENCHMARK(preallocateTestInt8, n) {
for (size_t i = 0; i < n; ++i) {
static_cast<unsigned __int128>(1) << 100,
static_cast<unsigned __int128>(1) << 127,
};
-}
+} // namespace
BENCHMARK(preallocateTestInt128, n) {
for (size_t i = 0; i < n; ++i) {
std::array<double, 4> double2FloatBad{{1e100, 1e101, 1e102, 1e103}};
std::array<double, 4> double2IntGood{{1.0, 10.0, 100.0, 1000.0}};
std::array<double, 4> double2IntBad{{1e100, 1.25, 2.5, 100.00001}};
-}
-}
+} // namespace conv_bench_detail
+} // namespace folly
#define STRING_TO_TYPE_BENCHMARK(type, name, pass, fail) \
BENCHMARK(stringTo##name##Classic, n) { \
}
}
}
-}
+} // namespace
#define EXPECT_CONV_ERROR_QUOTE(expr, code, value, quoted) \
testConvError( \
oss << to<std::string>(value);
return oss.str();
}
-}
+} // namespace
#define EXPECT_CONV_ERROR_ARITH(type, val, code) \
EXPECT_CONV_ERROR_QUOTE( \
return 2000 + folly::estimateSpaceNeeded(in.w) +
folly::estimateSpaceNeeded(in.h);
}
-}
+} // namespace my
TEST(Conv, custom_kkproviders) {
my::Dimensions expected{7, 8};
// we're not busy waiting because this is a deterministic schedule
}
}
-}
-}
+} // namespace test
+} // namespace folly
namespace folly {
namespace detail {
DeterministicSchedule::afterSharedAccess();
return rv;
}
-}
+} // namespace detail
template <>
CacheLocality const& CacheLocality::system<test::DeterministicAtomic>() {
Getcpu::Func AccessSpreader<test::DeterministicAtomic>::pickGetcpuFunc() {
return &detail::DeterministicSchedule::getcpu;
}
-}
+} // namespace folly
return { convertTo<int>(d["i"]) };
}
};
-}
+} // namespace folly
TEST(DynamicConverter, custom_class) {
dynamic d1 = dynamic::object("i", 17);
auto i1 = convertTo<A>(d1);
return Token(k, lex);
}
};
-}
+} // namespace folly
TEST(DynamicConverter, example) {
dynamic d1 = dynamic::object("KIND", 2)("LEXEME", "a token");
return B(convertTo<int>(d));
}
};
-}
+} // namespace folly
TEST(DynamicConverter, double_destroy) {
dynamic d = dynamic::array(1, 3, 5, 7, 9, 11, 13, 15, 17);
EIO, "hello world");
}
-}} // namespaces
+} // namespace test
+} // namespace folly
namespace {
template <typename T>
T& r_to_l(T v) { return std::ref(v); }
-}
+} // namespace
TEST(ExceptionWrapper, with_exception_deduction_functor_lvalue) {
auto ew = make_exception_wrapper<std::runtime_error>("hi");
return exception_wrapper{std::current_exception(), e};
}
}
-}
+} // namespace
TEST(ExceptionWrapper, base_derived_non_std_exception_test) {
auto ew = testNonStdException();
struct BigNonStdError {
char data_[sizeof(exception_wrapper) + 1]{};
};
-}
+} // namespace
TEST(ExceptionWrapper, handle_std_exception) {
auto ep = std::make_exception_ptr(std::runtime_error{"hello world"});
Unexpected<E>::BadExpectedAccess);
}
}
-}
+} // namespace folly
}
return lst;
}
-}
+} // namespace
////////////////////////////////////////////////////////////////////////////////
// Tests begin here
template <> int randomObject<int>() {
return random(0, 1024);
}
-}
+} // namespace
////////////////////////////////////////////////////////////////////////////////
// Tests begin here
namespace {
class UserDefinedType { int whatevs_; };
-}
+} // namespace
FOLLY_ASSUME_FBVECTOR_COMPATIBLE(UserDefinedType);
EXPECT_EQ(0440, getPerms(tmpPath("foo_txt")));
EXPECT_EQ(0444, getPerms(tmpPath("foo.txt2")));
}
-}} // namespaces
+} // namespace test
+} // namespace folly
#if defined(__linux__)
namespace {
};
std::atomic<int> FChmodFailure::forceFailure_{0};
-}
+} // namespace
// Replace the system fchmod() function with our own stub, so we can
// trigger failures in the writeFileAtomic() tests.
EXPECT_EQ(0600, getPerms(path));
EXPECT_EQ(set<string>{"foo"}, listTmpDir());
}
-}
-}
+} // namespace test
+} // namespace folly
#endif
const NoncopyableInt& v_;
};
-} // namespace
+} // namespace folly
TEST(Format, NoncopyableArg) {
{
EXPECT_NEAR(100, ticks.load(), 10);
}
-}
+} // namespace folly
}
};
-}
+} // namespace detail
int main(int argc, char** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
size_t hash_vector(const std::vector<T>& v) {
return hash_range(v.begin(), v.end());
}
-}
+} // namespace
TEST(Hash, hash_range) {
EXPECT_EQ(hash_vector<int32_t>({1, 2}), hash_vector<int16_t>({1, 2}));
};
class IndestructibleTest : public testing::Test {};
-}
+} // namespace
TEST_F(IndestructibleTest, access) {
static const Indestructible<map<string, int>> data{
EXPECT_EQ(lz(), 12);
}
-}
+} // namespace folly
}
}
-}} // namespaces
+} // namespace test
+} // namespace folly
int main(int argc, char *argv[]) {
testing::InitGoogleTest(&argc, argv);
std::declval<std::map<int, element_type_t<T>>>(),
std::declval<int>(),
std::declval<T>()))>> : std::true_type {};
-}
+} // namespace
TEST(MapUtil, get_default_temporary) {
EXPECT_TRUE(Compiles<const int&>::value);
std::declval<int>(),
std::declval<int>(),
std::declval<T>()))>> : std::true_type {};
-}
+} // namespace
TEST(MapUtil, get_ref_default_path_temporary) {
EXPECT_TRUE(GetRefDefaultPathCompiles<const int&>::value);
}
}
}
-}
+} // namespace
BENCHMARK_DRAW_LINE();
BENCHMARK(divTruncInt8, iters) {
}
}
}
-}
+} // namespace
TEST(Bits, divTestInt8) {
runDivTests<int8_t, int8_t, int64_t>();
dst[i] = static_cast<char>(255 - i);
}
}
-}
+} // namespace
TEST(memcpy, zero_len)
FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("nonnull-attribute") {
FutexResult(uint32_t, const MockClock::time_point&, uint32_t));
};
-}}
+} // namespace detail
+} // namespace folly
TEST(MemoryIdler, futexWaitValueChangedEarly) {
StrictMock<Futex<MockAtom>> fut;
makeMoveWrapper(p);
}
-} // namespace
+} // namespace folly
std::hash<Optional<int>>()(none);
std::hash<Optional<int>>()(3);
}
-}
+} // namespace folly
FOLLY_PACK_POP
static_assert(sizeof(ignore) == 9, "PackedSyncPtr wasn't packable");
-}
+} // namespace
TEST(PackedSyncPtr, Basic) {
PackedSyncPtr<std::pair<int,int>> sp;
BENCHMARK_PARAM(BM_ProducerConsumerAffinity, 1048574);
BENCHMARK_PARAM(BM_ProducerConsumerLatency, 1048574);
-}
+} // namespace
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
unsigned int DtorChecker::numInstances = 0;
-}
+} // namespace
//////////////////////////////////////////////////////////////////////
<< "; upgrades: " << upgrades.load(std::memory_order_acquire);
}
-}
+} // namespace
bool operator==(StringPiece sp, MutableStringPiece mp) {
return mp.compare(sp) == 0;
}
-}
+} // namespace folly
TEST(ReplaceAt, exhaustiveTest) {
char input[] = "this is nice and long input";
namespace {
struct EagerInitSyncTag {};
-}
+} // namespace
template <typename T, typename Tag = detail::DefaultTag>
using SingletonEagerInitSync = Singleton<T, Tag, EagerInitSyncTag>;
TEST(Singleton, SingletonEagerInitSync) {
namespace {
struct EagerInitAsyncTag {};
-}
+} // namespace
template <typename T, typename Tag = detail::DefaultTag>
using SingletonEagerInitAsync = Singleton<T, Tag, EagerInitAsyncTag>;
TEST(Singleton, SingletonEagerInitAsync) {
namespace {
struct EagerInitParallelTag {};
-}
+} // namespace
template <typename T, typename Tag = detail::DefaultTag>
using SingletonEagerInitParallel = Singleton<T, Tag, EagerInitParallelTag>;
TEST(Singleton, SingletonEagerInitParallel) {
namespace {
Singleton<GlobalWatchdog> global_watchdog;
-}
+} // namespace
// Test basic global usage (the default way singletons will generally
// be used).
// subclasses are created, and the ordering. Also tracks a global
// unique counter for each object.
std::atomic<size_t> global_counter(19770326);
-}
+} // namespace
std::vector<Watchdog*>& Watchdog::creation_order() {
static std::vector<Watchdog*> ret;
};
using FooSingletonTL = SingletonThreadLocal<Foo>;
FooSingletonTL theFooSingleton;
-}
+} // namespace
TEST(SingletonThreadLocalTest, OneSingletonPerThread) {
static constexpr std::size_t targetThreadCount{64};
size_t num_{0};
size_t count_;
};
-}
+} // namespace
template <typename Lock>
class InitLock {
MicroSpinLock lock_;
};
-}
+} // namespace
TEST(SmallLocks, SpinLockCorrectness) {
EXPECT_EQ(sizeof(MicroSpinLock), 1);
std::condition_variable cv_;
bool ready_;
};
-}
+} // namespace
TEST(SmallLocks, MicroLock) {
volatile uint64_t counters[4] = {0, 0, 0, 0};
freeaddrinfo(resultsp);
return !err;
}
-}
+} // namespace folly
private:
static bool isFamilyOfAddrEnabled(const char* addr);
};
-}
+} // namespace folly
EXPECT_EQ(blah.size(), 6);
}
-}
+} // namespace
TEST(Split, split_vector) {
splitTest<std::vector>();
}
return StringPiece(in.end(), in.end());
}
-}
+} // namespace my
TEST(Split, fixed_convert_custom) {
my::Color c1, c2;
auto fdsAfter = getOpenFds();
EXPECT_EQ(fdsAfter.size(), fdsBefore.size());
}
-}
+} // namespace
// Make sure Subprocess doesn't leak any file descriptors
TEST(SimpleSubprocessTest, FdLeakTest) {
// This won't compile without in_place
folly::Synchronized<NotCopiableNotMovable> a(folly::in_place, 5, "a");
}
-}
-}
+} // namespace sync_tests
+} // namespace folly
void testConstCopy();
template <class Mutex>
void testInPlaceConstruction();
-}
-}
+} // namespace sync_tests
+} // namespace folly
#include <folly/test/SynchronizedTestLib-inl.h>
<< acceptableDeltaSecs.count() << " secs of each other";
}
}
-}
+} // namespace test
// Define a PrintTo() function for StringPiece, so that gtest checks
// will print it as a string. Without this gtest identifies StringPiece as a
// standard string types.
*os << ::testing::PrintToString(sp.str());
}
-}
+} // namespace folly
}
}
}
-}
+} // namespace
// Slow test with fewer threads where there are more busy waits and
// many calls to readFull(). This attempts to test as many of the
PthreadKeyUnregister p;
constexpr PthreadKeyUnregisterTester() = default;
};
-}}
+} // namespace threadlocal_detail
+} // namespace folly
TEST(ThreadLocal, UnregisterClassHasConstExprCtor) {
folly::threadlocal_detail::PthreadKeyUnregisterTester x;
namespace {
FOLLY_CREATE_HAS_MEMBER_TYPE_TRAITS(has_member_type_x, x);
-}
+} // namespace
TEST(Traits, has_member_type) {
struct membership_no {};
struct F4 : T1 {};
namespace folly {
- template <> struct IsRelocatable<T1> : std::true_type {};
- template <> FOLLY_ASSUME_RELOCATABLE(T2);
-}
+template <>
+struct IsRelocatable<T1> : std::true_type {};
+template <>
+FOLLY_ASSUME_RELOCATABLE(T2);
+} // namespace folly
TEST(Traits, scalars) {
EXPECT_TRUE(IsRelocatable<int>::value);
template <class T>
struct has_value_type<T, folly::void_t<typename T::value_type>>
: std::true_type {};
-}
+} // namespace
TEST(Traits, void_t) {
EXPECT_TRUE((::std::is_same<folly::void_t<>, void>::value));
public:
mutable MoveConstructOnly val;
};
-}
+} // namespace
TEST(Try, basic) {
A a(5);
namespace {
class UtilityTest : public testing::Test {};
-}
+} // namespace
TEST_F(UtilityTest, copy) {
struct MyData {};
}
} // namespace
-}} // namespaces
+} // namespace test
+} // namespace folly
int main(int argc, char *argv[]) {
testing::InitGoogleTest(&argc, argv);
}
};
-}
+} // namespace
TEST(small_vector, BasicGuarantee) {
for (int prepop = 1; prepop < 30; ++prepop) {
return *this;
}
};
-}
+} // namespace
TEST(small_vector, EmplaceBackEfficiency) {
small_vector<Counter, 2> test;
int count_;
};
-}
+} // namespace
TEST(SortedVectorTypes, SimpleSetTest) {
sorted_vector_set<int> s;
: std::integral_constant<bool,
(f & IS_RELOCATABLE) != 0
> {};
-};
+} // namespace folly
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------