1### `folly/`
2
3### Components
4
5Below is a list of (some) Folly components in alphabetical order, along with
6a brief description of each.
7
8#### `Arena.h`, `ThreadCachedArena.h`
9
10Simple arena for memory allocation: multiple allocations get freed all
11at once. With threaded version.
12
13#### [`AtomicHashMap.h`, `AtomicHashArray.h`](AtomicHashMap.md), `AtomicHashArray.h`, `AtomicLinkedList.h`, ...
14
15High-performance atomic data-structures. Many of these are built with very specific
16tradeoffs and constraints in mind that make them faster than their more general
17counterparts. Each header should contain information about what these tradeoffs are.
18
19#### `Baton.h`
20
21A Baton allows a thread to block once and be awoken: it captures a single handoff. It is
22essentially a (very small, very fast) semaphore that supports only a single call to `sem_call`
23and `sem_wait`.
24
25#### [`Benchmark.h`](Benchmark.md)
26
27A small framework for benchmarking code. Client code registers
28benchmarks, optionally with an argument that dictates the scale of the
29benchmark (iterations, working set size etc). The framework runs
30benchmarks (subject to a command-line flag) and produces formatted
31output with timing information.
32
33#### `Bits.h`
34
35Various bit manipulation utilities optimized for speed; includes functions
36that wrap the
37[ffsl(l)](http://linux.die.net/man/3/ffsll) primitives in a uniform
38interface.
39
40#### `ConcurrentSkipList.h`
41
42An implementation of the structure described in [A Provably Correct
43Scalable Concurrent Skip
44List](http://www.cs.tau.ac.il/~shanir/nir-pubs-web/Papers/OPODIS2006-BA.pdf)
45by Herlihy et al.
46
47#### [`Conv.h`](Conv.md)
48
49A variety of data conversion routines (notably to and from string),
50optimized for speed and safety.
51
52#### `Demangle.h`
53
54Pretty-printing C++ types.
55
56#### `DiscriminatedPtr.h`
57
58Similar to `boost::variant`, but restricted to pointers only. Uses the
59highest-order unused 16 bits in a pointer as discriminator. So
60`sizeof(DiscriminatedPtr<int, string, Widget>) == sizeof(void*)`.
61
62#### [`dynamic.h`](Dynamic.md)
63
64Dynamically-typed object, created with JSON objects in mind. `DynamicConverter.h` is
65a utility for efficiently converting from a `dynamic` to a more concrete structure when
66the scheme is known (e.g. json -> `map<int,int>`).
67
68#### `EvictingCacheMap.h`
69
70A simple LRU hash map.
71
72#### [`FBString.h`](FBString.md)
73
74A drop-in implementation of `std::string` with a variety of optimizations.
75
76#### [`FBVector.h`](FBVector.md)
77
78A mostly drop-in implementation of `std::vector` with a variety of
79optimizations.
80
81#### `File.h`
82
83A C++ abstraction around files.
84
85#### `Fingerprint.h`
86
87Rabin fingerprinting.
88
89### [`Function.h`](Function.md)
90
91A 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`.
92
93### [`futures/`](Futures.md)
94
95Futures is a framework for expressing asynchronous code in C++ using the Promise/Future pattern.
96
97#### [`Format.h`](Format.md)
98
99Python-style formatting utilities.
100
101#### `gen/`
102
103This library makes it possible to write declarative comprehensions for
104processing sequences of values efficiently in C++ akin to C#'s LINQ.
105
106#### [`GroupVarint.h`](GroupVarint.md)
107
108[Group Varint
109encoding](http://www.ir.uwaterloo.ca/book/addenda-06-index-compression.html)
110for 32-bit values.
111
112#### `IPAddress.h`
113
114A collection of utilities to deal with IPAddresses, including ipv4 and ipv6.
115
116#### `io/`
117
118A collection of useful of abstractions for high-performance io. This is heavily relied upon
119in Facebook's internally networking code.
120
121#### `Hash.h`
122
123Various popular hash function implementations.
124
125#### [`Histogram.h`](Histogram.md)
126
127A simple class for collecting histogram data.
128
129#### `IntrusiveList.h`
130
131Convenience type definitions for using `boost::intrusive_list`.
132
133#### `json.h`
134
135JSON serializer and deserializer. Uses `dynamic.h`.
136
137#### `Likely.h`
138
139Wrappers around [`__builtin_expect`](http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html).
140
141#### `Malloc.h`, `Memory.h`
142
143Memory allocation helpers, particularly when using jemalloc.
144
145#### `MicroSpinLock.h`
146
147A really, *really* small spinlock for fine-grained locking of lots of teeny-tiny data.
148
149#### `MPMCQueue.h`
150
151MPMCQueue<typename> is a high-performance bounded concurrent queue that
152supports multiple producers, multiple consumers, and optional blocking.
153The queue has a fixed capacity, for which all memory will be allocated
154 up front.
155
156The additional utility `MPMCPipeline.h` is an extension that lets you
157chain several queues together with processing steps in between.
158
159#### [`PackedSyncPtr.h`](PackedSyncPtr.md)
160
161A highly specialized data structure consisting of a pointer, a 1-bit
162spin lock, and a 15-bit integral, all inside one 64-bit word.
163
164#### [`Poly.h`](Poly.md)
165
166A class template that makes it relatively easy to define a type-erasing
167polymorphic object wrapper.
168
169#### `Preprocessor.h`
170
171Necessarily evil stuff.
172
173#### [`ProducerConsumerQueue.h`](ProducerConsumerQueue.md)
174
175Lock free single-reader, single-writer queue.
176
177#### `Random.h`
178
179Defines only one function---`randomNumberSeed()`.
180
181#### `Range.h`
182
183Boost-style range facility and the `StringPiece` specialization.
184
185#### `RWSpinLock.h`
186
187Fast and compact reader-writer spin lock.
188
189#### `ScopeGuard.h`
190
191C++11 incarnation of the old [ScopeGuard](http://drdobbs.com/184403758) idiom.
192
193#### `Singleton.h`
194
195A singleton to rule the singletons. This is an attempt to insert a layer between
196C++ statics and the fiasco that ensues, so that things can be created, and destroyed,
197correctly upon program creation, program end and sometimes `dlopen` and `fork`.
198
199Singletons are bad for you, but this may help.
200
201#### [`SmallLocks.h`](SmallLocks.md)
202
203Very small spin locks (1 byte and 1 bit).
204
205#### `small_vector.h`
206
207Vector with the small buffer optimization and an optional embedded
208`PicoSpinLock`.
209
210#### `sorted_vector_types.h`
211
212Collections similar to `std::map` but implemented as sorted vectors.
213
214#### `stats/`
215
216A collection of efficient utilities for collecting statistics:
217* time series counters, gauges, histograms, and quantiles;
218* single-pass mean and variance.
219
220#### `StlAllocator.h`
221
222STL allocator wrapping a simple allocate/deallocate interface.
223
224#### `String.h`
225
226String utilities that connect `folly::fbstring` with `std::string`.
227
228#### `Subprocess.h`
229
230Subprocess library, modeled after Python's subprocess module.
231
232#### [`Synchronized.h`](Synchronized.md)
233
234High-level synchronization library.
235
236#### `System.h`
237
238Demangling and errno utilities.
239
240#### [`ThreadCachedInt.h`](ThreadCachedInt.md)
241
242High-performance atomic increment using thread caching.
243
244#### [`ThreadLocal.h`](ThreadLocal.md)
245
246Improved thread local storage for non-trivial types.
247
248#### `TimeoutQueue.h`
249
250Queue with per-item timeout.
251
252#### `Traits.h`
253
254Type traits that complement those defined in the standard C++11 header
255`<traits>`.
256
257#### `Unicode.h`
258
259Defines the `codePointToUtf8` function.
260
261#### `Uri.h`
262
263A collection of utilities to deal with URIs.
264