/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
folly/Below is a list of (some) Folly components in alphabetical order, along with a brief description of each.
Arena.h,
ThreadCachedArena.hSimple arena for memory allocation: multiple allocations get freed all at once. With threaded version.
AtomicHashMap.h,
AtomicHashArray.h, AtomicLinkedList.h, …High-performance atomic data-structures. Many of these are built with very specific tradeoffs and constraints in mind that make them faster than their more general counterparts. Each header should contain information about what these tradeoffs are.
Baton.hA Baton allows a thread to block once and be awoken: it captures a
single handoff. It is essentially a (very small, very fast) semaphore
that supports only a single call to sem_call and
sem_wait.
Benchmark.hA small framework for benchmarking code. Client code registers benchmarks, optionally with an argument that dictates the scale of the benchmark (iterations, working set size etc). The framework runs benchmarks (subject to a command-line flag) and produces formatted output with timing information.
Bits.hVarious bit manipulation utilities optimized for speed; includes functions that wrap the ffsl(l) primitives in a uniform interface.
ConcurrentSkipList.hAn implementation of the structure described in A Provably Correct Scalable Concurrent Skip List by Herlihy et al.
Conv.hA variety of data conversion routines (notably to and from string), optimized for speed and safety.
Demangle.hPretty-printing C++ types.
DiscriminatedPtr.hSimilar to std::variant, but restricted to pointers
only. Uses the highest-order unused 16 bits in a pointer as
discriminator. So
sizeof(DiscriminatedPtr<int, string, Widget>) == sizeof(void*).
dynamic.hDynamically-typed object, created with JSON objects in mind.
DynamicConverter.h is a utility for efficiently converting
from a dynamic to a more concrete structure when the scheme
is known (e.g. json -> map<int,int>).
EvictingCacheMap.hA simple LRU hash map.
FBString.hA drop-in implementation of std::string with a variety
of optimizations.
FBVector.hA mostly drop-in implementation of std::vector with a
variety of optimizations.
File.hA C++ abstraction around files.
Fingerprint.hRabin fingerprinting.
Function.hA polymorphic wrapper for callables similar to
std::function but not copyable and therefore able to wrap
non-copyable callables, such as lambdas that capture move-only types
like std::unique_ptr or folly::Promise.
futures/Futures is a framework for expressing asynchronous code in C++ using the Promise/Future pattern.
Format.hPython-style formatting utilities.
gen/This library makes it possible to write declarative comprehensions for processing sequences of values efficiently in C++ akin to C#’s LINQ.
GroupVarint.hGroup Varint encoding for 32-bit values.
IPAddress.hA collection of utilities to deal with IPAddresses, including ipv4 and ipv6.
io/A collection of useful of abstractions for high-performance io. This is heavily relied upon in Facebook’s internally networking code.
Hash.hVarious popular hash function implementations.
Histogram.hA simple class for collecting histogram data.
IntrusiveList.hConvenience type definitions for using
boost::intrusive_list.
json.hJSON serializer and deserializer. Uses dynamic.h.
Likely.hWrappers around __builtin_expect.
Malloc.h,
Memory.hMemory allocation helpers, particularly when using jemalloc.
MicroSpinLock.hA really, really small spinlock for fine-grained locking of lots of teeny-tiny data.
MPMCQueue.hMPMCQueue
The additional utility MPMCPipeline.h is an extension
that lets you chain several queues together with processing steps in
between.
PackedSyncPtr.hA highly specialized data structure consisting of a pointer, a 1-bit spin lock, and a 15-bit integer, all inside one 64-bit word.
Poly.hA class template that makes it relatively easy to define a type-erasing polymorphic object wrapper.
Preprocessor.hNecessarily evil stuff.
ProducerConsumerQueue.hLock free single-reader, single-writer queue.
Random.hDefines only one function—randomNumberSeed().
Range.hBoost-style range facility and the StringPiece
specialization.
RWSpinLock.hFast and compact reader-writer spin lock.
ScopeGuard.hC++11 incarnation of the old ScopeGuard idiom.
Singleton.hA singleton to rule the singletons. This is an attempt to insert a
layer between C++ statics and the fiasco that ensues, so that things can
be created, and destroyed, correctly upon program creation, program end
and sometimes dlopen and fork.
Singletons are bad for you, but this may help.
SmallLocks.hVery small spin locks (1 byte and 1 bit).
small_vector.hVector with the small buffer optimization and an optional embedded
PicoSpinLock.
sorted_vector_types.hCollections similar to std::map but implemented as
sorted vectors.
stats/A collection of efficient utilities for collecting statistics: * time series counters, gauges, histograms, and quantiles; * single-pass mean and variance.
StlAllocator.hSTL allocator wrapping a simple allocate/deallocate interface.
String.hString utilities that connect folly::fbstring with
std::string.
Subprocess.hSubprocess library, modeled after Python’s subprocess module.
Synchronized.hHigh-level synchronization library.
System.hDemangling and errno utilities.
ThreadCachedInt.hHigh-performance atomic increment using thread caching.
ThreadLocal.hImproved thread local storage for non-trivial types.
TimeoutQueue.hQueue with per-item timeout.
Traits.hType traits that complement those defined in the standard C++11
header <traits>.
Unicode.hDefines the codePointToUtf8 function.
Uri.hA collection of utilities to deal with URIs.