folly.git
10 years agoFix lint errors
Nicholas Ormrod [Mon, 22 Sep 2014 21:13:14 +0000 (14:13 -0700)]
Fix lint errors

Summary: Pass const StringPieces by value instead of reference.

Test Plan:
fbconfig -r folly && fbmake runtests

Reviewed By: robbert@fb.com

Subscribers: trunkagent, sdwilsh, njormrod

FB internal diff: D1569488

10 years agorfc : -Wshorten-64-to-32 warnings in folly liger dependencies
Ranjeeth Dasineni [Wed, 20 Aug 2014 19:38:57 +0000 (12:38 -0700)]
rfc : -Wshorten-64-to-32 warnings in folly liger dependencies

Summary:
This is not a fix but me seeking advice here. The context here is that in liger (our common network
stack for mobile platforms), we saw bugs due to truncation and want to enable these warnings. To find those in our code,
I had to first resolve the folly ones. I just got around by making the truncation explicit so that I can get to real errors.
Ideally I would like owners to examine each case and fix the original/accept the explicit truncate if its intended. Let me
know what you think. The last (least preferred) is for us to keep this as a liger only change. We have a couple of ways to
do that but it would be nice to fix.

N.B : this covers only liger dependencies

Test Plan: errors resolved after these changes.

Reviewed By: njormrod@fb.com

Subscribers: trunkagent, doug, shilin, njormrod, seanc, pgriess

FB internal diff: D1509355

10 years agofix leak in MPMCQueueTest's use of boost::intrusive_ptr
Nathan Bronson [Mon, 22 Sep 2014 18:33:28 +0000 (11:33 -0700)]
fix leak in MPMCQueueTest's use of boost::intrusive_ptr

Summary:
MPMCQueueTest's intrusive reference count test implementation was
incorrect, so it simultaneously didn't test what it should and had a leak.

Test Plan: tests, plus new __thread to track lifetimes

Reviewed By: meyering@fb.com

Subscribers: njormrod, soren, meyering

FB internal diff: D1569448

10 years agoFix lint errors
Nicholas Ormrod [Mon, 22 Sep 2014 18:27:18 +0000 (11:27 -0700)]
Fix lint errors

Summary: Lines exceeding 80 characters have been restructured.

Test Plan:
fbconfig -r folly && fbmake runtests

Reviewed By: robbert@fb.com

Subscribers: trunkagent, sdwilsh, fugalh, njormrod

FB internal diff: D1568086

10 years agoIncrease wangle test timers
Nicholas Ormrod [Mon, 22 Sep 2014 18:20:47 +0000 (11:20 -0700)]
Increase wangle test timers

Summary:
When running all folly tests at once, as with
fbconfig -r folly && fbmake runtests
the wangle tests sometimes fail. Enough tests are running that the
1-millisecond timer is too small, and is sometimes missed. Bumping
it to 10 milliseconds.

Test Plan:
fbconfig -r folly && fbmake runtests

Reviewed By: hans@fb.com

Subscribers: sdwilsh, fugalh, njormrod

FB internal diff: D1568124

Tasks: 5180879

10 years agoFaster accessors for dynamic values
Pavlo Kushnir [Sat, 20 Sep 2014 00:02:35 +0000 (17:02 -0700)]
Faster accessors for dynamic values

Summary:
Sometimes it is useful to have a fast accessor to a value stored in dynamic, without any type conversion. These still do the type check, but compiler has more room for optimization.

Test Plan: build folly, will add unit tests/benchmarks if this makes sense at all.

Reviewed By: njormrod@fb.com

Subscribers: jdelong, njormrod

FB internal diff: D1564867

10 years agoadd function to push data from another cursor
Guohui Wang [Fri, 29 Aug 2014 01:32:59 +0000 (18:32 -0700)]
add function to push data from another cursor

Summary:
Add a function to Writable to push data from another cursor. Data in the input
cursor could be in a buffer chain.

Added test in IOBufCurosTest.cpp to test the new function.

Test Plan: fbmake runtests;

Reviewed By: simpkins@fb.com

Subscribers: njormrod, net-systems@

FB internal diff: D1563209

Tasks: 4886058

Blame Revision:

10 years agoBump version to 9:0
dcsommer [Fri, 19 Sep 2014 22:31:17 +0000 (15:31 -0700)]
Bump version to 9:0

10 years agoDo not barf on invalid ELF files
Tudor Bosman [Fri, 19 Sep 2014 19:58:10 +0000 (12:58 -0700)]
Do not barf on invalid ELF files

Summary: The Haskell runtime does magic, and loads an ET_REL file directly.

Test Plan: ran it

Reviewed By: jon.coens@fb.com

Subscribers: njormrod, rkroll

FB internal diff: D1566853

Tasks: 4401996

@override-unit-failures

10 years agomove socketaddress to folly
Dave Watson [Fri, 12 Sep 2014 18:30:59 +0000 (11:30 -0700)]
move socketaddress to folly

Summary:
Goes with IPAddress and MACAddress already in folly.

* change namespace, add typedef in thrift.  Had to update forward decls to folly namespace.
* change exception types to std:: types instead of TTransportException.  I fbgs'd for everywhere I could find trying to catch these and updated the type, there looked like there were only ~9 files or so.

Test Plan: contbuild.

@override-unit-failures

Tests already passed in last run

Reviewed By: simpkins@fb.com

Subscribers: doug, ps, alandau, everstore-dev@, njormrod, fugalh, alikhtarov, bmatheny, jsedgwick

FB internal diff: D1556916

10 years agofix occasional crash in cpu pool
James Sedgwick [Fri, 19 Sep 2014 10:19:17 +0000 (03:19 -0700)]
fix occasional crash in cpu pool

Summary: need to initialize threadsToStop_ and make it signed so it doesn't underflow in rare races

Test Plan: cpu pool unit tests no longer crash if run a ton of times

Reviewed By: davejwatson@fb.com

Subscribers: fugalh, njormrod

FB internal diff: D1563524

10 years agoinstall connectionmanager headers
Dave Watson [Thu, 18 Sep 2014 19:12:33 +0000 (12:12 -0700)]
install connectionmanager headers

Summary: Install headers / compile files

Test Plan: watch jenkins build

Reviewed By: dcsommer@fb.com

Subscribers: doug, fugalh, njormrod

FB internal diff: D1564098

10 years agoBump version to 8:0
Dave Watson [Thu, 18 Sep 2014 16:45:05 +0000 (09:45 -0700)]
Bump version to 8:0

10 years agomerge https://github.com/facebook/folly/pull/88
dungcoi [Thu, 18 Sep 2014 16:19:57 +0000 (09:19 -0700)]
merge https://github.com/facebook/folly/pull/88

Summary:
merge https://github.com/facebook/folly/pull/88, missing install header

Looks like fbthrift build needs this

Test Plan: watch jenkins build still works

Reviewed By: ckwalsh@fb.com

Subscribers: doug, njormrod

FB internal diff: D1563651

10 years agoRemove dependency on std::to_string
Sean Cannella [Thu, 18 Sep 2014 14:20:04 +0000 (07:20 -0700)]
Remove dependency on std::to_string

Summary:
Mobile platform clang doesn't currently support std::to_string
so remove folly's dependency on it.

Test Plan: existing tests

Reviewed By: mpawlowski@fb.com

Subscribers: kmdent, fma, benyluo, shikong, ranjeeth, subodh, pgriess, njormrod

FB internal diff: D1562179

Tasks: 5183325

10 years agofix race in Future::waitWithSemaphore
Matt Dordal [Wed, 17 Sep 2014 23:52:03 +0000 (16:52 -0700)]
fix race in Future::waitWithSemaphore

Summary:
There's a race condition in waitWithSemaphore, specifically because we're
returning a new future that's completed by the input future. As a result,
that future may not be completed by the time waitWithSemaphore returns,
although completion should be imminent.

Test Plan:
`var=0; while true ; do echo $((var++)); _bin/folly/wangle/wangle-test --gtest_filter='Future*' || break ; done`

Before change two runs yielded 303 and 371.

After change I killed the test at 11000.

Reviewed By: njormrod@fb.com

Subscribers: fugalh, njormrod

FB internal diff: D1561281

Tasks: 5180879

10 years agoremove eof whitespace lines
Nicholas Ormrod [Wed, 17 Sep 2014 20:21:40 +0000 (13:21 -0700)]
remove eof whitespace lines

Summary:
Remove lint errors from folly: trailing newlines

find folly | xargs arc lint | grep -B3 EOF | grep ">>>" | egrep -o "folly[^:]*" | xargs -n1 sed -i '$d'

folly/experimental/io/test/AsyncIOTest.cpp had two trailing newlines,
the second was removed by hand

@override-unit-failures

Test Plan:
fbconfig -r folly && fbmake runtests

Pretty overkill for a whitespace diff, but why not.

Reviewed By: robbert@fb.com

Subscribers: sdwilsh, fugalh, njormrod

FB internal diff: D1561213

10 years agoBump version to 7:0
Dave Watson [Wed, 17 Sep 2014 18:23:54 +0000 (11:23 -0700)]
Bump version to 7:0

10 years agomove connectionmanager/managed connection to wangle
Dave Watson [Wed, 17 Sep 2014 17:20:31 +0000 (10:20 -0700)]
move connectionmanager/managed connection to wangle

Summary: Moar code sharing between proxygen/thrift.  Code must be moved to a common library: The only one we currently have is folly, but if someone wants to argue for a separate lib, that's cool too

Test Plan: fbconfig -r proxygen; fbmake dev

Reviewed By: dcsommer@fb.com

Subscribers: doug, fugalh, bmatheny, njormrod

FB internal diff: D1519919

Tasks: 5002343

10 years agoThreadPoolExecutor and its children CPUThreadPoolExecutor and IOThreadPoolExecutor
James Sedgwick [Wed, 17 Sep 2014 09:58:06 +0000 (02:58 -0700)]
ThreadPoolExecutor and its children CPUThreadPoolExecutor and IOThreadPoolExecutor

Summary:
Spun off from https://phabricator.fb.com/D1534506 as this seemed different enough for a new diff

Similar to previous diff but attempts to reuse a common thread management process between cpu and io bound thread pools. Also sets the stage for other common functionality, e.g. stats, monitoring, timeouts, and so on

Here is some output from the queue benchmark in common/concurrent with both of these pools added (changes to BM not in this diff): https://phabricator.fb.com/P16308560

Test Plan: added a unit test, ran benchmark

Reviewed By: davejwatson@fb.com

Subscribers: fugalh, njormrod, bmatheny

FB internal diff: D1555443

Tasks: 50023925002425

10 years agoFix folly signed/unsigned comparisons
Sean Cannella [Wed, 17 Sep 2014 00:08:52 +0000 (17:08 -0700)]
Fix folly signed/unsigned comparisons

Summary:
Fix a few sign comparison issues in folly::IPAddress

@override-unit-failures

Test Plan: existing tests, compiled with clang

Reviewed By: meyering@fb.com, davejwatson@fb.com

Subscribers: njormrod, bmatheny, subodh, ranjeeth, pgriess

FB internal diff: D1559152

10 years agomake with_exception() const work in all cases
Marc Horowitz [Thu, 11 Sep 2014 00:39:19 +0000 (17:39 -0700)]
make with_exception() const work in all cases

Summary:
Abstract the with_exception() logic into a static template
function which will work with a const or non-const object.

Test Plan: exception_wrapper_test

Reviewed By: vloh@fb.com

Subscribers: njormrod

FB internal diff: D1549175

Tasks: 5127267

10 years agoAdding IO stats in AsyncIO.
Shao-Chuan Wang [Tue, 16 Sep 2014 05:56:18 +0000 (22:56 -0700)]
Adding IO stats in AsyncIO.

Summary:
It would be great if we have IO stats tracking built within AsyncIO.
It would enable upper layer application to better track the number of I/O
that was submitted and completed

Test Plan:
$ fbmake runtests
Test Results Summary:
Passed: 1734
100% successful

Reviewed By: philipp@fb.com

Subscribers: njormrod, schen, stanislav

FB internal diff: D1557472

Tasks: 5008299

10 years agoBump version to 6:0
Dave Watson [Mon, 15 Sep 2014 21:30:23 +0000 (14:30 -0700)]
Bump version to 6:0

10 years agoAdd non-strict mode to folly::Singleton
Chip Turner [Fri, 12 Sep 2014 00:36:50 +0000 (17:36 -0700)]
Add non-strict mode to folly::Singleton

Summary:
It is difficult to guarantee every binary can call
registrationComplete; for now, support a mode where we don't enforce the
strict registration lifecycle.  In the fullness of time, we can make
strictness the default.

Test Plan: runtests

Reviewed By: lins@fb.com

Subscribers: lins, anca, njormrod

FB internal diff: D1551688

10 years agoequality for exception_wrapper
Victor Loh [Fri, 12 Sep 2014 22:03:39 +0000 (15:03 -0700)]
equality for exception_wrapper

Summary:
std::exception_ptr expose methods to compare equality and it
will be great to do so for folly::exception_wrapper (it helps in gmock
testing).

Test Plan: added some unit tests to test this new functionality

Reviewed By: mhorowitz@fb.com

Subscribers: njormrod

FB internal diff: D1546597

10 years agoMake TSocketAddress use folly::IPAddress
Dave Watson [Wed, 3 Sep 2014 21:41:47 +0000 (14:41 -0700)]
Make TSocketAddress use folly::IPAddress

Summary:
Step 1 of moving TAsyncSocket and friends to folly.

folly::IPAddress changes (can split these off if requested):
* isLoopback looks for a single address, as opposed to subnet
* For V6, isPrivate & isLoopback don't seem to check mapped addresses

TSocketAddress changes:
* Make union use folly::IPAddress instead of sockaddr struct.  external_ bool to tell if using AF_UNIX instead.
* manage the port and scope/zone info ourselves

@override-unit-failures

Overriding failures, can't get contbuild to finish all builds after several tries.  None of the failures look related

Test Plan:
fbconfig -r thrift
fbmake runtests
fbconfig folly/test:network_address_test
fbmake runtests

Reviewed By: simpkins@fb.com

Subscribers: snaptu-diffs@, trunkagent, hphp-diffs@, njormrod, fbcode-common-diffs@, doug, ruibalp, ps, alandau, bmatheny

FB internal diff: D1479365

Tasks: 3658665

10 years agofolly: avoid used-uninitialized bug in a test
Jim Meyering [Thu, 11 Sep 2014 22:23:17 +0000 (15:23 -0700)]
folly: avoid used-uninitialized bug in a test

Summary:
Clang complained about this.
* folly/gen/test/FileBenchmark.cpp (BENCHMARK): Initialize "rfd" to -1
and verify that it is set to something nonnegative in the first
BENCHMARK_SUSPEND block.

Test Plan:
Run this:
fbconfig -r --clang --with-project-version clang:dev folly/gen && fbmake runtests
and observe that compilation now succeeds. (and test results remain unchanged)

Reviewed By: tudorb@fb.com

Subscribers: njormrod

FB internal diff: D1551180

Tasks: 4090011

10 years agoBump version to 5:0
Sara Golemon [Wed, 10 Sep 2014 23:59:58 +0000 (16:59 -0700)]
Bump version to 5:0

10 years agoInstall EvictingCacheMap as part of OSS build
Daniel Sommermann [Wed, 10 Sep 2014 23:38:04 +0000 (16:38 -0700)]
Install EvictingCacheMap as part of OSS build

Summary: This may have just been forgotten when imported to folly

Test Plan: live. verified file name

Reviewed By: ranjeeth@fb.com

Subscribers: doug, njormrod

FB internal diff: D1548804

10 years agoFix folly compilation on MacOSX
Sara Golemon [Wed, 10 Sep 2014 18:35:44 +0000 (11:35 -0700)]
Fix folly compilation on MacOSX

Summary:
We don't always have features.h
and our glibc doesn't have __GLIBC_PREREQ()

@override-unit-failures

Test Plan: Builds on MacOSX

Reviewed By: pt@fb.com

Subscribers: njormrod

FB internal diff: D1546679

10 years agoRemove broken test
Dave Watson [Tue, 9 Sep 2014 18:35:27 +0000 (11:35 -0700)]
Remove broken test

Summary: Broken on other platforms, because demangle(typeid()) seems to return different results?  not entirely sure, but would like the builds to be green again

Test Plan: watch contbuild for 'fbthrift jenkins build' to pass

Reviewed By: mhorowitz@fb.com

Subscribers: doug, njormrod

FB internal diff: D1544919

Blame Revision: D1535681

10 years agoBump version to 4:0
Sara Golemon [Tue, 9 Sep 2014 21:22:35 +0000 (14:22 -0700)]
Bump version to 4:0

10 years agoMove HHWheelTimer to folly
Dave Watson [Tue, 26 Aug 2014 17:24:34 +0000 (10:24 -0700)]
Move HHWheelTimer to folly

Summary:
Move wheel timer to folly.  Needed for abstracting some code out of proxygen/thrift

The only code change was removing usage of thrift's Util::currentTime() in favor of std::chrono::steady_clock::now()

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

Reviewed By: alandau@fb.com

Subscribers: doug, alandau, bmatheny, njormrod

FB internal diff: D1519909

10 years agoConvert from jemalloc's obsolete *allocm() to *allocx().
Jason Evans [Wed, 3 Sep 2014 23:08:22 +0000 (16:08 -0700)]
Convert from jemalloc's obsolete *allocm() to *allocx().

Summary:
Convert from jemalloc's obsolete *allocm() to *allocx().

Strengthen goodMallocSize() to always return a jemalloc size class, so
that xallocx() success/failure detection is simple.

@override-unit-failures

Test Plan: Folly, unicorn, and HHVM tests.

Reviewed By: andrei.alexandrescu@fb.com

Subscribers: trunkagent, hphp-diffs@, ps, chaoyc, search-fbcode-diffs@, unicorn-diffs@, ptc, njormrod

FB internal diff: D1535841

Tasks: 4996808

10 years agofix exceptionStr to work for derived classes of std::exception
Marc Horowitz [Thu, 4 Sep 2014 02:32:36 +0000 (19:32 -0700)]
fix exceptionStr to work for derived classes of std::exception

Summary:
templates and overloads are hard.  This uses SFINAE to get
the desired behavior, and includes a test.

This also removes a hack in ExceptionWrapper which isn't needed with this fix.

Test Plan: string_test, exception_wrapper_test

Reviewed By: andrei.alexandrescu@fb.com

Subscribers: dreiss, dancol, njormrod

FB internal diff: D1535681

Blame Revision: D1517701

10 years agoFix bug in stripComments
Pavlo Kushnir [Mon, 8 Sep 2014 17:32:04 +0000 (10:32 -0700)]
Fix bug in stripComments

Summary: the bug is in InString state when we escape only '"' character. We should escape at least '\\' and '"'. This diffs simply escapes any character after '\\'.

Test Plan: folly unit tests, mcrouter unit tests

Reviewed By: stepan@fb.com

Subscribers: njormrod

FB internal diff: D1540836

10 years agoFix bug in circular singleton creation detection
Chip Turner [Wed, 3 Sep 2014 19:22:45 +0000 (12:22 -0700)]
Fix bug in circular singleton creation detection

Summary:
We considered it circular if we tried to create a singleton
while the singleton was being created.  In a single threaded world, this
is correct, but under concurrency, two threads can be in the singleton
creation codepath and become confused about the state of the singleton.

This change uses a condition variable to notify when creation completes
so that other threads can wait on the creation to complete.  Circular
creation is detected via thread id.

Test Plan:
runtests (new test case; failed without the fix, passes with
it)

Reviewed By: hans@fb.com

Subscribers: lins, anca, njormrod, rkroll

FB internal diff: D1534081

10 years ago(Folly/Wangle) Later.then, Later.whenAllLater
Hannes Roth [Thu, 4 Sep 2014 16:17:56 +0000 (09:17 -0700)]
(Folly/Wangle) Later.then, Later.whenAllLater

Summary:
Adding some basic functionality to `Later` to make it easier to chain
things.

Test Plan:
Added tests.

`fbconfig -r folly/wangle && fbmake runtests_{dbg,dbgo,opt}`
`fbconfig --clang -r folly/wangle && fbmake runtests_{dbg,dbgo,opt}`

Reviewed By: hans@fb.com

Subscribers: fugalh, njormrod

FB internal diff: D1527826

Tasks: 4993420

10 years agoRename shadowing local variables in various stats objects
Matt Dordal [Wed, 3 Sep 2014 23:47:14 +0000 (16:47 -0700)]
Rename shadowing local variables in various stats objects

Summary:
The GCC shadow variable detector is quite zealous in warning about
shadowed members. Here, we have local variables that share the name
of member functions. Rename them so that -Wshadow doesn't complain.

Test Plan:
It didn't build, and now it does.

`fbconfig -r folly && fbmake runtests`

Reviewed By: njormrod@fb.com

Subscribers: fbcode-common-diffs@, njormrod

FB internal diff: D1534033

10 years agoMake using folly::Singleton easier: names and direct referencing
Chip Turner [Wed, 30 Jul 2014 22:38:28 +0000 (15:38 -0700)]
Make using folly::Singleton easier: names and direct referencing

Summary:
There are times when you want multiple singletons of the same
underlying type -- for instance, a fast and slow request handling
singleton.  This diff allows for that with an optional name that
disambiguates multiple singletons of the same type.

In addition, we now also allow direct dereferencing of the
Singleton<Foo> object to get to the underlying singleton.  This is most
useful in cases where a singleton is used inside of the same cpp file it
is defined.

Finally, make get() faster by caching the underlying pointer rather than
accessing the shared pointer.  If you're using it, you already have a
race condition and hopefully your singleton lifecycle is sane and safe
from problems this may cause.

Test Plan: runtests

Reviewed By: hans@fb.com

Subscribers: njormrod, lins, anca

FB internal diff: D1485887

10 years agouse folly::Baton in waitWithSemaphore
Philip Pronin [Thu, 28 Aug 2014 11:05:45 +0000 (04:05 -0700)]
use folly::Baton in waitWithSemaphore

Test Plan:
fbconfig -r folly/wangle && fbmake runtests -j32

Reviewed By: lucian@fb.com

Subscribers: sdoroshenko, fugalh, njormrod

FB internal diff: D1525044

Tasks: 2680246

Blame Revision: D1358230

10 years agoMake it work more generically
Marc Horowitz [Mon, 11 Aug 2014 22:40:23 +0000 (15:40 -0700)]
Make it work more generically

Summary:
Change the strategy here: provide a more generic interface
which can be used safely with any exception types, but operates more
efficiently for explicitly named types.  Update the callers to use the
new pattern, which mostly means get() and operator* are replaced with
other more generic methods.  (This diff was constructed by merging
D1490304D1501644, and D1500861.)

Test Plan:
run tests.  Run something which generates an exception
message, and make sure that message isn't "std::exception"

Reviewed By: marccelani@fb.com

Subscribers: ruibalp, mcduff, marccelani, hitesh, mshneer, rtgw-diffs@, alandau, bmatheny, adityab, wormhole-diffs@, bwester, njormrod

FB internal diff: D1517701

10 years agoImprove messaging when registrationComplete hasn't been called
Chip Turner [Thu, 7 Aug 2014 13:19:22 +0000 (06:19 -0700)]
Improve messaging when registrationComplete hasn't been called

Summary:
The previous message from CHECK_THROW was difficult to debug.
This improves the messaging to be more actionable.

Test Plan: runtests

Reviewed By: lins@fb.com

Subscribers: lins, anca, fugalh

FB internal diff: D1483915

10 years agoEventCountTest cleanups
Soren Lassen [Sun, 24 Aug 2014 05:27:12 +0000 (22:27 -0700)]
EventCountTest cleanups

Summary: based on code review feedback in D1516171

Test Plan: ran the test

Reviewed By: philipp@fb.com

Subscribers: njormrod

FB internal diff: D1516187

10 years agoFix compilation warning
Daniel Sommermann [Fri, 22 Aug 2014 20:26:52 +0000 (13:26 -0700)]
Fix compilation warning

Summary:
Defining hash as a struct and a class was causing some junk to
get printed during fbmake.

Test Plan: `fbconfig -r proxygen; fbmake dbg`, ran unit tests, didn't see output

Reviewed By: njormrod@fb.com

Subscribers: doug, shilin, njormrod

FB internal diff: D1514793

10 years agoFix block overhead estimation in tests
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

10 years agoFix various compiler warnings
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

10 years agoFix #includes
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

10 years agofbcode: __x__-protect all __attribute__ keywords, mechanically
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

10 years agoAdd link-local scope handling
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

10 years agomade toAppendDelim better
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

10 years agoFix Optional test for -fb platform
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

10 years agohash_range
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

10 years ago(Wangle) Optimize empty continuation
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

10 years agoAdd Optional::value_or
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

10 years agoFix json_test's lookup of test files.
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

10 years agoEnabling folly::Synchronized for non-default constructible objects
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

10 years agoClang Love
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

10 years agoFactor out JSON stripComments().
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

10 years agoBump version to 3:2
Sara Golemon [Fri, 15 Aug 2014 05:38:03 +0000 (22:38 -0700)]
Bump version to 3:2

10 years agodon't use readFromSysfs on non-linux
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

10 years agoAdd missing s6_addr16 define for MacOSX targets
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

10 years agoBump version to 3:1
Sara Golemon [Fri, 15 Aug 2014 02:19:11 +0000 (19:19 -0700)]
Bump version to 3:1

10 years agobe explicit about what integer type we're using
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

10 years agoBump version to 3:0
Sara Golemon [Thu, 14 Aug 2014 18:49:22 +0000 (11:49 -0700)]
Bump version to 3:0

10 years ago(Wangle) Generic void star callback wrapper
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

10 years agofix build (gtest 1.6 -> 1.7)
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: 4909974491054749105674909983

10 years agomove EvictingCacheMap to folly
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

10 years agoRemove constructor version attribute on OS X
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

10 years agoSmall memory footprint reduction for folly::MultiLevelTimeSeries
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

10 years agofolly: operator << for MutableStringPiece
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

10 years agoalways log from LOG_EVERY_MS if interval is <= 0
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

10 years agoFix test breakage in clang
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

10 years agostore ipaddresses in folly::IPAddress
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

10 years agoAdd timed_wait and try_wait to Baton
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

10 years agoEliasFanoReader::{jump,jumpTo}
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

10 years agoImprove IPAddress::toFullyQualified() CPU performance
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

10 years agofolly/test: correct an erroneous test for failed mmap
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

10 years agostreaming support for EF compression
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

10 years agofolly/IndexedMemPool: correct an erroneous test for failed mmap
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

10 years agosorted_vector containers have a shrink_to_fit() method
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

10 years agoDon't check for thread running in terminateLoopSoon()
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

10 years agorfc: move folly::json::ParseError type to folly/json.h
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

10 years agoEliasFanoReader::goTo()
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

10 years agoAPI for getTimeoutManager
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

10 years agoinstall delayeddestruction header
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

10 years agoConstruct Later with exception_ptr
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

10 years agoMove TDelayedDestruction to folly::DelayedDestruction
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

10 years agoIPAddress::empty()
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

10 years agoBump version to 2:0
Chip Turner [Fri, 25 Jul 2014 16:07:33 +0000 (09:07 -0700)]
Bump version to 2:0

10 years agoTry again: folly::Singleton, a class for managing singletons
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

10 years agoAdd method to parse parameter list in query string to folly::Uri
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

10 years agoAdding one more test for trailing dots
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

10 years ago(wangle) set* should not invalidate getFuture
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

10 years agoVersioning for Thrift, remove thrift/lib/cpp/config.h
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

10 years agoSupport trailing decimals for floats
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

10 years agoMake ElfFile not crash on invalid ELF files
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

10 years agoEnforce that only one version of folly is loaded at the same time
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

10 years agoFix a folly build failure under clang: ConvTest.cpp.
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