extend folly::split

Summary:
see task:
https://our.intern.facebook.com/intern/tasks/?t=4723861

Test Plan: unit tests

Reviewed By: marcelo.juchem@fb.com

FB internal diff: D1443223

Tasks: 4723861
Factor out string stream re-splitting as StreamSplitter

Summary: This way I can reuse it in Subprocess. It also makes it easy to make a bunch of other convenient tokenization routines (e.g. delimiter-preserving folly::gen tokenizers, file tokenizers, etc, etc).

Test Plan: fbconfig folly/gen/test && fbmake runtests

Reviewed By: tjackson@fb.com

Subscribers: vkatich, tjackson

FB internal diff: D1317973
A generic line-reading callback for communicate()

Summary: There are a couple of places where this behavior is useful, and it's not 100% trivial to implement it from scratch. Adding it to Folly to save people code & bugs.

Test Plan: unit tests

Reviewed By: tudorb@fb.com

Subscribers: tjackson, folly@lists, tudorb

FB internal diff: D1297506
Fix the unaligned string toLowerAscii test

Summary:
* The test computed nonaligned inputs but then copied them into temporary
buffers to compare different implementations. The temporary buffers
were word-aligned.
* This diff keeps the temp buffers but ensures that the data in them
keeps the original input's alignment.

Test Plan:
* Ran the test case with a modified String.cpp containing an assert to
catch unaligned reads.  The assert failed, as expected, on a copy
of the code without the fix from D1434585

Reviewed By: meyering@fb.com

Subscribers: ruibalp

FB internal diff: D1435028

Tasks: 4696800
fix D1422343 ("make `folly::Formatter` extendible") for clang

Summary:
This is D1422343, but with a one-line change to make it clang-compatible. I authored this diff by first copying the original, then updating, so it's easy to see what I had to change.

> on advice of @tudorb, move most of `folly::Formatter` into `folly::BaseFormatter` so that we can use compile-time polymorphism to provide different types of Formatters.

Test Plan:
```
fbmake clean
fbconfig -r thrift folly cold_storage && fbmake dbg && fbmake runtests
fbmake clean
fbconfig -r hphp --clang && fbmake dbgo && fbmake runtests
```

Reviewed By: tudorb@fb.com, pt@fb.com

Subscribers: mathieubaudet, tudorb

FB internal diff: D1440310

Tasks: 4624268, 4667712
Fix a folly build failure under clang: FutexTest.cpp.

Summary:
[Folly] Fix a folly build failure under clang: FutexTest.cpp.

In clang-v3.4, there is a bug with the combination of a lambda expression inside a function template taking a template name (rather than a type name) as a template argument.

This diff, in the interest of building folly under clang-v3.4, extracts the lambda expression into a separate function so that the function template taking a template name as a template argument no longer has a lambda expression in it.

Test Plan: Build folly/test/FutexTest.cpp under clang.

Reviewed By: njormrod@fb.com

Subscribers: mathieubaudet, dougw

FB internal diff: D1446237

Tasks: 4723132
Fix a folly build failure under clang: MPMCQueueTest.cpp.

Summary:
[Folly] Fix a folly build failure under clang: MPMCQueueTest.cpp.

In clang-v3.4, there is a bug with the combination of a lambda expression inside a function template taking a template name (rather than a type name) as a template argument.

This diff, in the interest of building folly under clang-v3.4, extracts the lambda expression into a separate function so that the function template taking a template name as a template argument no longer has a lambda expression in it.

Test Plan: Build folly/test/MPMCQueueTest.cpp under clang.

Reviewed By: njormrod@fb.com

Subscribers: mathieubaudet, dougw

FB internal diff: D1446279

Tasks: 4723132
Fix a folly build failure under clang: ConvTest.cpp.

Summary: [Folly] Fix a folly build failure under clang: ConvTest.cpp.

Test Plan: Build the unit-test folly/test/ConvTest.cpp with clang.

Reviewed By: tudorb@fb.com, njormrod@fb.com

Subscribers: mathieubaudet, dougw

FB internal diff: D1446232

Tasks: 4723132
Enforce that only one version of folly is loaded at the same time

Test Plan: folly/test, OSS build, check the macro in separate file

Reviewed By: dancol@fb.com

FB internal diff: D1448086
Make ElfFile not crash on invalid ELF files

Summary:
@rkroll wants to run this on more than just fbcode binaries; there are x86 (not
x86_64) binaries in there and probably a lot of other junk. So, if you call
openNoThrow explicitly, you get a pretty error message in this case.

Test Plan: folly/experimental/symbolizer/test

Reviewed By: lucian@fb.com

Subscribers: rkroll, jhj, lesha, kma

FB internal diff: D1453758
Support trailing decimals for floats

Summary: So integer-like numbers can be formatted in a manner which disambiguates them from integers.

Test Plan: Unit tests

Reviewed By: tudorb@fb.com

Subscribers: jfh, cscheau

FB internal diff: D1454446
Versioning for Thrift, remove thrift/lib/cpp/config.h

Summary:
Also, regenerate thrift_config.h.

Move .gitignore to public_tld so I can add thrift_config.h while still
having it checked into fbcode.

Test Plan: fbconfig -r thrift && fbmake runtests_opt

Reviewed By: meyering@fb.com

Subscribers: alandau, bmatheny, jhj, kma, lesha

FB internal diff: D1449068
(wangle) set* should not invalidate getFuture

Summary: @jcoens observed in D1451114 that it was unintuitive that you have to retrieve the `Future` before fulfilling the `Promise`. That seemed wrong to me too, but sure enough when I wrote the unit tests that doesn't work (throws "promise already fulfilled" when you call `getFuture`). I think this is just a simple mistake, but I'm going to carefully look at the output of contbuild test suites before committing.

Test Plan:
red-green
careful dependency unit test inspection

Reviewed By: jon.coens@fb.com

Subscribers: net-systems@, fugalh, exa, jcoens

FB internal diff: D1453780
Adding one more test for trailing dots

Summary: Sorry, forgot to include tests for the other side of the equation.

Test Plan: It is a test

Reviewed By: tudorb@fb.com

FB internal diff: D1455583
Add method to parse parameter list in query string to folly::Uri

Summary:
Add a method to folly::Uri to get parsed query string

e.g. http://localhost?key1=foo&key2=bar

We can get key value map containing:
"key1" => "foo"
"key2" => "bar"

Test Plan:
fbconfig folly/test
fbmake runtests_dbg

Reviewed By: tudorb@fb.com

Subscribers: wormhole-dev@

FB internal diff: D1455158

Tasks: 4768038
Try again: folly::Singleton, a class for managing singletons

Summary:
Singletons are surprisingly tricky in a codebase where
libraries depend on one another.  folly::Singleton hopes to make this
process more reliable by ensuring object creation happens in a safe
order, that destruction is possible, and that singletons are created
on-demand.

The basic fbcode use intention is to invoke registration completion in
initFacebook, so users need only declare singletons via
Singleton<ClassName> in their .cpp files.

This diff ties the Singletons into the core Init process, but not hhvm
(which will be a separate diff).

Test Plan: runtests

Reviewed By: joelm@fb.com, hans@fb.com

Subscribers: fbcode-common-diffs@, hphp-diffs@, soren, anca, lins, aalexandre, ps, trunkagent, lucian, hannesr, yfeldblum, maxwellsayles

FB internal diff: D1453135
Bump version to 2:0