Nicholas Ormrod [Fri, 22 Aug 2014 17:07:25 +0000 (10:07 -0700)]
Fix block overhead estimation in tests
Summary:
folly/test/ArenaTest.h assumes that goodMallocSize will account
for the block overhead, if the size is +1. However, when compiling
without jemalloc (as, I would imagine, most of our open-source clients
do), goodMallocSize(64 + 1) returns 65, which is less than 64 +
sizeof(Block), and so the tests fail.
I have added a constant to Arena.h which exposes the overhead taken by
the Block, and changed the tests to use that value instead of 1.
(Arena::getTotalSize relies on the totalAllocatedSize_ variable, which
is only non-trivially set in allocateSlow, where the size of the heap is
added to sizeof(Block)).
Test Plan: fbconfig --allocator=malloc folly/test:arena_test && fbmake runtests
Reviewed By: jon.coens@fb.com
Subscribers: sdwilsh, njormrod
FB internal diff:
D1512231
Sean Cannella [Thu, 21 Aug 2014 21:26:49 +0000 (14:26 -0700)]
Fix various compiler warnings
Summary:
This allows projects that use -Wextra (sans -Wunused-parameter) to
compile folly.
Test Plan: compiled with gcc and clang
Reviewed By: meyering@fb.com
Subscribers: njormrod, kmdent, fma, benyluo, shikong, ranjeeth, subodh, pgriess
FB internal diff:
D1509827
Nicholas Ormrod [Thu, 21 Aug 2014 19:44:48 +0000 (12:44 -0700)]
Fix #includes
Summary:
A few of folly's includes do not start with folly/, and so were
missed by
D1411225's include-quotation ##""## -> ##<>## transformation change.
There were also some folly includes in deeper folly directories and the
docs, which I also fixed.
The search ##egrep "# *include *\"" -R folly/*## now only includes two
lines in FBString.h, which are included for libgcc purposes.
The wangle/test/Thens.cpp file, which is auto-generated, was special.
I changed the generator .rb script, but when I ran it I overwrote some
manual changes to Thens.cpp. For simplicity, I have manually applied the
change to Thens.cpp as well.
Test Plan: fbconfig -r folly && fbmake runtests
Reviewed By: hannesr@fb.com
Subscribers: sdwilsh, fugalh
FB internal diff:
D1511712
Jim Meyering [Sun, 17 Aug 2014 21:34:32 +0000 (14:34 -0700)]
fbcode: __x__-protect all __attribute__ keywords, mechanically
Summary:
The first (and sometimes 2nd) argument to __attribute__
should begin and end with "__". If it does not, then it
is at risk of conflicting with user cpp-defined symbols.
Don't do that. This change mechanically corrects most
such violations in fbcode. A companion change (see parent task)
adds a lint rule to help keep things clean going forwards.
Define this function to filter the list of file names to which
we will apply the transformations. First, ensure we modify only
C and C++ sources. The second process excludes a few directories
that appear to contain third-party code:
filter() {
grep -E '\.(c|h|cc|cpp|hpp)$' | grep -vE \
'^external/|/unbound/|/gearmand_|(3rd|third.)party|/external/libevent'
}
then, run this command,
git grep -l __attribute__ | filter \
| xargs perl -pi -e 's/(__attribute__ *)\(\(( *[^_]\w+)/$1((__${2}__/g'
inducing changes like this, for each such keyword:
-} __attribute__((packed));
+} __attribute__((__packed__));
That got all but the __format__ archetype arguments like this:
__attribute__((__format__(printf. That final "printf"
keyword should have the "__" prefix and suffix, too.
Run this command to transform those remaining uses:
git grep -l '__attribute__.*__format' | filter | xargs perl -pi -e \
's/(__attribute__ *\(\(__format__ *)\( *(printf|scanf|strftime|strfmon)/$1(__${2}__/g'
That command induces changes like this:
-static inline int __attribute__ ((__format__ (printf, 3, 4)))
+static inline int __attribute__ ((__format__ (__printf__, 3, 4)))
This exercise is useful to avoid spurious name-space conflicts,
especially when the unprotected keyword is used in a header file.
Test Plan:
I've ensured tao builds and passes its tests.
I will watch the arc-run tests.
Reviewed By: njormrod@fb.com
Subscribers: rounak, trunkagent, hphp-diffs@, nli, ps, fbcode-common-diffs@, mcdonald, chaoyc, bill, search-fbcode-diffs@, lars, net-systems@, davejwatson, varunk, ruibalp, hero-diffs@, andrewcox, sorg, dfechete, dhruba, sdoroshenko, mcduff, marccelani, hitesh, mshneer, cold-storage-diffs@, omry, jcoens, unicorn-diffs@, ldbrandy, sumeet, abirchall, fugalh, atlas2-eng@, dcapra, mpawlowski, alandau, nkgupta, shilin, bmatheny, everstore-dev@, zhuohuang, wormhole-diffs@, vnalla, msk, maoy, mwa, jgehring, adsatlasreporting@, mconnor, oujin, bwester, micha, tulloch, ptc, logdevice-diffs, alikhtarov, shikong, fuegen
FB internal diff:
D1508983
Tasks:
4947824
@override-unit-failures
Dave Watson [Fri, 8 Aug 2014 18:28:15 +0000 (11:28 -0700)]
Add link-local scope handling
Summary: Also save the link-local scope in the V6 address. See
D1479365 for more details
Test Plan: fbconfig folly/test:network_address_test; fbmake runtests
Reviewed By: simpkins@fb.com
Subscribers: marccelani, doug, ps, bmatheny
FB internal diff:
D1486435
Marcin Pawlowski [Wed, 20 Aug 2014 05:25:05 +0000 (22:25 -0700)]
made toAppendDelim better
Summary:
preallocate once and for all, so that we
are really malloc efficient in toAppendDelim
Test Plan: unit tests
Reviewed By: marcelo.juchem@fb.com
FB internal diff:
D1496310
Tasks:
4886092
Nicholas Ormrod [Wed, 20 Aug 2014 01:23:44 +0000 (18:23 -0700)]
Fix Optional test for -fb platform
Summary:
The Optional test relied on std::string clearing its data when
it is the source of a move. This does not happen for in-situ fbstrings,
so the test breaks in the -fb platform. The solution: wrap the string in
a class that explicitly invalidates its data upon a move.
Test Plan:
fbconfig --platform-all=gcc-4.8.1-glibc-2.17-fb -r folly
fbmake runtests
fbconfig -r folly
fbmake runtests
Reviewed By: tudorb@fb.com
Subscribers: sdwilsh
FB internal diff:
D1506840
Tasks:
4943996
Tom Jackson [Thu, 14 Aug 2014 05:17:05 +0000 (22:17 -0700)]
hash_range
Test Plan: Unit test
Reviewed By: andrei.alexandrescu@fb.com
Subscribers: shilin
FB internal diff:
D1497250
Hannes Roth [Tue, 19 Aug 2014 22:26:47 +0000 (15:26 -0700)]
(Wangle) Optimize empty continuation
Summary: It should remove one malloc as per the task.
Test Plan: `fbconfig folly/wangle && fbmake runtests` Also, `--clang`.
Reviewed By: davejwatson@fb.com
Subscribers: fugalh
FB internal diff:
D1498331
Tasks:
4913277
Tudor Bosman [Sat, 16 Aug 2014 22:09:20 +0000 (15:09 -0700)]
Add Optional::value_or
Summary:
Common pattern: a function returns Optional<X>, indicating whether some X was
present or not; you want a default value if the X was not present. Requires
that X is copiable.
Test Plan: optional_test (test added)
Reviewed By: tjackson@fb.com
Subscribers: aalexandre, fjargsto, jhj, ntv, lesha, kma
FB internal diff:
D1502397
Jez Ng [Tue, 19 Aug 2014 00:33:23 +0000 (17:33 -0700)]
Fix json_test's lookup of test files.
Summary:
The test runner for folly seems to run from folly/test rather than the base fbcode directory. This hack ensures that we find the necessary test files in either case.
This fixes the breakage introduced by {
D1493963}.
Test Plan: fbconfig -r folly && fbmake runtests
Reviewed By: davejwatson@fb.com
Subscribers: dipanshu
FB internal diff:
D1502161
Andrey Kashin [Mon, 18 Aug 2014 19:08:19 +0000 (12:08 -0700)]
Enabling folly::Synchronized for non-default constructible objects
Summary:
Currently folly::Synchronized can't be used with non-default
constructible types because copy and move constructors require
creation of datum_ before it's assignment.
To fix this we can initialize them in initializer-list and
handle guard creation using helper constructor
Test Plan:
fbconfig -r folly && fbmake runtests
Fixes compilation error: Synchronized started working for non-default
constructible types in my project(rfe).
Reviewed By: yuri@fb.com
Subscribers: dhruvbird
FB internal diff:
D1502110
Darren Mo [Sun, 17 Aug 2014 00:32:54 +0000 (17:32 -0700)]
Clang Love
Summary: Added support for clang in Checksum.cpp preprocessor statements.
Test Plan: The right code path is chosen using both gcc and clang now.
Reviewed By: brianp@fb.com
Subscribers: mathieubaudet, sroy, satadru
FB internal diff:
D1502289
Jez Ng [Fri, 15 Aug 2014 17:29:26 +0000 (10:29 -0700)]
Factor out JSON stripComments().
Summary:
Comments are a useful extension to JSON, especially for configuration files.
Facebook: twagent would previously barf on JSON files that contained '//' in their strings, and this commit allows twagent to strip comments properly. Fixes T4686066.
Test Plan: fbconfig common/json mcrouter/lib/config tupperware/agent && fbmake runtests
Reviewed By: aravindn@fb.com
Subscribers: anarayanan, pavlo, stepan, dipanshu, alikhtarov
FB internal diff:
D1493963
Tasks:
4686066
Sara Golemon [Fri, 15 Aug 2014 05:38:03 +0000 (22:38 -0700)]
Bump version to 3:2
Sara Golemon [Fri, 15 Aug 2014 05:30:58 +0000 (22:30 -0700)]
don't use readFromSysfs on non-linux
Summary:
It eventually tries to read from /sys/devices which is not portable.
Let's just fall back to sysconf/CacheLocality::uniform.
This fixes a runtime crash on OSX, but CYGWIN/BSD were probably also
affected.
Closes #80
@override-unit-failures
Test Plan: author tested, contbuild, flib
Reviewed By: joelm@fb.com
FB internal diff:
D1498567
Sara Golemon [Fri, 15 Aug 2014 04:53:49 +0000 (21:53 -0700)]
Add missing s6_addr16 define for MacOSX targets
Summary:
This is a known issue on Darwin
@override-unit-failures
Test Plan: folly/detail/IPAddress.h compiles on a mac
Reviewed By: joelm@fb.com
FB internal diff:
D1499795
Sara Golemon [Fri, 15 Aug 2014 02:19:11 +0000 (19:19 -0700)]
Bump version to 3:1
Daniel Sloof [Thu, 14 Aug 2014 21:12:19 +0000 (14:12 -0700)]
be explicit about what integer type we're using
Summary:
Fixes the OSX build.
Closes #79
Test Plan: author tested, contbuild, flib
Reviewed By: joelm@fb.com
FB internal diff:
D1498545
Sara Golemon [Thu, 14 Aug 2014 18:49:22 +0000 (11:49 -0700)]
Bump version to 3:0
Hannes Roth [Thu, 14 Aug 2014 15:52:49 +0000 (08:52 -0700)]
(Wangle) Generic void star callback wrapper
Summary: Less generic than I hoped for. Naming is terrible.
Test Plan:
`fbconfig -r tao/client && fbmake runtests` -- I figured if it compiles
it works. Also did a `--sanitize=address` build just in case.
Reviewed By: hans@fb.com
Subscribers: fugalh, zhuohuang, anca
FB internal diff:
D1470483
Philip Pronin [Thu, 14 Aug 2014 07:07:59 +0000 (00:07 -0700)]
fix build (gtest 1.6 -> 1.7)
Summary:
D1494614 migrated us to gtest 1.7 which broke multiple builds (with
"error: 'tuple' is already declared in this scope" coming from
https://code.google.com/p/googletest/source/detail?spec=svn621&r=621).
This diff makes folly compatible with both versions of gtest, and the rest
of fbcode is now compatible with gtest 1.7.
Test Plan: fbconfig -r folly unicorn/diskindex4 && fbmake opt -j32
Reviewed By: jiayan@fb.com
Subscribers: fbcode-common-diffs@, chaoyc, search-fbcode-diffs@, sdoroshenko, cold-storage-diffs@, unicorn-diffs@
FB internal diff:
D1497389
Tasks:
4909974,
4910547,
4910567,
4909983
Ranjeeth Dasineni [Thu, 7 Aug 2014 07:34:11 +0000 (00:34 -0700)]
move EvictingCacheMap to folly
Summary:
adding @agartrell's implementation of EvictingCacheMap to folly. Its a general purpose
cache with LRU eviction. It maintains a doubly linked list threaded throught a hash map using
boost::intrusive. set, get and delete are all constant time operations. It is not thread safe.
Configurability: It allows callers to specify a hasher for the keys, has callbacks for eviction
events and the number of evictions on reaching a capacity limit is configurable. resizing for
a higher capacity though could be suboptimal since index is not resized accordingly and you could
end up with a bad load factor.
Test Plan: unit tests
Reviewed By: tulloch@fb.com, njormrod@fb.com
Subscribers: tulloch, chrisbray, mhx, doug, agartrell
FB internal diff:
D1483789
Josh Watzman [Wed, 13 Aug 2014 22:05:12 +0000 (15:05 -0700)]
Remove constructor version attribute on OS X
Summary:
OS X doesn't support this -- it requires support at the linker
level which OS X just doesn't have. Reasonable OS X compilers will yell
about it, but even the ones that don't are just silently dropping it
on the floor.
So I'm not sure what //we// can do other than just silently dropping
this on the floor too and hoping that everything works.
Test Plan:
HHVM build on OS X gets ever so slightly further (runs into
other issues). HHVM build in fbcode still seems to build folly okay
(didn't wait for it to finish fully).
Fixes https://github.com/facebook/folly/issues/78
Reviewed By: tudorb@fb.com
FB internal diff:
D1487191
Blame Revision: rFBCODE502be7cb0fda306ddc33b9c5ad7a53b0cfbdc893
Brian Pane [Wed, 13 Aug 2014 06:00:02 +0000 (23:00 -0700)]
Small memory footprint reduction for folly::MultiLevelTimeSeries
Summary:
* Spend some extra time in getNumBuckets() in order to save
space: 8 bytes per object on 64-bit platforms.
Test Plan: Ran the unit tests
Reviewed By: simpkins@fb.com
Subscribers: ruibalp
FB internal diff:
D1488345
Lucian Grijincu [Tue, 12 Aug 2014 01:14:21 +0000 (18:14 -0700)]
folly: operator << for MutableStringPiece
Test Plan: n.a
Reviewed By: philipp@fb.com
FB internal diff:
D1487919
Nathan Bronson [Thu, 31 Jul 2014 06:08:17 +0000 (23:08 -0700)]
always log from LOG_EVERY_MS if interval is <= 0
Summary:
This diff changes LOG_EVERY_MS so that if the specified
interval is zero or negative, no clock call is made and LOG(severity) is
always called. milli_interval is copied into a temporary to avoid
double-evaluation.
Test Plan:
1. unit tests
2. new unit test
Reviewed By: lesha@fb.com
FB internal diff:
D1469366
Tasks:
4813858
Chip Turner [Fri, 8 Aug 2014 10:41:20 +0000 (03:41 -0700)]
Fix test breakage in clang
Summary:
clang would re-use the same memory location for recreated
objects, so instead of checking pointers, we can use a serial number.
Test Plan: runtests with fbconfig --clang
Reviewed By: lins@fb.com
Subscribers: mathieubaudet, lins, anca
FB internal diff:
D1485907
Marc Celani [Thu, 7 Aug 2014 20:24:05 +0000 (13:24 -0700)]
store ipaddresses in folly::IPAddress
Summary: Save space and avoid extra mallocs
Test Plan: fbconfig -r smc/zeus; fbmake runtests
Reviewed By: henryf@fb.com
Subscribers: zeus-diffs@
FB internal diff:
D1476688
Tasks:
4832974
Sarang Masti [Thu, 31 Jul 2014 00:45:16 +0000 (17:45 -0700)]
Add timed_wait and try_wait to Baton
Summary:
This diff adds timed_wait that allows waiting on the Baton
with a timeout. The diff also adds try_wait which doesn't
block the thread at all.
Test Plan:
-- added new unit tests
-- ran all folly tests
Reviewed By: ngbronson@fb.com
Subscribers: bwatling
FB internal diff:
D1468909
Tasks:
4679428
Philip Pronin [Sat, 2 Aug 2014 08:48:46 +0000 (01:48 -0700)]
EliasFanoReader::{jump,jumpTo}
Summary:
Renamed `goTo` to `jump`, introduced `jumpTo`.
FBCode: Updated CSS tree benchmark to compare with EF-based search that
is using `jumpTo` (P14517259).
Test Plan: fbconfig -r folly/experimental/test:eliasfano_test && fbmake runtests_opt -j32
@override-unit-failures
Reviewed By: lucian@fb.com
Subscribers: fbcode-common-diffs@
FB internal diff:
D1474431
Tasks:
4536072
Henry Filgueiras [Wed, 6 Aug 2014 18:39:55 +0000 (11:39 -0700)]
Improve IPAddress::toFullyQualified() CPU performance
Summary:
Currently IPAddress::toFullyQualified() is fairly slow for IPv6.
Change here implements more lightweight in_addr/in6_addr to string functions.
I also added a benchmark for comparison with inet_ntop.
This makes IPAddressV6::toFullyQualified() significantly faster than inet_ntop, and makes IPAddressV4::str() ~20ns faster than previous impementation (previously ~80ns).
Previous benchmark:
============================================================================
folly/test/IPAddressBenchmark.cpp relative time/iter iters/s
============================================================================
ipv4_to_string_inet_ntop 238.91ns 4.19M
ipv4_to_fully_qualified 289.96% 82.39ns 12.14M
----------------------------------------------------------------------------
ipv6_to_string_inet_ntop 780.72ns 1.28M
ipv6_to_fully_qualified 51.11% 1.53us 654.59K
============================================================================
With this change:
============================================================================
folly/test/IPAddressBenchmark.cpp relative time/iter iters/s
============================================================================
ipv4_to_string_inet_ntop 238.06ns 4.20M
ipv4_to_fully_qualified 364.76% 65.26ns 15.32M
----------------------------------------------------------------------------
ipv6_to_string_inet_ntop 770.74ns 1.30M
ipv6_to_fully_qualified 791.63% 97.36ns 10.27M
============================================================================
Test Plan:
fbconfig folly/test:network_address_test folly/test:network_address_benchmark
fbmake runtests_opt
Reviewed By: simpkins@fb.com
Subscribers: ps, bmatheny
FB internal diff:
D1477925
Tasks:
4832974
Jim Meyering [Tue, 5 Aug 2014 20:16:15 +0000 (13:16 -0700)]
folly/test: correct an erroneous test for failed mmap
Summary:
* folly/test/AtomicHashArrayTest.cpp (MmapAllocator):
Upon failure, mmap returns MAP_FAILED, not NULL.
Test Plan:
fbconfig -r folly/test:atomic_hash_array_test && fbmake runtests
Reviewed By: mwang@fb.com
FB internal diff:
D1481080
Tasks:
4846893
Philip Pronin [Sun, 3 Aug 2014 00:33:03 +0000 (17:33 -0700)]
streaming support for EF compression
Test Plan: fbconfig -r folly/experimental/test:eliasfano_test && fbmake opt -j32
Reviewed By: lucian@fb.com
Subscribers: chaoyc, search-fbcode-diffs@, unicorn-diffs@
FB internal diff:
D1474625
Tasks:
4828866
Jim Meyering [Tue, 5 Aug 2014 18:45:25 +0000 (11:45 -0700)]
folly/IndexedMemPool: correct an erroneous test for failed mmap
Summary:
* folly/IndexedMemPool.h (IndexedMemPool): Correct the test for
failed mmap. Upon failure, it returns MAP_FAILED, not nullptr.
Test Plan:
fbconfig -r folly/test:indexed_mem_pool_test && fbmake runtests
Reviewed By: ngbronson@fb.com
FB internal diff:
D1480389
Tasks:
4846893
@override-unit-failures
Marc Celani [Tue, 5 Aug 2014 13:04:24 +0000 (06:04 -0700)]
sorted_vector containers have a shrink_to_fit() method
Summary: Adds a shrink_to_fit() method to sorted vector types.
Test Plan: unit test
Reviewed By: mshneer@fb.com
FB internal diff:
D1477864
Marc Horowitz [Fri, 11 Jul 2014 23:48:20 +0000 (16:48 -0700)]
Don't check for thread running in terminateLoopSoon()
Summary:
Consider this use case:
thread 1:
make an evb
create and start thread 2
do some work
evb->terminateLoopSoon()
join thread 2 with a timeout
thread 2:
do some initialization
evb->loop()
Normally, this all works fine. However, if the work thread 1 has to do is sufficiently small, and no external input occurs (one of the thing the evb is doing is listening on a socket), then sometimes, terminateLoopSoon() happens before loop() is called (or at least, before loopThread_.store() happens). isRunning() in terminateLoopSoon() is false, and so stop_ is never set, and event_base_loopbreak() is never called. The join times out, and thread 2 is still running. Removing the isRunning() check gives the desired behavior.
Test Plan:
In my ad hoc tests, this fix caused my threads to exit when
I wanted them to exit in a situation like the one above.
Reviewed By: andrewcox@fb.com
FB internal diff:
D1455885
Tasks:
2057547
Ranjeeth Dasineni [Fri, 1 Aug 2014 03:01:24 +0000 (20:01 -0700)]
rfc: move folly::json::ParseError type to folly/json.h
Summary:
I don't know why this was in the cpp but seems pretty safe to move it to the .h
There are a few files that directly include json.cpp to get around this: https://fburl.com/
30544625.
I need it for something else and if you dont see a problem I want to move it.
Test Plan: unittests
Reviewed By: pgriess@fb.com
Subscribers: simpkins, doug
FB internal diff:
D1471958
Tasks:
3623725
Philip Pronin [Fri, 1 Aug 2014 20:13:03 +0000 (13:13 -0700)]
EliasFanoReader::goTo()
Summary: Random lookup support.
Test Plan: fbconfig -r folly/experimental/test:eliasfano_test && fbmake runtests_opt -j32
@override-unit-failures
Reviewed By: soren@fb.com
FB internal diff:
D1473244
Tasks:
4536072
Hitesh Khandelwal [Thu, 31 Jul 2014 21:47:46 +0000 (14:47 -0700)]
API for getTimeoutManager
Test Plan: Tested end-to-end with
D1342452
Reviewed By: mshneer@fb.com
Subscribers: alandau, bmatheny
FB internal diff:
D1470814
Tasks:
2682011
Dave Watson [Thu, 31 Jul 2014 16:36:37 +0000 (09:36 -0700)]
install delayeddestruction header
Summary: added recently, needs to be installed
Test Plan: watch fbthrift contbuild
Reviewed By: noamz@fb.com
Subscribers: doug
FB internal diff:
D1469760
Blame Revision:
D1453095
Rushi Desai [Thu, 31 Jul 2014 04:08:51 +0000 (21:08 -0700)]
Construct Later with exception_ptr
Summary:
It would be nice to be able to create a Later with pre-loaded
exception.
Test Plan: Unit test
Reviewed By: hans@fb.com
Subscribers: fugalh
FB internal diff:
D1462810
Alan Frindell [Wed, 23 Jul 2014 00:39:03 +0000 (17:39 -0700)]
Move TDelayedDestruction to folly::DelayedDestruction
Summary: This doesn't have many thrift dependencies and I need it for another async class I'm adding to folly.
Test Plan: unit tests
Reviewed By: alandau@fb.com
Subscribers: doug, mcduff, marccelani, mshneer, alandau, bmatheny
FB internal diff:
D1453095
Marc Celani [Fri, 25 Jul 2014 22:59:12 +0000 (15:59 -0700)]
IPAddress::empty()
Summary: Checks if IPAddress has not been initialized.
Test Plan: unit test
Reviewed By: tudorb@fb.com
Subscribers: tudorb
FB internal diff:
D1459525
Chip Turner [Fri, 25 Jul 2014 16:07:33 +0000 (09:07 -0700)]
Bump version to 2:0
Chip Turner [Fri, 23 May 2014 03:17:14 +0000 (20:17 -0700)]
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
Jun LI [Fri, 25 Jul 2014 00:07:36 +0000 (17:07 -0700)]
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
Tom Jackson [Thu, 24 Jul 2014 17:37:15 +0000 (10:37 -0700)]
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
Hans Fugal [Wed, 23 Jul 2014 22:12:19 +0000 (15:12 -0700)]
(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
Tudor Bosman [Tue, 22 Jul 2014 03:33:17 +0000 (20:33 -0700)]
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
Tom Jackson [Thu, 24 Jul 2014 00:19:47 +0000 (17:19 -0700)]
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
Tudor Bosman [Wed, 23 Jul 2014 22:16:32 +0000 (15:16 -0700)]
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
Tudor Bosman [Mon, 21 Jul 2014 22:18:02 +0000 (15:18 -0700)]
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
Yedidya Feldblum [Mon, 21 Jul 2014 23:37:40 +0000 (16:37 -0700)]
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
Yedidya Feldblum [Mon, 21 Jul 2014 21:31:09 +0000 (14:31 -0700)]
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
Yedidya Feldblum [Mon, 21 Jul 2014 21:10:43 +0000 (14:10 -0700)]
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
Tyler MacDonald [Mon, 21 Jul 2014 21:08:47 +0000 (14:08 -0700)]
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
Brian Pane [Mon, 21 Jul 2014 18:26:19 +0000 (11:26 -0700)]
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
Alexey Spiridonov [Fri, 25 Apr 2014 22:21:49 +0000 (15:21 -0700)]
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
Alexey Spiridonov [Thu, 8 May 2014 00:43:51 +0000 (17:43 -0700)]
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
Marcin Pawlowski [Fri, 18 Jul 2014 04:50:01 +0000 (21:50 -0700)]
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
Tudor Bosman [Mon, 21 Jul 2014 19:22:08 +0000 (12:22 -0700)]
Bump version to 1:0
Philip Pronin [Thu, 17 Jul 2014 20:05:02 +0000 (13:05 -0700)]
make folly::Range literal type
Summary:
7.1.5 [dcl.constexpr] / 9 (N3337) requires type to be literal to use it
in `constexpr` object declaration (seems to be not enforced by GCC 4.8?)
Currently `folly::Range<>` fails one of the requirements:
* is an aggregate type, or has at least one constexpr constructor or
constructor template that is not a copy or move constructor,
Test Plan: fbconfig folly/test:range_test && fbmake runtests_opt -j32
Reviewed By: lucian@fb.com
Subscribers: chaoyc, search-fbcode-diffs@, unicorn-diffs@
FB internal diff:
D1441646
Tasks:
4720575
Zejun Wu [Thu, 17 Jul 2014 16:49:39 +0000 (09:49 -0700)]
Check for self-assignment in move assignment
Summary:
Check for self-assignment in move assignment. Otherwise
Optional<Neko> cat = whatever;
cat = std::move(cat);
cat.hasValue(); // always returns false
Test Plan: fbmake runtests
Reviewed By: tjackson@fb.com
FB internal diff:
D1440633
Marcin Pawlowski [Tue, 15 Jul 2014 22:30:57 +0000 (15:30 -0700)]
reserve capacity in toAppend<StringType>(...)
Summary:
I modified the toAppend(args..., StringType* dest) so that
before appending it reserves enough space for data to be appended. It is
still work in progress (floats and doubles are really bad: we only do
very naive approximation of the size). On float like workload we gain
~10% perf, on strings/ints/chars we gain as much as 25% of perf.
Probably on bigger strings it will be even faster. We only modify the
case when toAppend() has more than 1 element to append as it would be
just overhead in case of one argument.
Test Plan:
with this change:
============================================================================
folly/test/ConvTest.cpp relative time/iter
iters/s
============================================================================
preallocateTestNoFloat 1.59us 627.85K
preallocateTestFloat 1.09us 920.70K
----------------------------------------------------------------------------
============================================================================
without the change:
============================================================================
folly/test/ConvTest.cpp relative time/iter
iters/s
============================================================================
preallocateTestNoFloat 2.12us 471.43K
preallocateTestFloat 1.22us 818.25K
----------------------------------------------------------------------------
============================================================================
Reviewed By: marcelo.juchem@fb.com
FB internal diff:
D1420588
Tasks:
4632421
Marcin Pawlowski [Tue, 15 Jul 2014 22:20:29 +0000 (15:20 -0700)]
added replaceAt and replaceAll to MutableStringPiece
Summary:
To make MutableStringPiece more usable (and make the
implementation of replace* methods easier) I made sure that
all the const methods (like find) work for MutableStringPiece
in a fashion similar to how they work with StringPiece
(work with everything auto convertible to StringPiece). As
a result this change is pretty susbstatial in LOC, even
though now much happens here.
Test Plan: unit tests
Reviewed By: marcelo.juchem@fb.com
FB internal diff:
D1420965
Tasks:
4632424
Jim Meyering [Mon, 14 Jul 2014 23:21:07 +0000 (16:21 -0700)]
folly: toLowerAscii: avoid unaligned access; also correct 3 conditions
Summary:
* folly/String.cpp (toLowerAscii): Fix two errors: the most important
would cause unaligned accesses. This would cause a performance loss
in general, but would also result in segfaults on ARM processes.
In addition, three conditionals were wrong, further limiting
the performance of this code: switch those "<" to "<=".
Test Plan:
Run this to exercise existing tests:
fbconfig folly/test:string_test && fbmake runtests_opt
Run this to generate timing stats (before and after this change), e.g.,
fbconfig folly/test:string_benchmark && fbmake opt
_bin/folly/test/string_benchmark > TIMING-toLower-old
These numbers show a 1.6% speed increase with this change:
--- TIMING-toLower-old 2014-07-14 16:51:12.
793523778 -0700
+++ TIMING-toLower-new 2014-07-14 16:49:45.
815119145 -0700
@@ -1,6 +1,6 @@
============================================================================
folly/test/StringBenchmark.cpp relative time/iter iters/s
============================================================================
-libc_tolower 1.06us 941.91K
-folly_toLowerAscii 89.99ns 11.11M
+libc_tolower 1.06us 941.90K
+folly_toLowerAscii 88.57ns 11.29M
============================================================================
Reviewed By: brianp@fb.com
Subscribers:
FB internal diff:
D1434585
Tasks:
4696800
Blame Revision:
D1421056
Tudor Bosman [Tue, 15 Jul 2014 00:49:34 +0000 (17:49 -0700)]
oops, remove stray libgtest
Reviewed By: lesha@fb.com
Test Plan: no
Tudor Bosman [Mon, 14 Jul 2014 20:21:55 +0000 (13:21 -0700)]
Update folly/thrift README with tested deps for Ubuntu 13.10 and 14.04
Test Plan: no
Reviewed By: lesha@fb.com
Subscribers: alandau, jhj, kma
FB internal diff:
D1434163
Tudor Bosman [Mon, 14 Jul 2014 20:24:27 +0000 (13:24 -0700)]
Allow undefined LZ4_MAX_INPUT_SIZE
Summary:
Because the version of lz4 that ships by default with Ubuntu 13.10 doesn't
define it (but has lz4_decompress_safe, so it's usable)
Test Plan: built on Ubuntu 13.10
Reviewed By: meyering@fb.com
Subscribers: jhj, lesha, kma
FB internal diff:
D1433864
@override-unit-failures
Pavlo Kushnir [Mon, 7 Jul 2014 04:03:36 +0000 (21:03 -0700)]
Fix IPAddress operator==
Summary: IPAddress operator== throws an exception when comparing ip v6 mapped address with unitialized (default constructed) address. With this diff it returns false.
Test Plan: folly unit tests
Reviewed By: bmatheny@fb.com
FB internal diff:
D1421280
Gunjan Sharma [Thu, 10 Jul 2014 00:50:19 +0000 (17:50 -0700)]
Fix another race in Notification Queue
Summary: Consider a case we found that the queue is empty and unlocked and before our setActive(false) from SCOPE_EXIT gets called (or gets the lock) putMessageImpl got the lock. Now putMessage thinks that we donot want to add another signal but actually we do.
Test Plan:
Running mcreplay2 without running into this problem on a box.
Benchmark:
Reviewed By: davejwatson@fb.com
FB internal diff:
D1428249
Tudor Bosman [Thu, 10 Jul 2014 19:40:18 +0000 (12:40 -0700)]
Enforce max uncompressed size; use safe LZ4 decompressor, which requires a newer version of LZ4
Test Plan: folly/io/test, whatever contbuild dreams up for hphp
Reviewed By: meyering@fb.com
Subscribers: meyering, hphp-diffs@, ps, jhj, kma, sainbar, lesha
FB internal diff:
D1429372
@override-unit-failures
Elizabeth Smith [Thu, 10 Jul 2014 22:52:22 +0000 (15:52 -0700)]
Small changes for cygwin build
Summary:
Folly is almost "out of the box" working with cygwin
This has the proper ifdefs to include cygwin in two areas and a workaround for a cygwin bug when including headers
Test Plan: fbconfig -r folly && fbmake runtests
Reviewed By: delong.j@fb.com
FB internal diff:
D1413303
Elizabeth Smith [Thu, 10 Jul 2014 22:19:57 +0000 (15:19 -0700)]
MSVC includes for inet/sockets
Summary:
MSVC has all the sockets and internet functionality required except for one missing item - which can safely be defined to a windows specific type
But it requires a different set of headers than on *nix systems
Test Plan: fbconfig -r folly && fbmake runtests
Reviewed By: delong.j@fb.com
FB internal diff:
D1413265
Elizabeth Smith [Thu, 10 Jul 2014 22:15:26 +0000 (15:15 -0700)]
MSVC intrinsics for bits and cpuid
Summary: Use msvc intrinsics for cpuid, popcount, byteswap, and bit scan functionality
Test Plan: fbconfig -r folly && fbmake runtests
Reviewed By: delong.j@fb.com
FB internal diff:
D1413254
Elizabeth Smith [Thu, 10 Jul 2014 21:54:28 +0000 (14:54 -0700)]
Expression SFINAE issue in base.h
Summary:
MSVC 14 is still broken with expression sfinae - and the things that break are often strange
Moving this out into two expr templates solves the compilation issue
Test Plan: fbconfig -r folly && fbmake runtests
Reviewed By: tjackson@fb.com
FB internal diff:
D1413297
Wez Furlong [Thu, 10 Jul 2014 18:37:17 +0000 (11:37 -0700)]
use recursive_mutex to protect State
Summary:
maelstrom destructs a Promise during an indirect call from
maybeCallback and deadlocks on itself unless we use a recursive mutex.
There may be a smarter way to proceed but at the moment I can't build
and deploy a package from trunk because the service is non-functional
:-/
Test Plan:
run
```
fbconfig -r folly/wangle messaging/maelstrom
fbmake runtests
```
Reviewed By: hannesr@fb.com
Subscribers: fugalh, fsilva
FB internal diff:
D1428504
Tudor Bosman [Wed, 9 Jul 2014 15:42:15 +0000 (08:42 -0700)]
Remove unnecessary and broken hash specializations
Summary:
No need to specialize std::hash for std::basic_string; the STL already does
this. Plus, the specializations were broken in multiple ways:
1. std::hash does not treat const char* specially, so it just hashes the
pointer value (contrasting the old __gnu_cxx::hash, which hashed a C-string)
2. Either way, using __gnu_cxx::hash<const char*> for std::string is broken,
as it won't hash anything past the first null byte.
Also, make sure fbstring gets the same (full) specializations as std::string
does in the standard.
Test Plan: fbconfig -r folly && fbmake runtests_opt, also tests in tupperware/agent which is still using __gnu_cxx::hash_map with string keys.
Reviewed By: pgriess@fb.com, andrei.alexandrescu@fb.com
Subscribers: njormrod, jhj, kma, lesha
FB internal diff:
D1426479
Gunjan Sharma [Wed, 9 Jul 2014 17:56:05 +0000 (10:56 -0700)]
Fix race in Notification Queue
Summary: When we are changing value of numActiveConsumers_ with setActive from handlerReady at the SCOPE_EXIT we have a race with reading of the same variable in putMessageImpl.
Test Plan: Had a local race which works fine now.
Reviewed By: davejwatson@fb.com
Subscribers: trunkagent
FB internal diff:
D1424674
Tudor Bosman [Tue, 8 Jul 2014 00:29:32 +0000 (17:29 -0700)]
Simplify pipe2 / O_CLOEXEC handling in Subprocess.cpp
Summary: per @rockyliu's suggestions
Test Plan: subprocess_test
Reviewed By: rockyliu4@fb.com
Subscribers: rockyliu, jhj, lesha, kma
FB internal diff:
D1423157
Paul Tarjan [Wed, 9 Jul 2014 14:07:38 +0000 (07:07 -0700)]
Revert "make `folly::Formatter` extendible"
Summary:
This reverts commit
5ea0eb0c705224b82a5c284dc5f7722e1f71199f.
This breaks the HHVM clang build test.
Test Plan: clang will pass now
Reviewed By: smith@fb.com
Subscribers: dmitrys
FB internal diff:
D1426399
Tasks:
4667712
Tyler MacDonald [Wed, 9 Jul 2014 00:27:36 +0000 (17:27 -0700)]
make `folly::Formatter` extendible
Summary:
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.
I wasn't able to get the recursive formatter to be polymorphic -- whenever I tried to convert `class FormatValue<Formatter<containerMode, Args...>, void>` into `class FormatValue<BaseFormatter...`, `FormatTest.cpp:Test(Format, Nested)` wouldn't compile because it couldn't find the template. @tudorb, if you have an easy fix for this, lmk, otherwise I'm (reluctantly) okay with requiring that `Formatter`s define their own nesting `FormatValue`.
phew. the last time I did this sort of metaprogramming was over 5 years ago in perl. Doing it in C++ is... interesting.
Test Plan: `fbconfig -r thrift folly cold_storage && fbmake dbg && fbmake runtests`
Reviewed By: tudorb@fb.com
Subscribers: tudorb, dgp
FB internal diff:
D1422343
Tasks:
4624268
Tudor Bosman [Sat, 5 Jul 2014 15:50:38 +0000 (08:50 -0700)]
Fix libc++ build errors
Summary:
Reported externally:
https://github.com/facebook/folly/issues/70
https://github.com/facebook/folly/issues/71
https://github.com/facebook/folly/issues/72
https://github.com/facebook/folly/issues/73
Note that I can't test on libc++ myself, but the reports suggested fixes which
sounded good.
Test Plan: fbconfig -r folly && fbmake runtests_opt
Reviewed By: marcelo.juchem@fb.com
Subscribers: jhj, ntv, lesha, kma, fugalh, jdelong
FB internal diff:
D1421029
Tudor Bosman [Mon, 7 Jul 2014 20:08:28 +0000 (13:08 -0700)]
Use pipe2 in Subprocess; platform-specific config
Summary:
We've wanted to use pipe2 in Subprocess for a while, but that's not supported
on glibc 2.5.1. This is not a problem in OSS (autoconf can solve this),
but, internally, we don't run autoconf; add an internal platform include file
with such per-platform differences.
Test Plan: fbconfig -r folly && fbmake runtests_opt
Reviewed By: meyering@fb.com
Subscribers: jhj, lesha, kma, agallagher
FB internal diff:
D1422128
Tom Jackson [Thu, 3 Jul 2014 22:28:27 +0000 (15:28 -0700)]
stride()
Summary: thatwaseasy
Test Plan: iloveunittests
Reviewed By: lucian@fb.com
Subscribers: philipp
FB internal diff:
D1419848
Tasks:
4636617
Brian Pane [Mon, 7 Jul 2014 17:27:30 +0000 (10:27 -0700)]
Move the branchless, parallel ASCII toLower into folly
Summary:
* Moved the fast toLower code into folly
* Updated the name to emphasize that it's ASCII-only
Test Plan: * Unit tests and benchmarks included.
Reviewed By: tudorb@fb.com
Subscribers: ruibalp, bmatheny
FB internal diff:
D1421056
Hans Fugal [Mon, 7 Jul 2014 16:01:47 +0000 (09:01 -0700)]
(wangle) fix shadow
Summary: Not sure why this shadow error didn't turn up in my tests, but whatevs
Test Plan: traffic manager builds without warning-errors
Reviewed By: suhas@fb.com
Subscribers: hannesr, net-systems@, fugalh, exa
FB internal diff:
D1421495
Tasks:
4653938
Tudor Bosman [Mon, 7 Jul 2014 15:59:17 +0000 (08:59 -0700)]
fix Makefile.am
Summary: wangle/detail.h -> wangle/detail/State.h
Test Plan: OSS build
Reviewed By: meyering@fb.com
Subscribers: fugalh, lesha
FB internal diff:
D1421490
Tudor Bosman [Fri, 4 Jul 2014 05:18:06 +0000 (22:18 -0700)]
gflags now likes namespace gflags, not google
Summary:
Use namespace gflags going forward, import namespace google into it if
backward.
Also added a few "checking for..." messages in autoconf.
Test Plan: fbconfig -r folly && fbmake runtests_opt, OSS build
Reviewed By: meyering@fb.com
Subscribers: fjargsto, ntv, jhj, lesha, kma, davejwatson
FB internal diff:
D1420575
Hans Fugal [Tue, 1 Jul 2014 00:29:05 +0000 (17:29 -0700)]
(wangle) cold via
Summary:
Instead of returning a Later, `via` returns a cold future.
This works without keeping a backreference like Later does, because an inactive Future will always activate on destruction. Alternatively we could have an extra Promise, a la Later, and pass that along like Later does, and require launch() at the end (though, implicit launching on destruction would be an option there too).
If you think this approach is viable I'll clean it up on Wednesday: make sure all the calling sites work, etc.
Test Plan:
new unit test
This may fail in contbuild, I haven't done the codemod for calling sites, if there are any.
Reviewed By: hannesr@fb.com
Subscribers: jsedgwick, net-systems@, fugalh, exa
FB internal diff:
D1412499
Tasks:
4480567
Hans Fugal [Mon, 30 Jun 2014 20:38:41 +0000 (13:38 -0700)]
(wangle) Future/Promise detachment
Summary:
Bring a bit more sanity to the lifetime. Now Future and Promise detach by calling the respective methods on State, and they do it during their destruction only. State manages its own lifetime.
Besides being cleaner, this also sets the stage for cancellation (where we'll need Future to hang on to its reference to State after setting the callback), and for folding in Later (we will have a bool for whether the future is hot and hold off executing the callback if it isn't).
Also cleans up various things I noticed while auditing the code for usages of `state_`.
Test Plan:
All the unit tests still pass.
Ran with ASAN (and found I had introduced a bug, then fixed it. yay)
Reviewed By: hannesr@fb.com
Subscribers: jsedgwick, net-systems@, fugalh, exa
FB internal diff:
D1412038
Tasks:
4618297
Hannes Roth [Fri, 4 Jul 2014 15:11:36 +0000 (08:11 -0700)]
(Folly/FBString) Enum class for category
Summary: Suggested by @aalexandre.
Test Plan: Compile.
Reviewed By: andrei.alexandrescu@fb.com
Subscribers: folly@lists, njormrod, aalexandre
FB internal diff:
D1246180
Lucian Grijincu [Thu, 26 Jun 2014 23:26:33 +0000 (16:26 -0700)]
folly: StringPiece: add skipWhitespace
Test Plan: copied from folly::json
Reviewed By: philipp@fb.com, soren@fb.com
FB internal diff:
D1417992
Tasks:
4527315
Hans Fugal [Mon, 30 Jun 2014 20:34:42 +0000 (13:34 -0700)]
s/setCallback_/setCallback/ for detail::State
Summary: This isn't really an internal-to-this-class method. :-/
Test Plan: builds
Reviewed By: hannesr@fb.com
Subscribers: jsedgwick, net-systems@, fugalh, exa
FB internal diff:
D1412008
Hans Fugal [Mon, 30 Jun 2014 20:32:17 +0000 (13:32 -0700)]
(wangle) s/continuation_/callback/ (missed some)
Summary: In the spirit of
D1406753
Test Plan: still builds and tests pass
Reviewed By: hannesr@fb.com
Subscribers: jsedgwick, net-systems@, fugalh, exa
FB internal diff:
D1412002
Hans Fugal [Mon, 30 Jun 2014 20:22:56 +0000 (13:22 -0700)]
(wangle) s/FutureObject/detail::State/
Summary:
codemod
I never was satisfied with this name. `State` feels a little better. More descriptive. But still pretty generic, so I'm open to alternative ideas.
Test Plan: It still builds and tests pass.
Reviewed By: hannesr@fb.com
Subscribers: jsedgwick, net-systems@, fugalh, exa
FB internal diff:
D1411506
Kevin Chou [Wed, 2 Jul 2014 16:14:24 +0000 (09:14 -0700)]
Fix string split when last part is shorter than delimiter
Summary: The bug is when ignoreEmpty is true, we use the wrong token size, which will be 0 when last token is shorter than delimiter.
Test Plan:
1. Add unit test
2. fbconfig -r folly && fbmake runtests
Reviewed By: philipp@fb.com
Subscribers: maxime, xiaol
FB internal diff:
D1415803
Tudor Bosman [Wed, 2 Jul 2014 01:03:26 +0000 (18:03 -0700)]
Add Random-inl.h to Makefile.am
Test Plan: OSS
Reviewed By: lesha@fb.com
FB internal diff:
D1415190
@override-unit-failures
Dave Watson [Fri, 27 Jun 2014 17:46:15 +0000 (10:46 -0700)]
update make check targets
Summary:
Update targets so that gtest isn't required unless you run 'make check'.
Simply make everything that uses gtest a 'check_PROGRAM' instead of a 'noinst_PROGRAM'
Test Plan: build folly with 'make -j32', gtest isn't required.
Reviewed By: andrewjcg@fb.com
Subscribers: pavlo, doug
FB internal diff:
D1408288