Move runAfterDelay/tryRunAfterDelay into TimeoutManager
[folly.git] / README.md
1 Folly: Facebook Open-source Library
2 -----------------------------------
3
4 ### What is `folly`?
5
6 Folly (acronymed loosely after Facebook Open Source Library) is a
7 library of C++11 components designed with practicality and efficiency
8 in mind. **Folly contains a variety of core library components used extensively
9 at Facebook**. In particular, it's often a dependency of Facebook's other
10 open source C++ efforts and place where those projects can share code.
11
12 It complements (as opposed to competing against) offerings
13 such as Boost and of course `std`. In fact, we embark on defining our
14 own component only when something we need is either not available, or
15 does not meet the needed performance profile. We endeavor to remove
16 things from folly if or when `std` or Boost obsoletes them.
17
18 Performance concerns permeate much of Folly, sometimes leading to
19 designs that are more idiosyncratic than they would otherwise be (see
20 e.g. `PackedSyncPtr.h`, `SmallLocks.h`). Good performance at large
21 scale is a unifying theme in all of Folly.
22
23 ### Logical Design
24
25 Folly is a collection of relatively independent components, some as
26 simple as a few symbols. There is no restriction on internal
27 dependencies, meaning that a given folly module may use any other
28 folly components.
29
30 All symbols are defined in the top-level namespace `folly`, except of
31 course macros. Macro names are ALL_UPPERCASE and should be prefixed
32 with `FOLLY_`. Namespace `folly` defines other internal namespaces
33 such as `internal` or `detail`. User code should not depend on symbols
34 in those namespaces.
35
36 Folly has an `experimental` directory as well. This designation connotes
37 primarily that we feel the API may change heavily over time. This code,
38 typically, is still in heavy use and is well tested.
39
40 ### Physical Design
41
42 At the top level Folly uses the classic "stuttering" scheme
43 `folly/folly` used by Boost and others. The first directory serves as
44 an installation root of the library (with possible versioning a la
45 `folly-1.0/`), and the second is to distinguish the library when
46 including files, e.g. `#include <folly/FBString.h>`.
47
48 The directory structure is flat (mimicking the namespace structure),
49 i.e. we don't have an elaborate directory hierarchy (it is possible
50 this will change in future versions). The subdirectory `experimental`
51 contains files that are used inside folly and possibly at Facebook but
52 not considered stable enough for client use. Your code should not use
53 files in `folly/experimental` lest it may break when you update Folly.
54
55 The `folly/folly/test` subdirectory includes the unittests for all
56 components, usually named `ComponentXyzTest.cpp` for each
57 `ComponentXyz.*`. The `folly/folly/docs` directory contains
58 documentation.
59
60 ### What's in it?
61
62 Because of folly's fairly flat structure, the best way to see what's in it
63 is to look at the headers in [top level `folly/` directory](https://github.com/facebook/folly/tree/master/folly). You can also
64 check the [`docs` folder](folly/docs) for documentation, starting with the
65 [overview](folly/docs/Overview.md).
66
67 Folly is published on Github at https://github.com/facebook/folly
68
69 ### Build Notes
70
71 #### Dependencies
72
73 folly requires gcc 4.8+ and a version of boost compiled with C++11 support.
74
75 Please download googletest from
76 https://googletest.googlecode.com/files/gtest-1.7.0.zip and unzip it in the
77 folly/test subdirectory.
78
79 #### Ubuntu 12.04
80
81 This release is old, requiring many upgrades. However, since Travis CI runs
82 on 12.04, `folly/build/deps_ubuntu_12.04.sh` is provided, and upgrades all
83 the required packages.
84
85 #### Ubuntu 13.10
86
87 The following packages are required (feel free to cut and paste the apt-get
88 command below):
89
90 ```
91 sudo apt-get install \
92     g++ \
93     automake \
94     autoconf \
95     autoconf-archive \
96     libtool \
97     libboost-all-dev \
98     libevent-dev \
99     libdouble-conversion-dev \
100     libgoogle-glog-dev \
101     libgflags-dev \
102     liblz4-dev \
103     liblzma-dev \
104     libsnappy-dev \
105     make \
106     zlib1g-dev \
107     binutils-dev \
108     libjemalloc-dev \
109     libssl-dev
110 ```
111
112 If advanced debugging functionality is required
113
114 ```
115 sudo apt-get install \
116     libunwind8-dev \
117     libelf-dev \
118     libdwarf-dev
119 ```
120
121 #### Ubuntu 14.04 LTS
122
123 The packages listed above for Ubuntu 13.10 are required, as well as:
124
125 ```
126 sudo apt-get install \
127     libiberty-dev
128 ```
129
130 The above packages are sufficient for Ubuntu 13.10 and Ubuntu 14.04.
131
132 In the folly directory, run
133 ```
134   autoreconf -ivf
135   ./configure
136   make
137   make check
138   sudo make install
139 ```
140
141 #### OS X (Homebrew)
142
143 folly is available as a Formula and releases may be built via `brew install folly`.
144
145 You may also use `folly/build/bootstrap-osx-homebrew.sh` to build against `master`:
146
147 ```
148   cd folly
149   ./build/bootstrap-osx-homebrew.sh
150   make
151   make check
152 ```
153
154 #### OS X (MacPorts)
155
156 Install the required packages from MacPorts:
157
158 ```
159   sudo port install \
160     autoconf \
161     automake \
162     boost \
163     gflags \
164     git \
165     google-glog \
166     libevent \
167     libtool \
168     lz4 \
169     lzma \
170     scons \
171     snappy \
172     zlib
173 ```
174
175 Download and install double-conversion:
176
177 ```
178   git clone https://github.com/google/double-conversion.git
179   cd double-conversion
180   cmake -DBUILD_SHARED_LIBS=ON .
181   make
182   sudo make install
183 ```
184
185 Download and install folly with the parameters listed below:
186
187 ```
188   git clone https://github.com/facebook/folly.git
189   cd folly/folly
190   autoreconf -ivf
191   ./configure CPPFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib"
192   make
193   sudo make install
194 ```
195
196 #### Other Linux distributions
197
198 - double-conversion (https://github.com/google/double-conversion)
199
200   Download and build double-conversion.
201   You may need to tell configure where to find it.
202
203   [double-conversion/] `ln -s src double-conversion`
204
205   [folly/] `./configure LDFLAGS=-L$DOUBLE_CONVERSION_HOME/ CPPFLAGS=-I$DOUBLE_CONVERSION_HOME/`
206
207   [folly/] `LD_LIBRARY_PATH=$DOUBLE_CONVERSION_HOME/ make`
208
209 - additional platform specific dependencies:
210
211   Fedora 21 64-bit
212     - gcc
213     - gcc-c++
214     - autoconf
215     - autoconf-archive
216     - automake
217     - boost-devel
218     - libtool
219     - lz4-devel
220     - lzma-devel
221     - snappy-devel
222     - zlib-devel
223     - glog-devel
224     - gflags-devel
225     - scons
226     - double-conversion-devel
227     - openssl-devel
228     - libevent-devel
229
230   Optional
231     - libdwarf-dev
232     - libelf-dev
233     - libunwind8-dev