folly.git
10 years agoEventBase::runAfterDelay to throw an exception
Haim Grosman [Wed, 4 Feb 2015 17:15:10 +0000 (09:15 -0800)]
EventBase::runAfterDelay to throw an exception

Summary:
EventBase::runAfterDelay to throw an exception in case it fails to
schedule a proper execution of the given callback
(instead of silently returning false)

it appears to be the right thing to do, since:
@davejwatson: Digging through the layers of code, it appears this can only fail if
epoll_ctl() with EPOLL_CTL_ADD fails. Ignoring libevent bugs, it looks
like the only relevant errors could be ENOMEM or ENOSPC. So
nonrecoverable

Test Plan: Unit tests

Reviewed By: anca@fb.com

Subscribers: yzhan, haijunz, simpkins, net-systems@, varunk, zeus-diffs@, nli, dfechete, fugalh, atlas2-eng@, alandau, bmatheny, everstore-dev@, zhuohuang, wormhole-diffs@, anca, mwa, jgehring, oujin, alikhtarov, fuegen, mshneer, wch, bil, sanketh, zippydb, maxwellsayles, jsedgwick, trunkagent, fbcode-common-diffs@, chaoyc, search-fbcode-diffs@, andrewcox, unicorn-diffs@, tw-eng@, xie, kennyyu, yfeldblum, folly-diffs@, davejwatson

FB internal diff: D1805125

Signature: t1:1805125:1424927912:8bebb4c3b9f1fa189c0ce97b12cdb8f95dba97ae

10 years agoUpdating Folly Formatting's use of separators for Decimal Integers 'd' and Numbers 'n'
John Ehrhardt [Thu, 26 Feb 2015 04:52:21 +0000 (20:52 -0800)]
Updating Folly Formatting's use of separators for Decimal Integers 'd' and Numbers 'n'

Summary:
Updating Folly Formatting's use of separators for Decimal Integers 'd' and Numbers 'n'.
Updated Decimal Integers 'd' use of separators to directly use commas ',' and grouping of 3 digits.
Updated Numbers use of separators and grouping to follow locale settings.

Test Plan:
Wrote unit tests to validate the insertion of thousandsSeparators works.
Note that the numbers unit test does not modify the locale since the test cases are not thread safe.

Reviewed By: lesha@fb.com

Subscribers: tudorb, trunkagent, folly-diffs@, yfeldblum, aric

FB internal diff: D1821156

Tasks: 6087521

Signature: t1:1821156:1424923837:d0fb383a07fd733375b72b1905e6112afa141265

10 years agoReduce AsyncSocket code size
Sean Cannella [Wed, 25 Feb 2015 18:34:25 +0000 (10:34 -0800)]
Reduce AsyncSocket code size

Summary:
Manual inspection of AsyncSocket.o shows the constructors are generating ugly
(and large) code. Call the smaller constructors instead of duplicating the code. This
reduces the debug .o size from ~1.9MB to ~1.6MB.

Test Plan: existing tests

Reviewed By: benyluo@fb.com

Subscribers: mzlee, folly-diffs@, yfeldblum, mathieubaudet, subodh, pgriess, benyluo

FB internal diff: D1870896

Signature: t1:1870896:1424885638:d37fc79c0f88d04109c8bb73e632dc506b9f773b

10 years agoFuture::ensure
Hans Fugal [Wed, 25 Feb 2015 17:54:53 +0000 (09:54 -0800)]
Future::ensure

Summary: Unconditionally execute the action, passthrough semantics.

Test Plan: new unit test

Reviewed By: bmatheny@fb.com

Subscribers: trunkagent, exa, folly-diffs@, yfeldblum, jsedgwick

FB internal diff: D1868837

Tasks: 6166860

Signature: t1:1868837:1424820181:0e83f54b59d7091dac60ab65feb387992e8ae89c

10 years agofolly/FileUtil.h: fix compiler warning signed/unsigned comparison
Sven Over [Wed, 25 Feb 2015 14:54:21 +0000 (06:54 -0800)]
folly/FileUtil.h: fix compiler warning signed/unsigned comparison

Summary:
writeFull() returns ssize_t and without proper casting, comparing
it with data.size() triggers a compiler warning (which is
treated as an error) in the gcc-4.9-glibc-2.20 toolchain.

Test Plan: fbmake runtests

Reviewed By: mhx@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1870710

Signature: t1:1870710:1424874592:f51026c35196d763ad4b192d43c8ccee0255b41d

10 years agoImprovement fbvector.computePushBackCapacity
Nicholas Ormrod [Wed, 25 Feb 2015 00:51:24 +0000 (16:51 -0800)]
Improvement fbvector.computePushBackCapacity

Summary:
See the github pull request at https://github.com/facebook/folly/issues/135

Important optimizations: remove one of the branches and change ##empty()## to ##capacity()==0##

Test Plan:
Ran extended fbvector test suite (re-enabled in experimental/njormrod)

Also

fbconfig -r folly && fbmake runtests

Reviewed By: markisaa@fb.com

Subscribers: trunkagent, sdwilsh, njormrod, folly-diffs@, yfeldblum

FB internal diff: D1869112

Tasks: 6338531

Signature: t1:1869112:1424823901:d2d7331aef82edad1e8c159005cc1c7185550d0c

10 years agoRemoving call to google::setThreadName from FunctionScheduler
Andrei Alexandrescu [Tue, 24 Feb 2015 21:09:36 +0000 (13:09 -0800)]
Removing call to google::setThreadName from FunctionScheduler

Summary: Funnily, google::setThreadName is Facebook specific: it's introduced only in the FB build of glog. This diff removes the call because folly should not depend on FB's glog.

Test Plan: made sure the line was deleted

Reviewed By: ldbrandy@fb.com

Subscribers: net-systems@, folly-diffs@, yfeldblum

FB internal diff: D1868249

Tasks: 6345935

Signature: t1:1868249:1424812595:2a084754d614ab9b7b6168454f33638882e3f6db

10 years agoEmulatedFutexAtomic doesn't copy or move
Praveen Kumar [Wed, 11 Feb 2015 14:29:30 +0000 (19:59 +0530)]
EmulatedFutexAtomic doesn't copy or move

Summary:
EmulatedFutexAtomic concisely says here that it doesn't copy construct,
move construct, copy assign, or move assign.

Closes #130

Test Plan:
Inspection and all unit tests.

```
Summary (total time 66.97s):
PASS: 2029
FAIL: 0
SKIP: 0
FATAL: 0
TIMEOUT: 0
```

Reviewed By: ngbronson@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1868033

Signature: t1:1868033:1424808823:d9dd618981b29b5949c00190d69d670d96e60e07

10 years agoadd preprocessor to hide unused functions
Beny Luo [Mon, 23 Feb 2015 15:12:29 +0000 (07:12 -0800)]
add preprocessor to hide unused functions

Summary:
encodeVarintToIOBuf and decodeVarintFromCursor are not used when
FOLLY_HAVE_LIBLZMA and FOLLY_HAVE_LIBLZ4 are false, which will trigger
-Werror,-Wunused-function on compile on mobile.

Test Plan: unit test

Reviewed By: seanc@fb.com

Subscribers: meisner, trunkagent, seanc, folly-diffs@, yfeldblum

FB internal diff: D1864016

Signature: t1:1864016:1424702813:75535ea92ac16385ce5c272d93bba507ccbb67a1

10 years agoFix folly::Singleton DFATAL
Andrii Grynenko [Sat, 21 Feb 2015 01:22:54 +0000 (17:22 -0800)]
Fix folly::Singleton DFATAL

Summary:
Previously leak-fatal could never happen because we were incorrectly checking singleton state.
Sending this diff to see how many tests will actually fail and potentially fix worst offenders.

Test Plan: unit tests

Reviewed By: stepan@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1838405

Signature: t1:1838405:1424478983:94cda86ed57f38b0cf626b74804fbc168d182c66

10 years agoOptimize perf of EventBase with new option.
Andre Pinto [Fri, 20 Feb 2015 22:51:39 +0000 (14:51 -0800)]
Optimize perf of EventBase with new option.

Summary:
Add option to disable time measurement in EventBase::loopBody()
to improve performances when time measurement is not used.

Test Plan:
Unit tests, benchmarking and manual tests.

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1846020

Tasks: 6086197

Signature: t1:1846020:1424459703:9686a84027e1137ee43eb0458b0baa4fee3a8abf

10 years agoAdd AutoTimer to folly
Andrey Goder [Fri, 20 Feb 2015 21:48:36 +0000 (13:48 -0800)]
Add AutoTimer to folly

Summary:
This 'moves' bistro::AutoTimer into folly. I actually changed it a bit, so I'm
not migrating any existing uses in this diff, but I can do that as a followup.
We're using it in various places now, so it doesn't make sense to have it in
bistro.

Basically this class lets you conveniently time a series of things while
printing log messages, e.g.:
{
AutoTimer t("Done");
processA();
t.log("processA() complete");
}

would print
"processA() complete in XXX seconds"
"Done in YYY seconds"

I changed some things from bistro::AutoTimer:
- Use std::chrono::time_point<Clock> to store the start time.
- I removed the gflags. It seems weird to rely on those to control the timer,
since they would affect all uses of this. If a specific user of the timer
wants to actually control timing at runtime, I think it's better to use a
custom logger.
- I removed the 'min log duration'. As implemented it actually made the
constructor conflict: AutoTimer("foo", 1.2) is ambiguous. Also, it should
probably be set on the logger, so this likewise feels like a place where you
could make a custom logger.

I'm not sure that the way I use the default logger as a template argument is
best, so please suggest improvements to that.

Test Plan: unit test

Reviewed By: lesha@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1860794

Signature: t1:1860794:1424458219:a2dd0d428aedf063a888b2937b1443c7142554e8

10 years ago(folly/futures) Fix get() bug
Hans Fugal [Fri, 20 Feb 2015 21:15:15 +0000 (13:15 -0800)]
(folly/futures) Fix get() bug

Summary: I thought this was a race, but I think now it was something to do with using a value that had been moved out or something. Anyway, this refactor is cleaner and consolidates a few methods so it's all kinds of fuzzy feelings.

Test Plan: unit tests

Reviewed By: hannesr@fb.com

Subscribers: exa, folly-diffs@, yfeldblum, jsedgwick

FB internal diff: D1861376

Tasks: 6298004

Signature: t1:1861376:1424465861:736353ab3174656fec9e036e0ebd964970da38d0

10 years agorevert D1471958. ParseError is not intended to be caught
Ranjeeth Dasineni [Wed, 18 Feb 2015 09:24:34 +0000 (01:24 -0800)]
revert D1471958. ParseError is not intended to be caught

Summary:
a couple of files were catching this exception and included the .cpp file :O. So we moved
to .h before realizing this was not intended to be caught. reverting the move to .h. codemod will follow.

Test Plan: fbmake -r folly && fbmake && fbmake runtests

Reviewed By: delong.j@fb.com

Subscribers: trunkagent, doug, seanc, folly-diffs@, yfeldblum

FB internal diff: D1854301

Tasks: 6245781

Signature: t1:1854301:1424375745:7e226196315fac99835752896cc5e549e91df2da

10 years ago(futures) Make executors sticky
Hans Fugal [Fri, 20 Feb 2015 17:03:14 +0000 (09:03 -0800)]
(futures) Make executors sticky

Summary:
Instead of returning a deactivated future, have `via` just set the executor. Propagate the executor from `then`. This fixes the `via().get()` problem, and has semantics similar to before for `via().then().then()`.

However, the semantics are now slightly different - each `then` goes back through the executor. This adds some overhead and tweaks the semantics (e.g. if the executor is a threadpool it might execute subsequent `then`s in another thread). However, with `futures::chain` recently introduced, and any other convenience methods that you can dream up and make a case for, we can reasonably get the old once-through-the-executor behavior when performance or other concerns demand it. e.g. `via().then(futures::chain(a, b, c))`.

Test Plan: unit tests

Reviewed By: hannesr@fb.com

Subscribers: zeus-diffs@, mmandal, steveo, rituraj, trunkagent, exa, folly-diffs@, yfeldblum, jsedgwick, davejwatson

FB internal diff: D1839691

Tasks: 6048744

Signature: t1:1839691:1424397180:ca0b0ea7b3867769ab8abd254a510059df67011e

10 years agoRevert: (Wangle) Clean up move constructors
Hannes Roth [Thu, 19 Feb 2015 23:10:49 +0000 (15:10 -0800)]
Revert: (Wangle) Clean up move constructors

Summary:
This reverts commit 1e407b48d379a41f32e7a980285dbdf4dadb2e33.

Test Plan: revert-hammer

Reviewed By: yitingli@fb.com

Subscribers: folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1858994

Signature: t1:1858994:1424386588:5c4608ecbe1f9ab1108ac12e506b157b54d0078b

10 years ago(Wangle) Clean up move constructors
Hannes Roth [Thu, 19 Feb 2015 21:10:26 +0000 (13:10 -0800)]
(Wangle) Clean up move constructors

Summary:
These were doing more assignments than necessary.
1) We don't need to set `core_` to `nullptr` and then immediately
overwrite it with `other.core_`.
2) Don't need to swap the booleans (this was actually an unitialized
memory access).

Test Plan: Ran all the tests.

Reviewed By: hans@fb.com

Subscribers: trunkagent, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1852386

Signature: t1:1852386:1424375154:25997209e76ccd16169125597e868932a5143ffb

10 years agoRemove @/folly dependency from folly/io:compression
Michael Lee [Thu, 19 Feb 2015 18:44:16 +0000 (10:44 -0800)]
Remove @/folly dependency from folly/io:compression

Summary: This diff should let us include folly/io:compression into iOS and Android projects without pulling in a lot of dependencies and should allow the use of zlib.

Test Plan: fbconfig -r folly/io/tests && fbmake runtests

Reviewed By: seanc@fb.com

Subscribers: trunkagent, bmatheny, folly-diffs@, yfeldblum, seanc, benyluo

FB internal diff: D1853058

Tasks: 6245912

Signature: t1:1853058:1424370881:2ea243d93e6041502e5e356fa430c2483f652b40

10 years agouse ServerBootstrap
Dave Watson [Thu, 19 Feb 2015 18:06:27 +0000 (10:06 -0800)]
use ServerBootstrap

Summary:
Use server bootstrap.

* code reuse
* Allows multiple accept threads easily.

Accept now doesn't happen in the server's eventBase, but a new thread.

I think I hit all the corner cases involving existingSocket, duplex, stopListening(), etc.

There are a lot of minor changes here to support all the cases, let me know if I should split anything to separate diffs

Test Plan: fbconfig -r thrift/lib/cpp2; fbmake runtests

Reviewed By: hans@fb.com

Subscribers: haijunz, yfeldblum, ruibalp, fbcode-common-diffs@, davejwatson, jsedgwick, trunkagent, doug, alandau, bmatheny, mshneer, folly-diffs@, mcduff, andrewcox, fugalh

FB internal diff: D1732895

Tasks: 5788102

Signature: t1:1732895:1423087631:379bbb131c35ce2221801bc7cec226f87ba0b1d9

10 years agosome moar unittests
Dave Watson [Wed, 18 Feb 2015 17:28:09 +0000 (09:28 -0800)]
some moar unittests

Summary: from discussion

Test Plan: unit tests

Reviewed By: hans@fb.com

Subscribers: doug, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1829282

Signature: t1:1829282:1423180907:3630dac1378750b05f316c672fbbd71138d2bc0a

10 years agoUse folly's async udp socket
Dave Watson [Wed, 18 Feb 2015 16:12:06 +0000 (08:12 -0800)]
Use folly's async udp socket

Summary: They are functionaly equivalent, no need to have more than one

Test Plan: fbconfig -r realtime/voip; fbmake runtests

Reviewed By: naizhi@fb.com

Subscribers: trunkagent, doug, ps, bmatheny, folly-diffs@, yfeldblum

FB internal diff: D1828044

Tasks: 6154007

Signature: t1:1828044:1423165354:f71d2fd28ca76a8f67a597c747f8578d2909823c

10 years agoKill get_fast/get_weak_fast Singletonn API
Andrii Grynenko [Wed, 18 Feb 2015 01:03:58 +0000 (17:03 -0800)]
Kill get_fast/get_weak_fast Singletonn API

Summary: After D1827390 regular get and get_weak is comparable to Meyers and static singletons, so there's no need to keey _fast APIs.

Test Plan: benchmark && fbmake

Reviewed By: mshneer@fb.com

Subscribers: trunkagent, configerator-diffs@, fbcode-common-diffs@, mcduff, hitesh, mshneer, fugalh, acampi, alikhtarov, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1843219

Signature: t1:1843219:1424216566:f2f182a1c86bb5f0fb1f978d8c6b7a4388198f5f

10 years agoMigrate FunctionScheduler from common/concurrency/ to folly/experimental/
Andrei Alexandrescu [Thu, 12 Feb 2015 21:17:31 +0000 (13:17 -0800)]
Migrate FunctionScheduler from common/concurrency/ to folly/experimental/

Summary: This are the open-source-related additions. A separate diff will replace the current implementation in common/concurrency/ to use this one.

Test Plan: fbmake runtests

Reviewed By: simpkins@fb.com

Subscribers: trunkagent, net-systems@, folly-diffs@, yfeldblum

FB internal diff: D1845525

Signature: t1:1845525:1424207291:d30e3c5e85222527c2aff39c1250aa1e41b9a2cf

10 years agoReformat comment for readability, 80-col rule, and gcc cleanliness
Sara Golemon [Tue, 17 Feb 2015 19:45:21 +0000 (11:45 -0800)]
Reformat comment for readability, 80-col rule, and gcc cleanliness

Summary:
The continuation at the end of the line with the while
was causing gcc to complain about it because it's a
single line comment.

Reformat it into a multiline comment and wrap it to 80 chars.

Test Plan: It's just a comment...

Reviewed By: paulbiss@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1850876

Signature: t1:1850876:1424124973:b2afbc2a8177ac6d11a21bf5a52093bcfd9cbb3e

10 years ago(Wangle) Shrink Core to 128 bytes
Hannes Roth [Tue, 17 Feb 2015 19:15:36 +0000 (11:15 -0800)]
(Wangle) Shrink Core to 128 bytes

Summary: I think this makes sense, especially if `interrupt_` is really rare.

Test Plan:
============================================================================
folly/futures/test/Benchmark.cpp                relative  time/iter  iters/s
============================================================================
constantFuture                                             101.25ns    9.88M
promiseAndFuture                                  92.86%   109.03ns    9.17M
withThen                                          28.96%   349.65ns    2.86M
----------------------------------------------------------------------------
oneThen                                                    337.33ns    2.96M
twoThens                                          58.46%   577.06ns    1.73M
fourThens                                         32.42%     1.04us  961.23K
hundredThens                                       1.45%    23.24us   43.04K
----------------------------------------------------------------------------
no_contention                                                4.45ms   224.48
contention                                        72.89%     6.11ms   163.61
----------------------------------------------------------------------------
throwAndCatch                                                6.34us  157.77K
throwAndCatchWrapped                              95.65%     6.63us  150.91K
throwWrappedAndCatch                             142.58%     4.45us  224.95K
throwWrappedAndCatchWrapped                      488.86%     1.30us  771.27K
----------------------------------------------------------------------------
throwAndCatchContended                                        1.01s  987.01m
throwAndCatchWrappedContended                    100.03%      1.01s  987.27m
throwWrappedAndCatchContended                    148.37%   682.86ms     1.46
throwWrappedAndCatchWrappedContended            18765.19%     5.40ms   185.21
============================================================================

Compare to D1843129#31 (seems to be an improvement?)

Reviewed By: hans@fb.com

Subscribers: trunkagent, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1847843

Signature: t1:1847843:1423855151:3602d49df245eda3f85325ab5efd63514213ca44

10 years agoExceptionWrapperTest.cpp vs clang's new warning about side effects in typeid argument...
Jim Meyering [Sat, 14 Feb 2015 01:20:06 +0000 (17:20 -0800)]
ExceptionWrapperTest.cpp vs clang's new warning about side effects in typeid argument list

Summary:
Disable the -Wunevaluated-expression warning for this test:

EXPECT_EQ(typeid(ie), typeid(IntException));

Otherwise, clang warns about the unevaluated expression because
the expansion of EXPECT_EQ applies sizeof to an expression
with side effects:

folly/test/ExceptionWrapperTest.cpp:179:122: error: expression with side effects has no effect in an unevaluated context [-Werror,-Wunevaluated-expression]
switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing::internal::IsNullLiteralHelper(typeid(ie))) == 1)>::Compare("typeid(ie)", "typeid(IntException)", typeid(ie), typeid(IntException)))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "folly/test/ExceptionWrapperTest.cpp", 179, gtest_ar.failure_message()) = ::testing::Message();

Test Plan:
Ensure this compiles with clang-3.4, 3.5 and clang:dev.
I.e., ensure that this prints PASS at the end.

for i in '' 3.5 dev; do
test -n "$i" && i=--with-project-version=clang:$i
fbconfig -r --clang $i folly/test:exception_wrapper_test && fbmake dbgo
done && echo PASS

Reviewed By: mpawlowski@fb.com

Subscribers: mathieubaudet, folly-diffs@, yfeldblum

FB internal diff: D1850778

Tasks: 6244745

Signature: t1:1850778:1424111029:136478e9a3cc3a219047547d501de4c579a1a181

10 years agowangle: make new pragma use portable to older clang
Jim Meyering [Sat, 14 Feb 2015 00:37:37 +0000 (16:37 -0800)]
wangle: make new pragma use portable to older clang

Summary:
* folly/wangle/channel/test/MockChannelHandler.h:
Avoiding a new warning that rendered this file uncompilable
by clang-3.5 and older.  Add cpp conditionals to protect
against that.

Test Plan:
Ensure it works with clang-3.4, 3.5 and clang:dev.
I.e., ensure that this prints PASS at the end.

for i in '' 3.5 dev; do
test -n "$i" && i=--with-project-version=clang:$i
fbconfig -r --clang $i folly/wangle/channel/test && fbmake runtests_dbgo
done && echo PASS

Reviewed By: meyering@fb.com

Subscribers: mpawlowski, fugalh, mathieubaudet, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1849474

Tasks: 6244745

Blame Revision: D1848330
@build-break

10 years agofolly: OptionalTest.cpp: suppress a -Wself-move warning
Jim Meyering [Fri, 13 Feb 2015 22:37:55 +0000 (14:37 -0800)]
folly: OptionalTest.cpp: suppress a -Wself-move warning

Summary:
Clang's new -Wself-move warning dings this code:

b = std::move(b);

But in this case, that is a deliberate test of
this capability, so we suppress that particular
warning for the duration of this small test function.

Test Plan:
Run this and note that it now compiles: (it passes the tests, too)
fbconfig --clang --with-project-version=clang:dev -r folly/test:optional_test && fbmake dbgo

Reviewed By: watashi@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1849689

Tasks: 6244745

Signature: t1:1849689:1423877932:4f479d682bd8ba97dcabed7fc29ce0a22c013969

@build-break (using this to work around bogus push failure: https://phabricator.fb.com/P19730606)

10 years agofolly/ExceptionWrapper.h: avoid warning about typeid operand side effects
Jim Meyering [Fri, 13 Feb 2015 17:23:08 +0000 (09:23 -0800)]
folly/ExceptionWrapper.h: avoid warning about typeid operand side effects

Summary:
* folly/ExceptionWrapper.h (class_name): Clang is not yet smart enough to
see that there is no harm in dereferencing an "item_" that we've just
verified is non-NULL.  Accommodate it, to avoid this:
./folly/ExceptionWrapper.h:199:30: error: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Werror,-Wpotentially-evaluated-expression]
return demangle(typeid(*item_));
^

Test Plan:
Run these commands and note there are fewer errors than before:
fbconfig --clang --with-project-version=clang:dev -r folly && fbmake dbgo

Reviewed By: mhorowitz@fb.com

Subscribers: trunkagent, yfeldblum, folly-diffs@

FB internal diff: D1848327

Tasks: 6244745

Signature: t1:1848327:1423869597:a58c9e9e3671befb78ae07fbd274a13d08ffb2a7

Blame Revision:

10 years agoclang:dev rejects vector<atomic<T>> in EventBaseTest.cpp.
Yedidya Feldblum [Fri, 13 Feb 2015 22:35:04 +0000 (14:35 -0800)]
clang:dev rejects vector<atomic<T>> in EventBaseTest.cpp.

Summary: [Folly] clang:dev rejects vector<atomic<T>> in EventBaseTest.cpp.

Test Plan: Build and run `folly/io/async/test/EventBaseTest.cpp` using the current `clang`; try building with `clang:dev` and verifying that at least the related failures are gone.

Reviewed By: meyering@fb.com

Subscribers: mathieubaudet, folly-diffs@, yfeldblum, dougw, brettp

FB internal diff: D1848749

Tasks: 6244720

Signature: t1:1848749:1423866420:7b7354d4568b6a6d6a824236ae8d271f6855d90b

10 years agofolly: move side effects out of EXPECT_EQ args
Jim Meyering [Fri, 13 Feb 2015 19:06:37 +0000 (11:06 -0800)]
folly: move side effects out of EXPECT_EQ args

Summary:
This avoids warnings about e.g., sizeof(k++) that result
from macro expansion.
* folly/futures/test/ExecutorTest.cpp: Move increment out
of macro argument list.
* folly/test/FBVectorTestBenchmarks.cpp.h: Likewise.
* folly/test/LazyTest.cpp: Likewise.
Otherwise, we'd get errors like this:

folly/test/LazyTest.cpp:49:118: error: expression with side effects has no effect in an unevaluated context [-Werror,-Wunevaluated-expression]
switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing::internal::IsNullLiteralHelper(++globalCount())) == 1)>::Compare("++globalCount()", "1", ++globalCount(), 1))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "folly/test/LazyTest.cpp", 49, gtest_ar.failure_message()) = ::testing::Message();
^

Test Plan:
Run these commands and note there are fewer errors than before:
fbconfig --clang --with-project-version=clang:dev -r folly && fbmake dbgo

Reviewed By: njormrod@fb.com

Subscribers: folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1848324

Tasks: 6244745

Signature: t1:1848324:1423860890:bce44c5e0895804a21957893ae6b78e76dfbc4d3

10 years agofolly: avoid new warnings from -Winconsistent-missing-override
Jim Meyering [Fri, 13 Feb 2015 18:36:27 +0000 (10:36 -0800)]
folly: avoid new warnings from -Winconsistent-missing-override

Summary:
Upgrading to clang:dev (clang >3.6) brought in some new warnings.
This change address all of the issues exposed by the new
-Winconsistent-missing-override, usually by simply adding the
missing "override" keyword.  However, in
folly/wangle/channel/test/MockChannelHandler.h, I chose
to ignore those warnings for the mocked functions.
* folly/futures/test/ViaTest.cpp: Add missing "override"(s).
* folly/io/async/AsyncSSLSocket.h: Likewise.
* folly/io/async/AsyncSocket.h: Likewise.
* folly/io/async/EventBase.h: Likewise.
* folly/test/ExceptionWrapperTest.cpp: Likewise.
* folly/wangle/channel/AsyncSocketHandler.h: Likewise.
* folly/wangle/channel/test/MockChannelHandler.h: Ignore
the new warning for these functions.

Test Plan:
Run these commands and note there are fewer errors than before:
fbconfig --clang --with-project-version=clang:dev -r folly && fbmake dbgo

Reviewed By: hans@fb.com

Subscribers: trunkagent, fugalh, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1848330

Tasks: 6244745

Signature: t1:1848330:1423858909:b167ca220d6c9fe036d3adca08cf3053a7a9de16

10 years ago(Wangle) Have Core own an FSM instead of inheriting
Hannes Roth [Fri, 13 Feb 2015 21:14:22 +0000 (13:14 -0800)]
(Wangle) Have Core own an FSM instead of inheriting

Summary:
This seems cleaner. I also moved a Core member around and changed state to be a smaller size to save us 16 bytes. Might be neat to try to get this down to 128?

Fixed compilation with GCC 4.9, too.

Test Plan: Ran all the tests. Will also benchmark.

Reviewed By: hans@fb.com

Subscribers: trunkagent, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1843129

Signature: t1:1843129:1423789502:60e56d1af553994991195fcc350d37d644a556ca

10 years agoBe able to access proxy client IP (including Lua)
Jonathan Frank [Fri, 13 Feb 2015 17:59:56 +0000 (09:59 -0800)]
Be able to access proxy client IP (including Lua)

Summary:
Pass TransportInfo object through connection setup.  This allows us to
pass along additional info from the setup if necessary.

Test Plan:
Run proxygen on my devserver listening on ipv4 and ipv6 for ports 80 and 443.
Configure it to run a lua request rule with the following lines:

io.stderr:write("jonlog: proxy " .. conn:getClientAddrOriginal() .. "\n")
io.stderr:write("jonlog: client " .. request:getClientIPStr() .. "\n")

Run haproxy also on my devserver, listening on ports 8555-8558, with each
forwarding to one of the four pairs (ipv4-localhost/ipv6-localhost, 80/443)

From my laptop, run curls against each of these four endpoints and make
sure that we print out "127.0.0.1" as the proxy IP, and my laptop's IP
as the client IP.

Reviewed By: cgheorghe@fb.com

Subscribers: jsedgwick, yfeldblum, trunkagent, ruibalp, bmatheny, folly-diffs@, dsp, nbm

FB internal diff: D1746590

Tasks: 5688127

Signature: t1:1746590:1423695880:f647964d95636a69a00304e144aef71ee0213d28

10 years agoFix EliasFanoReader position() when past-the-end
Giuseppe Ottaviano [Fri, 13 Feb 2015 01:46:14 +0000 (17:46 -0800)]
Fix EliasFanoReader position() when past-the-end

Summary:
`EliasFanoReader::position()` used to return `size() - 1` both when
the reader is positioned on the last element, and after `next()` is
called after that (and it return `false`). Now in the latter case
`position()` returns `size()` (consistently with the usual behaviour
of past-the-end iterators).

Also fix the return type of `jumpTo`.

Test Plan:
fbconfig folly/experimental/test:eliasfano_test && fbmake runtests_opt

Reviewed By: philipp@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1846275

Signature: t1:1846275:1423790264:151f5d2e1e09d4e24dfb758473dfb9cd52c070bd

10 years agostd::atomicize MicroSpinLock.
Keith Adams [Thu, 12 Feb 2015 23:52:39 +0000 (15:52 -0800)]
std::atomicize MicroSpinLock.

Summary:
A colleague at another company started making fun of
MicroSpinLock for its x86 assembly and ad hoc compiler memory
barriers. Use C++11 (which wasn't really a thing at the time I wrote
this).

Test Plan: folly's runtests. What else would we like?

Reviewed By: andrei.alexandrescu@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1841563

Signature: t1:1841563:1423780458:a447c081fbd72e3420b23e95dcf26575c9a06798

10 years agoElias-Fano micro-optimizations
Giuseppe Ottaviano [Thu, 12 Feb 2015 21:34:47 +0000 (13:34 -0800)]
Elias-Fano micro-optimizations

Summary:
Short skips have been optimized by adding special cases that use simple iteration when it is convenient. Large skips have been optimized by using the broadword selection algorithm by Vigna (improved with ideas by Gog&Petri) instead of iterating on the zeros/ones of the upper bits.

The benchmarks had to be made more granular to measure the differences, in particular they used to test skipping with a fixed skip length for each test, while now we average over a range of skips to better simulate a random distribution.

The improvements are very significant for `skipTo()` on short skips, about 2-3x for skips at distance 1 or 2, which can occur when intersecting dense lists. On large skips the gain is about 17%.

`skip()` exhibits slightly smaller improvements.

before               after
============================================================================  ==================
folly/experimental/test/EliasFanoCodingTest.cpp relative  time/iter  iters/s  time/iter  iters/s
============================================================================  ==================
Next                                                         2.52ns  396.26M     2.52ns  397.28M
Skip_ForwardQ128(1)                                          8.66ns  115.52M     3.92ns  255.28M
Skip_ForwardQ128(2)                                          8.37ns  119.42M     5.08ns  197.04M
Skip_ForwardQ128(4_pm_1)                                     9.67ns  103.41M     7.04ns  142.02M
Skip_ForwardQ128(16_pm_4)                                   21.44ns   46.65M    19.68ns   50.82M
Skip_ForwardQ128(64_pm_16)                                  30.86ns   32.40M    27.58ns   36.26M
Skip_ForwardQ128(256_pm_64)                                 37.80ns   26.45M    32.49ns   30.78M
Skip_ForwardQ128(1024_pm_256)                               38.99ns   25.65M    33.39ns   29.95M
Jump_ForwardQ128                                            37.91ns   26.37M    34.05ns   29.37M
----------------------------------------------------------------------------  ------------------
SkipTo_SkipQ128(1)                                          13.87ns   72.10M     4.42ns  226.49M
SkipTo_SkipQ128(2)                                          18.80ns   53.20M     8.58ns  116.55M
SkipTo_SkipQ128(4_pm_1)                                     23.59ns   42.38M    11.43ns   87.50M
SkipTo_SkipQ128(16_pm_4)                                    36.04ns   27.74M    31.19ns   32.06M
SkipTo_SkipQ128(64_pm_16)                                   53.34ns   18.75M    43.88ns   22.79M
SkipTo_SkipQ128(256_pm_64)                                  62.27ns   16.06M    49.08ns   20.37M
SkipTo_SkipQ128(1024_pm_256)                                65.63ns   15.24M    52.24ns   19.14M
JumpTo_SkipQ128                                             65.89ns   15.18M    54.61ns   18.31M
----------------------------------------------------------------------------  ------------------
Encode_10                                                  111.94ns    8.93M   117.24ns    8.53M
Encode                                                       5.35ms   187.02     5.64ms   177.15
----------------------------------------------------------------------------  ------------------
Select64                                                     8.07ns  123.96M     8.04ns  124.35M
============================================================================  ==================

Test Plan:
fbconfig folly/experimental/test:eliasfano_test && fbmake runtests_opt

Reviewed By: philipp@fb.com

Subscribers: yfeldblum, fbcode-common-diffs@, chaoyc, search-fbcode-diffs@, unicorn-diffs@, trunkagent, folly-diffs@

FB internal diff: D1793554

Signature: t1:1793554:1423619344:1b078c0789639f317342ebcc77b11fe91859cd7b

10 years ago(Wangle) Catch all exceptions in `then() -> Future`
Hannes Roth [Thu, 12 Feb 2015 18:27:33 +0000 (10:27 -0800)]
(Wangle) Catch all exceptions in `then() -> Future`

Summary: Saw this while debugging some stuff. Just an oversight, right?

Test Plan: Ran all the tests.

Reviewed By: hans@fb.com

Subscribers: folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1843016

Signature: t1:1843016:1423704557:d9fdb4b879ab4fcfda54a5fcb16a639df15872b5

10 years agoBump version to 26:0 v0.26.0
Sara Golemon [Thu, 12 Feb 2015 16:55:12 +0000 (08:55 -0800)]
Bump version to 26:0

10 years agoMaking 'just()' reference arguments like 'from()' (fixed)
Tom Jackson [Wed, 11 Feb 2015 23:42:11 +0000 (15:42 -0800)]
Making 'just()' reference arguments like 'from()' (fixed)

Summary: That is, for all inputs except r-values. Now with support for GCC.

Test Plan: Run tests

Reviewed By: ajaymenon@fb.com

Subscribers: moharrami, trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1822339

Signature: t1:1822339:1423683482:027871549d69017a7a23a675025851a0b876ad77

10 years agoRemove unsed header from singleton-inl.h
Sara Golemon [Wed, 11 Feb 2015 23:11:14 +0000 (15:11 -0800)]
Remove unsed header from singleton-inl.h

Summary:
This was recently added by @andrii to provide stack traces,
but it no longer needed since he now produces them from a hook in
folly/experimental/SingletonStackTrace.cpp

Test Plan: Continues to build without the include.

Reviewed By: andrii@fb.com

Subscribers: folly-diffs@, yfeldblum, andrii

FB internal diff: D1842654

Signature: t1:1842654:1423696133:cfa91851f28696082f790eb13c3b0b015c813590

10 years agoRevert "[folly] TLS cache for AccessSpreader"
Nathan Bronson [Wed, 11 Feb 2015 22:23:06 +0000 (14:23 -0800)]
Revert "[folly] TLS cache for AccessSpreader"

Summary:
This reverts commit 4ebb2303bbcf343d7c2bcc95d55557c0a3b444f3.
The caching mechanism was based on a misunderstanding of the
implementation of CLOCK_MONOTONIC_COARSE, and is not correct.
On the plus side, the upstream kernel patch

e76b027e6408 x86,vdso: Use LSL unconditionally for vgetcpu

gets the vdso getcpu from 16 nanos down to 10 (half of which is the
inherent indirect call).

Test Plan: unit tests

Reviewed By: delong.j@fb.com

Subscribers: trunkagent, bmaurer, tudorb, folly-diffs@, yfeldblum, jdelong

FB internal diff: D1840690

Signature: t1:1840690:1423693026:33801341ec0b83bf47e050be6528c5dd05021ed5

10 years agoMake Singleton dependency on Symbolizer Facebook-only
Andrii Grynenko [Wed, 11 Feb 2015 21:41:55 +0000 (13:41 -0800)]
Make Singleton dependency on Symbolizer Facebook-only

Summary: Open-source build was broken because Symbolizer is not part of it.

Test Plan: singleton unit test w/ and w/o SingletonStackTrace.cpp linked in.

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1840346

Signature: t1:1840346:1423690004:926c2aa21e0b7916260749120997ad56fab6f742

10 years agoBump version to 25:0 v0.25.0
Sara Golemon [Wed, 11 Feb 2015 02:02:15 +0000 (18:02 -0800)]
Bump version to 25:0

10 years agoAutodetect pthread_atfork() support
Sara Golemon [Wed, 11 Feb 2015 02:00:05 +0000 (18:00 -0800)]
Autodetect pthread_atfork() support

Summary: This is usually available on linux

Test Plan: Existing tests and manual test on arclinux

Reviewed By: mpawlowski@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1840081

Signature: t1:1840081:1423619986:911c95f9f04f286e9f113543ab4b705cf1b17396

10 years agoremove stray / in include path
Ranjeeth Dasineni [Fri, 6 Feb 2015 06:15:05 +0000 (22:15 -0800)]
remove stray / in include path

Summary: removing // as it could break some comment parser

Test Plan: unitz

Reviewed By: dancol@fb.com

Subscribers: trunkagent, doug, seanc, folly-diffs@, yfeldblum

FB internal diff: D1830591

Signature: t1:1830591:1423203436:9e8b28b714eb2dc080462ab3e8ce04c176df8586

10 years agoswitch order of method/object in Future::then to match std::bind
Hans Fugal [Tue, 10 Feb 2015 20:32:04 +0000 (12:32 -0800)]
switch order of method/object in Future::then to match std::bind

Summary:
I have half a mind to just rip this out and let people use std::bind if they need this. But I won't be so cruel.

Why isn't this just implemented as `then(std::bind(method, object))` anyway? Is the template soup we have now faster?

Test Plan:
Fixed the unit tests to use the new format.
Will look to contbuild to catch all the things this might break (if anyone is using it at all?), and will fix them.

Reviewed By: hannesr@fb.com

Subscribers: trunkagent, exa, folly-diffs@, yfeldblum, jsedgwick, davejwatson

FB internal diff: D1831118

Signature: t1:1831118:1423243771:65db9a89daf14d8bd88331c503ba1ea7ab03b679

10 years agofutures::chain
Hans Fugal [Tue, 10 Feb 2015 20:24:07 +0000 (12:24 -0800)]
futures::chain

Summary:
`futures::chain<A,Z>(a, b, c, d, e, f, ..., z)` where `a` is a callback suitable for `Future<A>::then` and `z` is a callback suitable for `Future<Y>::then<Z>`.

This will be important, at least in the background, for the new `via`. It will probably also be useful to some user sometime.

I imagine this will be tweaked over time if people find magic ways to get it to deduce the types better. But this works and it's not *too* much trouble to specify A and Z.

Test Plan: unit

Reviewed By: davejwatson@fb.com

Subscribers: trunkagent, exa, folly-diffs@, yfeldblum, jsedgwick

FB internal diff: D1831073

Tasks: 6048744

Signature: t1:1831073:1423259292:711be0e047a2acb706fd74e529d5d5fb6abda566

10 years agofolly::Singleton leak diagnostics utils
Andrii Grynenko [Fri, 6 Feb 2015 03:41:31 +0000 (19:41 -0800)]
folly::Singleton leak diagnostics utils

Summary: This adds different types of messages depending on whether Singleton was depending on other Singleton or just leaked. It also adds destruction stack trace for such Singletons (if they were ever destroyed) to help debug such leaks/broken dependencies.

Test Plan: unit test

Reviewed By: chip@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1830526

Signature: t1:1830526:1423266462:ba328b0da0bf4030b1c4f686d8f7b609fd20683c

10 years agoMaking each SingletonEntry a singleton
Andrii Grynenko [Wed, 4 Feb 2015 17:48:12 +0000 (09:48 -0800)]
Making each SingletonEntry a singleton

Summary:
Most of the singleton construction logic is moved to SingletonEntry, and each SingletonEntry is now also a singleton.
SingletonVault becomes only responsible for keeping singleton construction order (and potentially dependencies) and destoying them in correct order.
This also significantly improves perf of get() / get_weak() (not-fast)

This diff is based on D1823663.

Test Plan:
unit test

============================================================================
folly/experimental/test/SingletonTest.cpp       relative  time/iter  iters/s
============================================================================
NormalSingleton                                            333.35ps    3.00G
MeyersSingleton                                   99.99%   333.39ps    3.00G
FollySingletonSlow                                49.99%   666.84ps    1.50G
FollySingletonFast                                95.90%   347.61ps    2.88G
FollySingletonFastWeak                             2.22%    15.00ns   66.66M
============================================================================

Reviewed By: chip@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1827390

Signature: t1:1827390:1423268514:da322d1dcaba54905d478b253f26dd76f890fb4e

10 years agomake decodeVarint accept StringPiece
Philip Pronin [Tue, 10 Feb 2015 01:54:29 +0000 (17:54 -0800)]
make decodeVarint accept StringPiece

Summary: `decodeVarint` now accepts all of `StringPiece`, `MutableStringPiece`, `ByteRange`, and `MutableByteRange`.

Test Plan: fbconfig -r folly unicorn/utils && fbmake runtests_opt -j32

Reviewed By: ott@fb.com, lucian@fb.com

Subscribers: trunkagent, chaoyc, search-fbcode-diffs@, unicorn-diffs@, folly-diffs@, yzhan, yfeldblum

FB internal diff: D1836805

Signature: t1:1836805:1423534085:cca5c3e83ad699e5d56e1d1e3394644ec3f94dab

10 years agotypo
Andre Pinto [Tue, 10 Feb 2015 03:01:47 +0000 (19:01 -0800)]
typo

Summary: Correct typo on docs.

Test Plan: N/A

Reviewed By: alikhtarov@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1836264

Signature: t1:1836264:1423527402:4e5f263f446346f7145c33c671f0b9e694db15fd

10 years agofix open source build
Marcin Pawlowski [Mon, 9 Feb 2015 21:41:02 +0000 (13:41 -0800)]
fix open source build

Summary:
include was missing, causing build to fail on
Arch Linux with gcc 4.9.2 -- found this while resolving
other issues.

Test Plan: build folly on my personal linux and on dev server

Reviewed By: viswanath@fb.com

Subscribers: fugalh, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1835143

Signature: t1:1835143:1423513128:5dcff69a82878f47b40512711ed254f239399c2c

10 years agoRevert "Revert "Using type-tags for test SingletonVaults""
Andrii Grynenko [Fri, 6 Feb 2015 23:48:19 +0000 (15:48 -0800)]
Revert "Revert "Using type-tags for test SingletonVaults""

Summary:
This reverts commit 4893c09795ad4b1187518b184ac4812079039988.

Fix unit test in D1823663.

Test Plan: fbconfig -r folly fbmake dbg

Reviewed By: alikhtarov@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1832645

Signature: t1:1832645:1423267466:6012f1d7700d540c7290c29b01b33148cf91183c

10 years agoTLS cache for AccessSpreader
Nathan Bronson [Fri, 6 Feb 2015 23:16:53 +0000 (15:16 -0800)]
TLS cache for AccessSpreader

Summary:
Under Linux the process gtod doesn't contain the current cpu, so
__vdso_getcpu uses RDTSCP, which makes it cost about 20 nanos.  The gtod
_does_, however, contain a nanosecond time (for CLOCK_REALTIME_COARSE)
updated during context switches.  This diff adds a TLS cache that uses
__vdso_clock_gettime_ns(CLOCK_REALTIME_COARSE) to detect context switches.
The end result is that AccessSpreader goes from ~20 nanos to ~6.

Test Plan: unit tests

Reviewed By: davejwatson@fb.com

Subscribers: yfeldblum, trunkagent, folly-diffs@

FB internal diff: D1798922

Signature: t1:1798922:1423264298:32312a5e9bddb3b8aa630c146ef708164a6a4651

10 years agoRevert "Using type-tags for test SingletonVaults"
Nicholas Ormrod [Fri, 6 Feb 2015 21:34:15 +0000 (13:34 -0800)]
Revert "Using type-tags for test SingletonVaults"

Summary: This reverts commit 315cfed207895455ecd359d0c1b9d98f28ed0519.

Test Plan:
fbconfig -r folly && fbmake dbg

Reviewed By: robbert@fb.com

Subscribers: sdwilsh, folly-diffs@, yfeldblum

FB internal diff: D1831932

Signature: t1:1831932:1423258329:0962b939a93bbf1722a9e1c90090dcc024b63765

Blame Revision: D1823663

10 years agoDedupe the implementations of EventBase::runInEventBaseThreadAndWait.
Yedidya Feldblum [Fri, 6 Feb 2015 19:37:36 +0000 (11:37 -0800)]
Dedupe the implementations of EventBase::runInEventBaseThreadAndWait.

Summary: [Folly] Dedupe the implementations of EventBase::runInEventBaseThreadAndWait.

Test Plan:
Unit tests:
* `folly/io/async/test/EventBaseTest.cpp`

Reviewed By: subodh@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum, dougw, brettp

FB internal diff: D1826291

Signature: t1:1826291:1423225534:42264d8dcc8adec6b90ac8a3d6ce1f4b98f29297

Blame Revision: D1810764D1823407

10 years agoUsing type-tags for test SingletonVaults
Andrii Grynenko [Wed, 4 Feb 2015 00:48:31 +0000 (16:48 -0800)]
Using type-tags for test SingletonVaults

Summary: This makes test SingletonVaults more similar to global SingletonVault. It also ensures that every SingletonVault is a singleton, which allows potential optimization of making each SingletonEntry a Singleton too, which itself will make get/get_weak as efficient as get_fast/get_weak_fast.

Test Plan: unit test

Reviewed By: chip@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1823663

Signature: t1:1823663:1423188884:4ab2b47cfba270a66613f6f2458b6affc0ed96ad

10 years agomake wait() and friends return reference to self instead of new Future
Hans Fugal [Fri, 6 Feb 2015 00:20:51 +0000 (16:20 -0800)]
make wait() and friends return reference to self instead of new Future

Summary:
we still make the new Future, but assign it to ourselves. this avoids the following buggy pattern that people might expect to work

```
auto f = ...
f.wait();

// Careful. f.value() was moved out into the new Future, so you may have lost something
someOperationOn(f.value());

// Nope. We already set a callback internally in wait()
f.then(...);
```

Test Plan: unit

Reviewed By: davejwatson@fb.com

Subscribers: exa, yfeldblum, trunkagent, fbcode-common-diffs@, sammerat, cold-storage-diffs@, folly-diffs@, jsedgwick, aflock

FB internal diff: D1809040

Tasks: 6048284

Signature: t1:1809040:1422900812:1b416408eb5eaa71e88778c9c22ed8bfba087efe

10 years agoAdd StringKeyed(Unordered){Set,Map} to folly
Andrei Alexandrescu [Wed, 4 Feb 2015 21:09:20 +0000 (13:09 -0800)]
Add StringKeyed(Unordered){Set,Map} to folly

Summary: We're using StringKeyed* from common/datastruct to avoid unnecessary string creation whenever we're looking up string keys. C++14 does offer a solution, see e.g. http://stackoverflow.com/questions/10536788/avoiding-key-construction-for-stdmapfind. That is not supported by current compilers.

Test Plan: unittests

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, net-systems@, folly-diffs@, yfeldblum

FB internal diff: D1825700

Signature: t1:1825700:1423086724:530550c3c80e33c80900f31c0ade05c66b22cbe8

10 years agoDisallow assignment to rvalue Range objects (and StringPiece in particular)
Andrei Alexandrescu [Wed, 4 Feb 2015 19:57:51 +0000 (11:57 -0800)]
Disallow assignment to rvalue Range objects (and StringPiece in particular)

Summary:
Before this diff the code below compiled and did absolutely nothing of interest:

StringPiece fun();
...
fun() = "hello";

i.e. assignment to an rvalue range was allowed. Such code is almost always, if not always, in error. This diff fixes that.

Test Plan: ran unittests

Reviewed By: ldbrandy@fb.com

Subscribers: mpawlowski, net-systems@, folly-diffs@, yfeldblum

FB internal diff: D1825360

Signature: t1:1825360:1423097817:fdaaf893cd1abbe71dc857a315df7c45cb6a0bd0

10 years agoSubprocess Process Group Improvements
Darren Mo [Thu, 5 Feb 2015 17:56:04 +0000 (09:56 -0800)]
Subprocess Process Group Improvements

Summary: Eliminated a potential race condition by removing unnecessary code.

Test Plan: Unit tests pass.

Reviewed By: lesha@fb.com

Subscribers: tudorb, trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1824924

Signature: t1:1824924:1423102017:6bce388dccf9126d6ac3a1741d8300a51c5276ed

Blame Revision: D1492526

10 years agoAvoid EventBase depending on Baton (mutex/condvar variant).
Yedidya Feldblum [Wed, 4 Feb 2015 23:10:51 +0000 (15:10 -0800)]
Avoid EventBase depending on Baton (mutex/condvar variant).

Summary: [Folly] Avoid EventBase depending on Baton (mutex/condvar variant).

Test Plan:
Unit tests:
* folly/io/async/test/EventBaseTest.cpp

Reviewed By: subodh@fb.com

Subscribers: trunkagent, fma, folly-diffs@, yfeldblum, dougw, brettp

FB internal diff: D1823407

Signature: t1:1823407:1423088450:71ae1673ed8067103e2aaa1ac9b239eae9ebe9de

Blame Revision: D1810764

10 years agoFix comment
Hans Fugal [Wed, 4 Feb 2015 21:03:26 +0000 (13:03 -0800)]
Fix comment

Summary: It is true. Also, add a useful message about which thread this Future will complete in.

Test Plan: it should still compile

Reviewed By: davejwatson@fb.com

Subscribers: trunkagent, exa, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1819849

Tasks: 57052866008465

Signature: t1:1819849:1423074012:79bf11c877eb2f061cb5d07f7ab45fa4cc4a894b

10 years agoFuture<T>::onTimeout(Duration, function<T()>, Timekeeper*=nullptr)
Hans Fugal [Wed, 4 Feb 2015 20:55:23 +0000 (12:55 -0800)]
Future<T>::onTimeout(Duration, function<T()>, Timekeeper*=nullptr)

Summary:
(or func returns Future<T>)

Invoke and respond to a timeout with a callback, rather than using `within` and adding `onError` or `then` or something.

Test Plan: new tests

Reviewed By: davejwatson@fb.com

Subscribers: jsedgwick, yfeldblum, trunkagent, fugalh, exa, folly-diffs@

FB internal diff: D1763174

Tasks: 4548494

Signature: t1:1763174:1423074062:05cec1dfb1110b31b599033949ebe0ee70dd0552

10 years agoFix another comment
Hans Fugal [Wed, 4 Feb 2015 20:54:10 +0000 (12:54 -0800)]
Fix another comment

Summary:
I don't know what this paragraph is even saying. It looks like
copypasta

Test Plan: still compiles or my uncle is a monkey

Reviewed By: davejwatson@fb.com

Subscribers: trunkagent, exa, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1819905

Tasks: 5705286

Signature: t1:1819905:1423074021:a095fe2a17d5698678a527b60c9384625df869fd

10 years agoFixing find_first_of O(n) case
Tom Jackson [Wed, 4 Feb 2015 20:51:11 +0000 (12:51 -0800)]
Fixing find_first_of O(n) case

Summary:
The `memchr()`-based `find_first_of()` behaves extremely badly when it's used in a loop and the input string doesn't contain all the needles. This was discovered when a reasonable line-breaking routine tried to use it to break lines by a mix of '\r' and '\n'. The entire remainder of the file was scanned each time a line was read.

Before:

```
CountDelimsBase                    1.26s   794.86m
CountDelimsNoSSE         100.03%   1.26s   795.12m
CountDelimsStd         40501.63%   3.11ms  321.93
CountDelimsMemchr         98.31%   1.28s   781.41m
CountDelimsByteSet     23162.41%   5.43ms  184.11
```

After:

```
CountDelimsBase                   3.20ms  312.08 <-- Base impl no longer considers memchr
CountDelimsNoSSE         102.37%  3.13ms  319.47
CountDelimsStd           103.19%  3.11ms  322.05
CountDelimsMemchr          0.25%  1.27s   788.39m
CountDelimsByteSet        59.68%  5.37ms  186.27
```

Test Plan: Benchmarks

Reviewed By: njormrod@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1823536

Signature: t1:1823536:1423081687:bb2ec8cdea477ee9b9c8d8ad2bfdecdc52657515

10 years agoRevert "fix configure script to check pthread_atfork(3) in the correct way"
Sara Golemon [Wed, 11 Feb 2015 01:54:30 +0000 (17:54 -0800)]
Revert "fix configure script to check pthread_atfork(3) in the correct way"

This reverts commit 462e13b135cfa772403fddc16105bf23ea78105a.

10 years agoMerge pull request #125 from 0mok/fix-configure-pthread-atfork
Marcin [Mon, 9 Feb 2015 20:02:49 +0000 (20:02 +0000)]
Merge pull request #125 from 0mok/fix-configure-pthread-atfork

fix configure script to check pthread_atfork(3) in the correct way

10 years agoMerge commit '64f2f2734ad853784bdd260bcf31e065c47c0741' into fix-configure-pthread...
Brad Kim [Mon, 9 Feb 2015 05:04:00 +0000 (14:04 +0900)]
Merge commit '64f2f2734ad853784bdd260bcf31e065c47c0741' into fix-configure-pthread-atfork

10 years agoBump version to 24:0 v0.24.0
Andrew Cox [Wed, 4 Feb 2015 21:04:02 +0000 (13:04 -0800)]
Bump version to 24:0

10 years agoFix folly::Singleton error message
Andrii Grynenko [Wed, 4 Feb 2015 20:01:39 +0000 (12:01 -0800)]
Fix folly::Singleton error message

Test Plan: fbmake runtests

Reviewed By: chip@fb.com, pavlo@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1825369

Signature: t1:1825369:1423080185:8507643a3f8860bae6a2240e0ae28fbaf2885b12

10 years agoFuture constructor
Dave Watson [Wed, 4 Feb 2015 18:52:49 +0000 (10:52 -0800)]
Future constructor

Summary:
As a replacement for makeFuture().  The main advantage is for non-void futures, implicit conversion works pretty well.

See unittest for examples

Test Plan: fbconfig -r folly/futures; fbmake runtests

Reviewed By: hannesr@fb.com

Subscribers: yfeldblum, trunkagent, doug, folly-diffs@, jsedgwick

FB internal diff: D1806575

Signature: t1:1806575:1422465608:6099f791591b70ce1bcda439b49307b8f3187d89

10 years agoAdding demonstrative test of O(n^2) string split case
Tom Jackson [Wed, 4 Feb 2015 18:52:34 +0000 (10:52 -0800)]
Adding demonstrative test of O(n^2) string split case

Summary:
Even though the benchmark only keeps the first 10 lines, it gets slower the bigger the "file" is.

```
folly/gen/test/StringBenchmark.cpp              relative  time/iter  iters/s
----------------------------------------------------------------------------
Lines_Gen(1e3)                                               5.53us  180.94K
Lines_Gen(2e3)                                    66.43%     8.32us  120.21K
Lines_Gen(3e3)                                    48.26%    11.45us   87.33K
```

Test Plan: Benchmarks

Reviewed By: lesha@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1823545

Tasks: 6155600

Signature: t1:1823545:1423023712:86fdb3dadbec44195e4b3596cf793cea80ae3a76

10 years agofix AsyncServerSocket::bind issue
Philip Pronin [Tue, 3 Feb 2015 07:53:46 +0000 (23:53 -0800)]
fix AsyncServerSocket::bind issue

Summary:
When closing sockets on retry, we should use `shutdownSocketSet_`
if it is set (so socket will properly be removed from the set).

Also I changed all `::close()` and `::shutdown()` calls to `*NoInt()`
version.

Test Plan:
fbconfig unicorn/test:basic_compression_test && fbmake opt -j32
while _bin/unicorn/test/test:basic_compression_test; do echo DONE; done

Reviewed By: mcduff@fb.com

Subscribers: trunkagent, folly-diffs@, yzhan, yfeldblum

FB internal diff: D1821104

Tasks: 47525796123510

Signature: t1:1821104:1423001050:5bc09ffdd6666c2884ea82dbd70831a56513cfc9

Blame Revision: D1795120

10 years agoprint better error message
Tianjiao Yin [Tue, 3 Feb 2015 22:03:18 +0000 (14:03 -0800)]
print better error message

Summary:
before:

E0203 12:32:34.548096 3354863 [admonitor-local] Singleton.cpp:72] Singleton of type N8facebook12configerator22ConfigeratorStaticDataE has a living reference at destroyInstances time; beware! Raw pointer is 0x7fd6ccc81000. It is very likely that some other singleton is holding a shared_ptr to it. Make dependencies between these singletons are properly defined.

after:

E0203 13:48:09.013022 3913115 Singleton.cpp:72] Singleton of type facebook::configerator::ConfigeratorStaticData has a living reference at destroyInstances time; beware! Raw pointer is 0x7f6f7dc4c000. It is very likely that some other singleton is holding a shared_ptr to it. Make dependencies between these singletons are properly defined.

Test Plan: run it

Reviewed By: chip@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1822466

Signature: t1:1822466:1423000686:345f40fa706701476256a7157468521bc69166a0

10 years agokill asyncsslserversocket
Dave Watson [Mon, 2 Feb 2015 22:10:44 +0000 (14:10 -0800)]
kill asyncsslserversocket

Summary: This was only used in a unittest, every real use case uses AsyncServerSocket, and decides on its own to do SSL or not.

Test Plan: fbconfig -r thrift/lib/cpp/test; fbmake runtests

Reviewed By: alandau@fb.com

Subscribers: fugalh, trunkagent, doug, alandau, bmatheny, ssl-diffs@, mshneer, jsedgwick, folly-diffs@

FB internal diff: D1806807

Signature: t1:1806807:1422396209:02333c736e1ef10963e3fe0b4ed6ecf6122475bb

10 years agoRemove request context enable flag
Dave Watson [Tue, 27 Jan 2015 21:05:18 +0000 (13:05 -0800)]
Remove request context enable flag

Summary:
Originally meant as a kill switch.  It's turned on in everything except adfinder, so we can probably remove this flag after running a couple adfinder canaries

I have no idea who should review this in ads team, guessed and added some people

Test Plan: https://our.intern.facebook.com/intern/tupperware/canary/view/?experiment_id=32937

Reviewed By: haijunz@fb.com

Subscribers: trunkagent, doug, ruibalp, nli, alandau, bmatheny, wormhole-diffs@, mshneer, folly-diffs@

FB internal diff: D1809255

Tasks: 5645329

Signature: t1:1809255:1422490068:5b4551e6c126d86cac8f8e7b06da6474e6b8a25a

10 years agoWait for some time if Singleton isn't destroyed immediately
Andrii Grynenko [Wed, 28 Jan 2015 04:09:27 +0000 (20:09 -0800)]
Wait for some time if Singleton isn't destroyed immediately

Summary: This diff introduces 5 seconds wait time to let other threads release Singleton which may be temporarily locked. This helps prevent most of "Singleton object alive after destruction" warnings in cases where weak_ptr API is used correctly. Abusive use of folly::Singletons, where dependencies between singletons are not properly defined will still cause a warning.

Test Plan: unit test

Reviewed By: chip@fb.com

Subscribers: trunkagent, folly-diffs@

FB internal diff: D1808371

Signature: t1:1808371:1422487261:573eb40b6a260e428d96be476659335250c7ea76

10 years agoSet CLOEXEC for connected fd
Haijun Zhu [Mon, 2 Feb 2015 19:41:38 +0000 (11:41 -0800)]
Set CLOEXEC for connected fd

Summary:
AsyncSocket sets CLOEXEC if it connects an address, but won't
if it uses a connected fd. This sets CLOEXEC for such fd.

Test Plan: fbconfig folly/io/async/test && fbmake runtests

Reviewed By: davejwatson@fb.com

Subscribers: trunkagent, folly-diffs@, zacm

FB internal diff: D1809300

Signature: t1:1809300:1422900997:40fcc84506582ac67076fd975a36d094522c35c2

10 years agoEventBase::runInEventLoopThreadAndWait.
Yedidya Feldblum [Mon, 2 Feb 2015 19:37:23 +0000 (11:37 -0800)]
EventBase::runInEventLoopThreadAndWait.

Summary:
[Folly] EventBase::runInEventLoopThreadAndWait.

Useful for when some code needs to be run in the event loop thread, but another thread needs to trigger the code and then wait for it to be done.

Test Plan:
Unit tests:
* `folly/io/async/test/EventBaseTest.cpp`

Reviewed By: davejwatson@fb.com

Subscribers: trunkagent, folly-diffs@, brettp, dougw

FB internal diff: D1810764

Signature: t1:1810764:1422900654:7ff0aa7feb2792266f620b344cf8a1110a09f7ef

10 years agofix configure script to check pthread_atfork(3) in the correct way
Brad Kim [Wed, 4 Feb 2015 15:27:55 +0000 (00:27 +0900)]
fix configure script to check pthread_atfork(3) in the correct way

10 years agoBump version to 23:0 v0.23.0
woo [Mon, 2 Feb 2015 21:15:32 +0000 (13:15 -0800)]
Bump version to 23:0

10 years agofixing readme and configure script links to double-conv
Marcin Pawlowski [Wed, 28 Jan 2015 00:01:46 +0000 (16:01 -0800)]
fixing readme and configure script links to double-conv

Summary:
Fixing following the issues raised by nsuke on github
following his diff (https://github.com/facebook/folly/pull/112)

Test Plan: visual inspection, tested build on arch linux

Reviewed By: davejwatson@fb.com

Subscribers: folly-diffs@

FB internal diff: D1807378

Tasks: 5909189

Signature: t1:1807378:1422403093:ca024f396a27ecd9b304c57643f0107764a38ca1

10 years agoadd some missing methods to DeterministicAtomic
Nathan Bronson [Mon, 2 Feb 2015 16:46:18 +0000 (08:46 -0800)]
add some missing methods to DeterministicAtomic

Summary:
fetch_and and fetch_or are actually required in some instances,
since the operation they perform isn't reversible.  This also adds some
other missing functions, ^= and fetch_{add,sub,xor}.

Test Plan: use from other code's unit tests

Reviewed By: mssarang@fb.com

Subscribers: yfeldblum, folly-diffs@

FB internal diff: D1798924

Signature: t1:1798924:1422892374:a9859039075ddcac54f75259b9bc6a29bb963a09

10 years agoRevert "[folly::gen] Making 'just()' reference arguments like 'from()'"
Chip Turner [Sat, 31 Jan 2015 03:51:20 +0000 (19:51 -0800)]
Revert "[folly::gen] Making 'just()' reference arguments like 'from()'"

Summary: This reverts commit 90da92b05762f8032560d0d6a66237ab2772d7f2.

Test Plan: compiles

Reviewed By: tjackson@fb.com

Subscribers: lins, anca, folly-diffs@, yfeldblum

FB internal diff: D1817376

Tasks: 6118752

10 years agoRework the Future::Core state machine
Hans Fugal [Fri, 30 Jan 2015 23:23:24 +0000 (15:23 -0800)]
Rework the Future::Core state machine

Summary:
There was a race reading `callback_` in `maybeCallback` and setting `callback_` in `setCallback`. This diff reworks the state machine to make this unpossible. To avoid the explosion of states due to the cross-product of has-interrupt-handler/has-been-interrupted/etc. I introduce a separate lock for setting interrupt handler and interruption, since this is primarily orthogonal. Other attributes (active, for example) are still atomic variables, and while somewhat tied into the state machine logically (e.g. transitioning from Armed to Done only happens when active) they are mostly independent, keeping the state machine simple (and probably faster).

I think it may even be possible to do some things cheaper. In some states, we may not need to protect the writing of `callback_` and `result_`. But we'd need to enforce some ordering so I'm not going to try to tackle that. But that could be some speedup if we can do it cheaply.

Test Plan:
Builds and all existing tests pass.

Reviewed By: rockyliu4@fb.com

Subscribers: yfeldblum, stepan, trunkagent, exa, folly-diffs@, jsedgwick

FB internal diff: D1807854

Tasks: 6087856

Signature: t1:1807854:1422656713:25b62706cd7952b2dde06dab08074f8030db456b

10 years agocautionary comment in futexWake
Nathan Bronson [Thu, 29 Jan 2015 20:02:45 +0000 (12:02 -0800)]
cautionary comment in futexWake

Summary:
Add a description of the fault-after-unlock problem that can
occur when a synchronization object is used to guard its own
destruction.

Test Plan: comment change only

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, folly-diffs@

FB internal diff: D1808446

Signature: t1:1808446:1422481173:83c0369e2277cd5b8cf6377fcd92b132019611a7

10 years agoMaking 'just()' reference arguments like 'from()'
Tom Jackson [Thu, 29 Jan 2015 18:56:30 +0000 (10:56 -0800)]
Making 'just()' reference arguments like 'from()'

Summary: That is, for all inputs except r-values.

Test Plan:
Run tests
@override-test-failures

Reviewed By: ajaymenon@fb.com

Subscribers: trunkagent, folly-diffs@

FB internal diff: D1807789

Signature: t1:1807789:1422410689:442d50ab17f8e3b08e34f33318a4dc7f23b4c6cc

10 years agoenable ssl false start with Next Protocol Negotiation (NPN) extension
Shijin Kong [Thu, 29 Jan 2015 18:54:53 +0000 (10:54 -0800)]
enable ssl false start with Next Protocol Negotiation (NPN) extension

Summary:
This speeds up TLS handshake and might be a factor of liger perf regression.
The enabling is guarded by an #ifdef. The condition itself is defined in an
openssl patch.

Test Plan: folly unit tests pass. Tried on devices as well and from tcpdump data was sent before the new ticket was received, essentially speeded up the handshake process.

Reviewed By: subodh@fb.com

Subscribers: trunkagent, kmdent, seanc, benyluo, ssl-diffs@, ranjeeth, folly-diffs@

FB internal diff: D1806856

Tasks: 5284979

Signature: t1:1806856:1422494521:0a048ea9001da13b5d698b5a764d1e66dcbedc99

10 years agoindirect(), for making pointers out of refs
Tom Jackson [Thu, 29 Jan 2015 18:22:59 +0000 (10:22 -0800)]
indirect(), for making pointers out of refs

Test Plan: Unit tests

Reviewed By: ajaymenon@fb.com

Subscribers: trunkagent, folly-diffs@

FB internal diff: D1808023

Signature: t1:1808023:1422410709:8db2d73d5b4c0c2eab563643e5fa1557ebfd4730

10 years agoCleanup duplicate include
Sean Cannella [Wed, 28 Jan 2015 23:28:58 +0000 (15:28 -0800)]
Cleanup duplicate include

Summary:
Included climits and limits.h due to non-conflicting changes,
clean this up.

Test Plan: compiled

Reviewed By: kelarini@fb.com

Subscribers: trunkagent, folly-diffs@

FB internal diff: D1810133

Signature: t1:1810133:1422483209:0826d2198769efed86607de6c5b28ce0bc4ac04b

10 years agofix deprecated Promise::setException()
James Sedgwick [Wed, 28 Jan 2015 21:55:45 +0000 (13:55 -0800)]
fix deprecated Promise::setException()

Summary: should have been using fulfilTry anyways. and fulfilTry needs to take the Try by value so fix that too

Test Plan: unit

Reviewed By: hans@fb.com

Subscribers: fugalh, folly-diffs@, jsedgwick

FB internal diff: D1808923

Tasks: 6098987

Signature: t1:1808923:1422478981:d4b9727394339c996ebccb7841b94e0c7b2bffb4

10 years agoFixing break in multifeed. CHAR_BIT was previously unfound
Kyle Dent [Wed, 28 Jan 2015 21:47:43 +0000 (13:47 -0800)]
Fixing break in multifeed. CHAR_BIT was previously unfound

Summary: Now CHAR_BIT will be found

Test Plan: ran multifeed and folly

Reviewed By: seanc@fb.com

Subscribers: seanc, folly-diffs@

FB internal diff: D1810027

Signature: t1:1810027:1422480946:4568c5190e318ff097d33b3d0434593b72f8205e

10 years agofix missing header in Range.h
Khalid El-Arini [Wed, 28 Jan 2015 21:47:44 +0000 (13:47 -0800)]
fix missing header in Range.h

Summary: ^

Test Plan: fbmake

Reviewed By: woo@fb.com

Subscribers: folly-diffs@

FB internal diff: D1810061

Signature: t1:1810061:1422481560:089c9186834f2bf87ac6d10b71d53784299b7992

Blame Revision: D1806632

10 years agoConvert TransportInfo SSL fields to shared_ptrs
Viswanath Sivakumar [Wed, 28 Jan 2015 20:08:36 +0000 (12:08 -0800)]
Convert TransportInfo SSL fields to shared_ptrs

Summary:
We do a lot of copying of TransportInfo in proxygen, and in most cases
the SSL structs don't change after connection establishment. We could
cut down on memory usage by sharing these huge strings. This is
especially true with SPDY where all streams belonging to a session could
share these fields.

Facebook:

Test Plan: Unit tests, will canary

Reviewed By: afrind@fb.com

Subscribers: fugalh, bmatheny, ssl-diffs@, folly-diffs@, jsedgwick, woo

FB internal diff: D1807557

Tasks: 5343753

Signature: t1:1807557:1422472932:53038345fca620632097586fb9e410bca8fe748d

10 years agoFixing a -Wshorten-64-32 issues in folly for liger.
Kyle Dent [Wed, 28 Jan 2015 19:33:49 +0000 (11:33 -0800)]
Fixing a -Wshorten-64-32 issues in folly for liger.

Summary: Normally I would use the folly::to<> function, but it would cause a circular dependency, so I just added a static cast

Test Plan: Ran on iOS and ran the folly tests

Reviewed By: seanc@fb.com

Subscribers: lucian, mpawlowski, marcelo, tudorb, aalexandre, seanc, folly-diffs@

FB internal diff: D1806632

Signature: t1:1806632:1422416646:b8104f18f90eb7457f2f358428f2bd800f8f1db5

10 years agokill a couple unnecessary rethrows
James Sedgwick [Wed, 28 Jan 2015 19:01:44 +0000 (11:01 -0800)]
kill a couple unnecessary rethrows

Summary: as above, there were less of these than I expected, nice

Test Plan: unit

Reviewed By: hans@fb.com

Subscribers: trunkagent, folly-diffs@, jsedgwick

FB internal diff: D1789332

Tasks: 5949939

Signature: t1:1789332:1421878033:d7c2979a77b51a5257b8bcd910ad9296ca1aa7e0

10 years agoFix Conv.h compilation on Android
Sean Cannella [Wed, 28 Jan 2015 16:47:51 +0000 (08:47 -0800)]
Fix Conv.h compilation on Android

Summary:
std::to_string doesn't exist on Android so don't use it.

Facebook: Did a sync to fbandroid and confirmed liger compiles with this fix.

Test Plan: existing tests

Reviewed By: ranjeeth@fb.com

Subscribers: trunkagent, folly-diffs@, shikong, kmdent, fma, pgriess

FB internal diff: D1808037

Signature: t1:1808037:1422410556:d78e0633a1554254b1a1f25bef49a4550a1817c6

10 years agoAnother stab at waitWithSemaphore -> Future<T>::wait()
James Sedgwick [Wed, 28 Jan 2015 16:05:30 +0000 (08:05 -0800)]
Another stab at waitWithSemaphore -> Future<T>::wait()

Summary:
See D1785572. Check out the new Future test and the commented portion of wait(Duration) for the fix

The test only fails a few times out of a hundred before the fix, but hasn't failed yet after

Test Plan: futures unit, wait for contbuild

Reviewed By: hans@fb.com

Subscribers: trunkagent, rushix, fbcode-common-diffs@, hero-diffs@, cold-storage-diffs@, adamsyta, zhuohuang, darshan, micha, folly-diffs@, lins, tingy, hannesr, jsedgwick

FB internal diff: D1803526

Tasks: 59400086059995

Signature: t1:1803526:1422309486:3613c59a708ecac312d241723828763feb2a57aa