folly.git
9 years agoDrop support for GCC < 4.8 in folly/experimental/Bits.h
Yedidya Feldblum [Sun, 13 Sep 2015 20:23:17 +0000 (13:23 -0700)]
Drop support for GCC < 4.8 in folly/experimental/Bits.h

Summary: [Folly] Drop support for GCC < 4.8 in folly/experimental/Bits.h

Can't stay indefinitely backcompat with older compilers.

Reviewed By: @meyering

Differential Revision: D2420133

9 years agoPort Folly to PPC64
Leonardo Bianconi [Sun, 13 Sep 2015 16:47:49 +0000 (09:47 -0700)]
Port Folly to PPC64

Summary: This patch adds PPC64 specific code in order to support this architecture and be able to be used by HHVM.
Closes #299

Reviewed By: @simpkins

Differential Revision: D2340723

Pulled By: @JoelMarcey

9 years agoAdd support for std::string in folly::Hash
Giuseppe Ottaviano [Sat, 12 Sep 2015 00:37:20 +0000 (17:37 -0700)]
Add support for std::string in folly::Hash

Reviewed By: @​liviu

Differential Revision: D2436705

9 years agoTyping changes in the LockFreeRingBuffer to support 64/32 bit iOS architectures.
Bryce Redd [Fri, 11 Sep 2015 22:46:05 +0000 (15:46 -0700)]
Typing changes in the LockFreeRingBuffer to support 64/32 bit iOS architectures.

Summary: The capacity variable changed types, and turn function needed an explicit cast.

Reviewed By: @BurntBrunch

Differential Revision: D2421421

9 years agoAdd ability to merge dynamic objects
Kevin Hurley [Fri, 11 Sep 2015 17:25:14 +0000 (10:25 -0700)]
Add ability to merge dynamic objects

Summary: Adding ability to merge dynamic objects with another object.  It will just overwrite duplicate keys

Reviewed By: @yfeldblum

Differential Revision: D2413628

9 years agoMarking a bunch of AsyncSSLSocket methods as "const".
Maxim Georgiev [Fri, 11 Sep 2015 16:38:28 +0000 (09:38 -0700)]
Marking a bunch of AsyncSSLSocket methods as "const".

Summary: folly::AsyncSSLSocket class has a number of "get..." methods which don't change the object's state, but are not marked as "const". As a result these methods can't be called on objects passed through const pointer or referrence. Adding "const" modificator for these methods.

Reviewed By: @yfeldblum

Differential Revision: D2430134

9 years agoRevert "use thread_local instead of ThreadLocal for some statics in Random"
Sara Golemon [Fri, 11 Sep 2015 15:18:59 +0000 (08:18 -0700)]
Revert "use thread_local instead of ThreadLocal for some statics in Random"

This reverts commit 6caa3d95ee837703f8f094ffbff5592627417711.

9 years agofolly: fix EmplaceIterCtor test
Lucian Grijincu [Fri, 11 Sep 2015 05:10:42 +0000 (22:10 -0700)]
folly: fix EmplaceIterCtor test

Reviewed By: @yfeldblum

Differential Revision: D2433146

9 years agoUse type-parameterized test cases in folly/test/SynchronizedTest.cpp
Yedidya Feldblum [Fri, 11 Sep 2015 03:22:21 +0000 (20:22 -0700)]
Use type-parameterized test cases in folly/test/SynchronizedTest.cpp

Summary: [Folly] Use type-parameterized test cases in `folly/test/SynchronizedTest.cpp`.

And some cleanups.

Reviewed By: @nbronson

Differential Revision: D2428287

9 years agoFix Build: IPv6: SocketAddressTest.SetFromStrings and AsyncSocketTest.ConnectTimeout...
Yedidya Feldblum [Fri, 11 Sep 2015 03:21:30 +0000 (20:21 -0700)]
Fix Build: IPv6: SocketAddressTest.SetFromStrings and AsyncSocketTest.ConnectTimeout failing

Summary: [Folly] Fix Build: IPv6: `SocketAddressTest.SetFromStrings` and `AsyncSocketTest.ConnectTimeout` failing

On IPv6-only machines, the `SocketAddressTest.SetFromStrings` example in `folly/test/SocketAddressTest.cpp` was failing because it tries to resolve `127.0.0.1` with `AI_ADDRCONFIG` set. Fix it by detecting which of IPv6 and IPv4 are enabled, and picking an appropriate loopback address.

On IPv6-only machines, the `AsyncSocketTest.ConnectTimeout` example in `folly/io/async/test/AsyncSocketTest2.cpp` was failing because it tries to connect `8.8.8.8`, which is IPv4. Fix it by detecting which of IPv6 and IPv4 are enabled, and picking an approprate remote address.

Reviewed By: @chipturner

Differential Revision: D2429109

9 years agouse thread_local instead of ThreadLocal for some statics in Random
Mark McDuff [Thu, 16 Jul 2015 23:27:21 +0000 (16:27 -0700)]
use thread_local instead of ThreadLocal for some statics in Random

Summary: Exit synchronization is the worst!  The worst!

Reviewed By: @​bmaurer

Differential Revision: D2253073

9 years agoMake EliasFanoReader and BitVectorReader API more consistent
Giuseppe Ottaviano [Thu, 10 Sep 2015 15:26:36 +0000 (08:26 -0700)]
Make EliasFanoReader and BitVectorReader API more consistent

Summary: This diff introduces a few breaking API changes to both EliasFanoReader and BitVectorReader in order to fix some inconsistencies:

- As initalized, `EliasFanoReader` and `BitVectorReader` held a value of `0`, thus if `0` is present in the list `skipTo(0)` would not update the position to `0`, as it happens with any other `skipTo(<first element>)`. This fixes `jumpTo` accordingly.
- `jump(i + 1)` would go at position `i`. Now `reader.jump(i)`'s postcondition is `reader.position() == i`.
- It is now illegal to retrieve `value()` from a reader in an out-of-bounds position (before-the-begin or past-the-end). Validity of a reader can be checked with `valid()`.

Reviewed By: @philippv

Differential Revision: D2420023

9 years agoAdd SharedPromise<T>::isFulfilled
Elliott Clark [Thu, 10 Sep 2015 07:31:47 +0000 (00:31 -0700)]
Add SharedPromise<T>::isFulfilled

Summary: Promise<T> has isFulFilled. This patch adds the corresponding functionality to shared promise.

Reviewed By: @jsedgwick

Differential Revision: D2417631

9 years agofolly: small_vector: emplace_back for iterator constructor (compat with std::vector)
Lucian Grijincu [Thu, 10 Sep 2015 00:22:27 +0000 (17:22 -0700)]
folly: small_vector: emplace_back for iterator constructor (compat with std::vector)

Summary: This works:
  std::vector<T*> v;
  std::vector<std::unique_ptr<T>> uv(v.begin(), v.end())

Make it work for small_vector as well.

Reviewed By: @ot, @Gownta

Differential Revision: D2426919

9 years agofolly::FunctionScheduler: Adding support for uniform interval distribution
Eugene Pekurovsky [Wed, 9 Sep 2015 19:33:59 +0000 (12:33 -0700)]
folly::FunctionScheduler: Adding support for uniform interval distribution

Summary: 1) Added uniform interval distribution functionality.
2) Added a generic API for custom interval distribution algorithms.
3) Fixed an issue with removing a canceled function.
4) Did some code cleanup along the way.

Reviewed By: @​kaanb

Differential Revision: D2339911

9 years agoHandle take(-1) better
Tom Jackson [Wed, 9 Sep 2015 19:23:51 +0000 (12:23 -0700)]
Handle take(-1) better

Summary: It's easy to accidentally pass a negative value to ##take()##, which leads to underflow on conversion to ##size_t##.

Reviewed By: @​rosephilip, @philippv

Differential Revision: D2421459

9 years agoDrop support for GCC < 4.8 in folly/Conv.h
Yedidya Feldblum [Wed, 9 Sep 2015 01:48:54 +0000 (18:48 -0700)]
Drop support for GCC < 4.8 in folly/Conv.h

Summary: [Folly] Drop support for GCC < 4.8 in folly/Conv.h.

Can't stay indefinitely backcompat with older compilers.

Reviewed By: @Gownta, @JoelMarcey

Differential Revision: D2422369

9 years agoDrop support for GCC < 4.8 in folly/test/FBStringTest.cpp
Yedidya Feldblum [Tue, 8 Sep 2015 22:24:42 +0000 (15:24 -0700)]
Drop support for GCC < 4.8 in folly/test/FBStringTest.cpp

Summary: [Folly] Drop support for GCC < 4.8 in folly/test/FBStringTest.cpp.

Can't stay indefinitely backcompat with older compilers.

Reviewed By: @tudor

Differential Revision: D2422425

9 years agoImplement assume()
Giuseppe Ottaviano [Tue, 8 Sep 2015 19:20:36 +0000 (12:20 -0700)]
Implement assume()

Summary: In some cases hinting the compiler about conditions that are guaranteed
to be true can help it generate better code. For instance, remove
unnecessary bound checks. Clang has `__builtin_assume` and on GCC we
can simulate it with `__builtin_unreachable`, so better just abstract
both into a function.

Reviewed By: @philippv

Differential Revision: D2419937

9 years agoSwitch a local from long to size_t for MSVC
Orvid King [Tue, 8 Sep 2015 01:23:38 +0000 (18:23 -0700)]
Switch a local from long to size_t for MSVC

Summary: Because MSVC would try to calculate the mmapLength as a long value, which isn't correct, and MSVC issues multiple warnings if you try to do it.
Closes #289

Reviewed By: @yfeldblum

Differential Revision: D2419061

Pulled By: @JoelMarcey

9 years agoImplement adjacent_tokens_only() for GFlagValueSemanticBase
Tom Hughes [Tue, 8 Sep 2015 01:23:00 +0000 (18:23 -0700)]
Implement adjacent_tokens_only() for GFlagValueSemanticBase

Summary: Needed for boost 1.59.0 which added this as a pure virtual function
in the value_semantic base class. Fixes #314.
Closes #315

Reviewed By: @yfeldblum

Differential Revision: D2419035

Pulled By: @JoelMarcey

9 years agoDeclare missing environ variable
Christopher Dolan [Tue, 8 Sep 2015 01:18:45 +0000 (18:18 -0700)]
Declare missing environ variable

Summary: Declaring `extern char** environ` in `experimental/TestUtil.cpp` fixes a compilation issue on OS X 10.10.
Closes #311

Reviewed By: @yfeldblum

Differential Revision: D2419037

Pulled By: @JoelMarcey

9 years agoDead Code: GCC-v4.6 Back Compat: folly/Chrono.h
Yedidya Feldblum [Mon, 7 Sep 2015 05:32:50 +0000 (22:32 -0700)]
Dead Code: GCC-v4.6 Back Compat: folly/Chrono.h

Summary: [Folly] Dead Code: GCC-v4.6 Back Compat: folly/Chrono.h

Reviewed By: @philippv

Differential Revision: D2419086

9 years agofix SharedPromise<T>::setWith
James Sedgwick [Fri, 4 Sep 2015 21:09:39 +0000 (14:09 -0700)]
fix SharedPromise<T>::setWith

Summary: was using the renamed/nonexistent makeTryFunction

Reviewed By: @elliottneilclark

Differential Revision: D2416178

9 years agoFix MemoryIdler::flushLocalMallocCaches() regression.
Jason Evans [Fri, 4 Sep 2015 16:12:18 +0000 (09:12 -0700)]
Fix MemoryIdler::flushLocalMallocCaches() regression.

Summary: Fix MemoryIdler::flushLocalMallocCaches() to use the correct type when querying
jemalloc's "opt.narenas" mallctl.

Reviewed By: @jobenber

Differential Revision: D2414309

9 years agoAllow (read-only) access to a fiber's stack details
Brian Watling [Thu, 3 Sep 2015 20:13:26 +0000 (13:13 -0700)]
Allow (read-only) access to a fiber's stack details

Summary: Allow users to access the stack pointer and stack size

Reviewed By: @alikhtarov

Differential Revision: D2407252

9 years agofolly: specialise makeFutureWith for functions returning futures
Sven Over [Wed, 2 Sep 2015 10:13:17 +0000 (03:13 -0700)]
folly: specialise makeFutureWith for functions returning futures

Summary: makeFutureWith executes a function and returns a future containing
set to the function's return value. This diff adds a specialisation
for the case when the function returns some type Future<T>. Instead
of returning Future<Future<T>>, makeFutureWith now just passes
on the future that the function returned, which may or may not have
a value set at this time. In case the function throws,
makeFutureWith returns a Future<T> containing the exception.

With this diff, the following two lines produce equivalent results:
  auto f1 = makeFutureWith(func);
  auto f2 = makeFuture().then(func);
except for the fact that f2 requires an additional temporary
Future<Unit> to be created and destroyed.

Reviewed By: @fugalh

Differential Revision: D2388335

9 years agoErasing Cpp2Worker in its evb thread
Haijun Zhu [Tue, 1 Sep 2015 23:50:12 +0000 (16:50 -0700)]
Erasing Cpp2Worker in its evb thread

Summary: Erasing Cpp2Worker happens in acceptor thread but when evb is
destroyed and drains its callback queue, the callbacks may access the
worker. This moves erasing Cpp2Worer to its own evb thread, after all
callbacks are run.

Reviewed By: @yfeldblum

Differential Revision: D2398089

9 years agoBump version to 57:0 v0.57.0
Sara Golemon [Mon, 31 Aug 2015 21:44:27 +0000 (14:44 -0700)]
Bump version to 57:0

9 years agoUniversally update to jemalloc 4.0.0.
Jason Evans [Sat, 29 Aug 2015 20:34:12 +0000 (13:34 -0700)]
Universally update to jemalloc 4.0.0.

Summary: Universally update to jemalloc 4.0.0.

Update MALLOC_CONF/malloc_conf configuration, and use the
"arena.<i>.purge" mallctl (replaces "arenas.purge").

Reviewed By: @​bmaurer

Differential Revision: D2355602

9 years agoLog TLS signature_algorithms extension values.
Kyle Nekritz [Fri, 28 Aug 2015 20:35:05 +0000 (13:35 -0700)]
Log TLS signature_algorithms extension values.

Summary: Provide a folly interface for logging the client supported TLS signature algorithms.

Reviewed By: @siyengar

Differential Revision: D2374528

9 years agoRevert "Mass Revert to cdb635a"
Sara Golemon [Mon, 31 Aug 2015 20:45:31 +0000 (13:45 -0700)]
Revert "Mass Revert to cdb635a"

This reverts commit 37f45ee56d52b31c662ea6e0893206ed3fabf8fb which should not have been pushed.

9 years agoBump version to 56:0 v0.56.0
Sara Golemon [Mon, 31 Aug 2015 20:26:50 +0000 (13:26 -0700)]
Bump version to 56:0

9 years agoMass Revert to cdb635a
Michael Lee [Fri, 28 Aug 2015 19:24:32 +0000 (12:24 -0700)]
Mass Revert to cdb635a

Reviewed By: @​sarals, @siyengar, @​dpittman, @​alephbax

9 years agoAdding singular token bucket implementation.
Michael Morton [Thu, 27 Aug 2015 22:44:43 +0000 (15:44 -0700)]
Adding singular token bucket implementation.

Summary: Contains only the central implementation of the TokenBucket, without moving other files to use the new implementation.

Reviewed By: @yfeldblum

Differential Revision: D2329892

9 years agomake doNotOptimizeAway work with clang
Mainak Mandal [Wed, 26 Aug 2015 17:42:59 +0000 (10:42 -0700)]
make doNotOptimizeAway work with clang

Summary: Projects depending on benchmark library fail to build with clang with the following error
```
./folly/Benchark.h:263:16: error: inline asm not supported yet: don't know how to handle tied indirect register inputs
```

I am not an expert here, just tried to take an approach similar to the MSVC compiler clause

Reviewed By: @andralex, @yfeldblum

Differential Revision: D2368670

9 years agoFix the example for folly::static_function_deleter.
Yedidya Feldblum [Wed, 26 Aug 2015 08:57:57 +0000 (01:57 -0700)]
Fix the example for folly::static_function_deleter.

Summary: [Folly] Fix the example for folly::static_function_deleter.

The problem is that

    int BIO_free(BIO*)

is not directly compatible.

So have two examples. One using `RSA_free` which is compatible, and one making a compatible wrapper around `BIO_free`.

Reviewed By: @Gownta

Differential Revision: D2381125

9 years agoBump version to 55:0 v0.55.0
Sara Golemon [Tue, 25 Aug 2015 04:47:24 +0000 (21:47 -0700)]
Bump version to 55:0

9 years agoAdding a unit test for HHWheelTimer exercising the default timeout functionality.
Maxim Georgiev [Tue, 25 Aug 2015 01:46:35 +0000 (18:46 -0700)]
Adding a unit test for HHWheelTimer exercising the default timeout functionality.

Summary: Recently default timeout logic was added to HHWheelTimer interface. This diff adds a unit test exercising this new logic.

Reviewed By: @djwatson

Differential Revision: D2376834

9 years agoGive folly/symbolizer an explicit main function
Mark Isaacson [Mon, 24 Aug 2015 21:40:00 +0000 (14:40 -0700)]
Give folly/symbolizer an explicit main function

Summary: Don't automatically generate the main function for this test.

Reviewed By: @Gownta

Differential Revision: D2375814

9 years agoCreate MockAsyncUDPSocket
Peter Griess [Mon, 24 Aug 2015 13:12:29 +0000 (06:12 -0700)]
Create MockAsyncUDPSocket

Summary: - Mark all methods in AsyncUDPSocket as virtual
- Create new gmock AsyncUDPSocket: MockAsyncUDPSocket

Reviewed By: @yfeldblum

Differential Revision: D2370668

9 years agoRename fixup from TDelayedDestruction to DelayedDestruction.
Yedidya Feldblum [Sun, 23 Aug 2015 05:09:33 +0000 (22:09 -0700)]
Rename fixup from TDelayedDestruction to DelayedDestruction.

Summary: [Folly] Rename fixup from TDelayedDestruction to DelayedDestruction.

Just affects comments.

Reviewed By: @haijunz

Differential Revision: D2373364

9 years agoRename fixup from TNotificationQueue to NotificationQueue.
Yedidya Feldblum [Sun, 23 Aug 2015 04:40:49 +0000 (21:40 -0700)]
Rename fixup from TNotificationQueue to NotificationQueue.

Summary: [Folly] Rename fixup from TNotificationQueue to NotificationQueue.

    hg locate 'folly/**/*.{h,cpp}' | xargs perl -pi -e 's/TNotificationQueue/NotificationQueue/g'

Reviewed By: @haijunz

Differential Revision: D2373334

9 years agostatic_function_deleter.
Yedidya Feldblum [Fri, 21 Aug 2015 22:24:06 +0000 (15:24 -0700)]
static_function_deleter.

Summary: [Folly] static_function_deleter.

So you can write this:

    using BIO_deleter = folly::static_function_deleter<BIO, &BIO_free>;
    auto buf = std::unique_ptr<BIO, BIO_deleter>(BIO_new(BIO_s_mem()));
    buf = nullptr;

In place of this:

    struct BIO_deleter {
      void operator()(BIO* bio) {
        BIO_free(bio);
      }
    };
    auto buf = std::unique_ptr<BIO, BIO_deleter>(BIO_new(BIO_s_mem()));
    buf = nullptr;

Reviewed By: @alandau

Differential Revision: D2364544

9 years agofolly: update README.md for newer Fedora
Jim Meyering [Fri, 21 Aug 2015 22:08:58 +0000 (15:08 -0700)]
folly: update README.md for newer Fedora

Summary: Running ./configure on Fedora 21 failed until I installed some
more prerequisite packages.  Add them to the list in README.md.

Reviewed By: @markisaa

Differential Revision: D2369708

9 years agoAdd a default timeout parameter to HHWheelTimer.
Maxim Georgiev [Fri, 21 Aug 2015 19:54:59 +0000 (12:54 -0700)]
Add a default timeout parameter to HHWheelTimer.

Summary: Currently HHWheelTimer requires providing an explicit timeout value every time a new timeout is scgeduled. This change adds an optional "default timeout" parameter. With this parameter set, HHWheelTimer can be used the same way as AsyncTimeoutSet. Variable timeout functionality is still available even if the default parameter is set.

Reviewed By: @djwatson

Differential Revision: D2366783

9 years agoPrevent accidental moves in filter()
Tom Jackson [Fri, 21 Aug 2015 17:28:33 +0000 (10:28 -0700)]
Prevent accidental moves in filter()

Summary: Per Boris's report.

Preparing to re-push this after fixing downstream errors.

Reviewed By: @ot

Differential Revision: D2361333

9 years agoRemove superfluous std::move calls
Jason Prado [Fri, 21 Aug 2015 01:06:23 +0000 (18:06 -0700)]
Remove superfluous std::move calls

Summary: clang-3.7 upstream warns that these calls prevent a copy elision
(-Wpessimizing-move).

Reviewed By: @​mzlee

Differential Revision: D2366951

9 years agoReplace Singleton<T>::get() with Singleton<T>::try_get and make it obsolete
Andrey Obraztsov [Thu, 20 Aug 2015 02:18:36 +0000 (19:18 -0700)]
Replace Singleton<T>::get() with Singleton<T>::try_get and make it obsolete

Summary: BREAKING CHANGE! Deprecate Singleton::get() and replace it with Singleton::try_get() that return smart pointer that allows to manage lifetime of a reference and prevents it from being deleted if the reference is still in use

Reviewed By: @chipturner

Differential Revision: D2268791

9 years agoRevert "[folly::gen] Prevent accidental moves in filter()"
Kristen Parton [Wed, 19 Aug 2015 04:53:36 +0000 (21:53 -0700)]
Revert "[folly::gen] Prevent accidental moves in filter()"

Summary: This reverts commit aee49bc8a945db9ad6c0ef6a9598ca5c44a4dc8c.

Temporarily reverting the previous diff to investigate possible downstream regression.

Reviewed By: @yfeldblum

Differential Revision: D2359864

9 years agoPrevent accidental moves in filter()
Tom Jackson [Tue, 18 Aug 2015 19:52:16 +0000 (12:52 -0700)]
Prevent accidental moves in filter()

Summary: Per Boris's report.

Reviewed By: @yfeldblum

Differential Revision: D2357299

9 years agoAdjust Format-inl.h to work with MSVC
Orvid King [Tue, 18 Aug 2015 18:53:33 +0000 (11:53 -0700)]
Adjust Format-inl.h to work with MSVC

Summary: Originally #247, which was closed before being merged, this doesn't change the behavior of the formatting function now.
Closes #297

Reviewed By: @yfeldblum

Differential Revision: D2340712

Pulled By: @sgolemon

9 years agoEnvVarSaver.
Yedidya Feldblum [Tue, 18 Aug 2015 09:09:11 +0000 (02:09 -0700)]
EnvVarSaver.

Summary: [Folly] EnvVarSaver.

    TEST(SomeBigClassTest, ChangesEnvVars) {
      folly::EnvVarSaver saver;
      setenv("USER", "root", 1);
      BigClass().doSomethingWithUser();
    }

Reviewed By: @Gownta

Differential Revision: D2354679

9 years agoRefactor HandshakeHelper and add a peeking handshake helper
Subodh Iyengar [Tue, 18 Aug 2015 04:28:08 +0000 (21:28 -0700)]
Refactor HandshakeHelper and add a peeking handshake helper

Summary: This adds support to Acceptor to be able to switch between
multiple protcols when SSL is being negotiated using MSG_PEEK.

The motivation for this is to be able to try out multiple protocols.

Reviewed By: @djwatson

Differential Revision: D2327946

9 years agoBump version to 54:0 v0.54.0
Sara Golemon [Mon, 17 Aug 2015 19:36:48 +0000 (12:36 -0700)]
Bump version to 54:0

9 years agoLimit use of hardware crc32 check to SSE 4.2
Daniel M. Weeks [Mon, 17 Aug 2015 17:40:12 +0000 (10:40 -0700)]
Limit use of hardware crc32 check to SSE 4.2

Summary: Fixes compiling crc32c function on older hardware. (I believe this problem was introduced by 7ec1fc0e0e27ed56c1d18d33af9711a17e9ec750).

Also ensures is in final library since the API suggests it should be. This should correct a number of build problems for other projects like wdt and hhvm when they are compiled using a shared folly library rather than borrowing sources at compile time.
Closes #296

Reviewed By: @yfeldblum

Differential Revision: D2340699

Pulled By: @sgolemon

9 years agoRemove `unsigned char v = static_cast<unsigned char>(v);`
Orvid King [Mon, 17 Aug 2015 17:37:08 +0000 (10:37 -0700)]
Remove `unsigned char v = static_cast<unsigned char>(v);`

Summary: MSVC spotted this very suspicious line when I was running it with /analyze, and complained about using an unitialized variable. This variable isn't used anywhere in the function, and is initializing itself with itself. I have no idea how this compiled in the first place, but apparently it does.
This removes the line in question.
Closes #295

Reviewed By: @yfeldblum, @paulbiss

Differential Revision: D2340688

Pulled By: @sgolemon

9 years agoImplement Random.cpp for MSVC
Orvid King [Mon, 17 Aug 2015 17:32:51 +0000 (10:32 -0700)]
Implement Random.cpp for MSVC

Summary: This uses `<random>` to implement it, because there is no `/dev/urandom` on Windows.
Closes #250

Reviewed By: @yfeldblum

Differential Revision: D2282887

Pulled By: @sgolemon

9 years agoExtract folly/io/async/test/RequestContextTest.cpp (from Thrift).
Yedidya Feldblum [Mon, 17 Aug 2015 07:51:43 +0000 (00:51 -0700)]
Extract folly/io/async/test/RequestContextTest.cpp (from Thrift).

Summary: [Folly] Extract folly/io/async/test/RequestContextTest.cpp (from Thrift).

Reviewed By: @haijunz

Differential Revision: D2350908

9 years agoMore descriptive message when we fail with a "Double registration of singleton" error
Dhruv Matani [Sat, 15 Aug 2015 15:37:23 +0000 (08:37 -0700)]
More descriptive message when we fail with a "Double registration of singleton" error

Summary: When we FATAL with a "Double registration of singleton" error, make it abundantly clear why such a thing could have happended so that the developer doesn't feel lost.

Reviewed By: @chipturner

Differential Revision: D2345728

9 years agoAllow AysncUDPSocket to work without SO_REUSEADDR flag
Naizhi Li [Fri, 14 Aug 2015 20:16:53 +0000 (13:16 -0700)]
Allow AysncUDPSocket to work without SO_REUSEADDR flag

Summary: Today it's hardcoded to use the flag, which could result
in some problem. We should allow callers to choose.

Reviewed By: @djwatson

Differential Revision: D2345036

9 years agoRemove dep on boost_thread
Dave Watson [Fri, 14 Aug 2015 18:56:32 +0000 (11:56 -0700)]
Remove dep on boost_thread

Summary: Remove recently introduced dependency on boost_thread by breaking EventBaseLocal off to its own rule

Introduced in D2203063

Reviewed By: @​mzlee

Differential Revision: D2301943

9 years agoFix AtomicHashArray::defaultConfig SIOF.
Yedidya Feldblum [Fri, 14 Aug 2015 08:57:38 +0000 (01:57 -0700)]
Fix AtomicHashArray::defaultConfig SIOF.

Summary: [Folly] Fix AtomicHashArray::defaultConfig SIOF.

May fix https://github.com/facebook/folly/issues/300.

Reviewed By: @paulbiss

Differential Revision: D2343162

9 years agoSet IPV6_V6ONLY in folly::AsyncUDPServerSocket
Peter Griess [Thu, 13 Aug 2015 17:19:09 +0000 (10:19 -0700)]
Set IPV6_V6ONLY in folly::AsyncUDPServerSocket

Summary: - This mirrors the behavior in AsyncServerSocket

Reviewed By: @yfeldblum

Differential Revision: D2338665

9 years agoDetect clang in folly/Portability.h
Yang Chi [Thu, 13 Aug 2015 14:58:03 +0000 (07:58 -0700)]
Detect clang in folly/Portability.h

Summary: The fix in D2283221 was specific to a bug in gcc 4.8 but the macro was failing
to filter out clang compilers.

Reviewed By: @yfeldblum

Differential Revision: D2340160

9 years agoDon't warn if pthread_atfork isn't avaliable on MSVC
Orvid King [Wed, 12 Aug 2015 20:40:33 +0000 (13:40 -0700)]
Don't warn if pthread_atfork isn't avaliable on MSVC

Summary: Because we don't even have `fork` to begin with under MSVC.
Closes #278

Reviewed By: @yfeldblum

Differential Revision: D2306518

Pulled By: @sgolemon

9 years agoAdd MSVC support to MaxAlign
Orvid King [Wed, 12 Aug 2015 20:39:29 +0000 (13:39 -0700)]
Add MSVC support to MaxAlign

Summary: This adds MSVC support to the detection of `MaxAlign` in `Portability.h`.
Closes #256

Reviewed By: @yfeldblum

Differential Revision: D2283221

Pulled By: @sgolemon

9 years agoHandle some scoping issues in Conv.h under MSVC
Orvid King [Wed, 12 Aug 2015 20:37:02 +0000 (13:37 -0700)]
Handle some scoping issues in Conv.h under MSVC

Summary: No idea why these are the only two places it complains about, but it does.
This just explicitly scopes them.
Closes #253

Reviewed By: @yfeldblum

Differential Revision: D2282985

Pulled By: @sgolemon

9 years agoCodeMod apache::thrift::transport::TSocketAddress to folly::SocketAddress.
Yedidya Feldblum [Wed, 12 Aug 2015 20:29:16 +0000 (13:29 -0700)]
CodeMod apache::thrift::transport::TSocketAddress to folly::SocketAddress.

Summary: [Folly] CodeMod apache::thrift::transport::TSocketAddress to folly::SocketAddress.

    yes | codemod --extensions h,tcc,cpp '^#include [<"]thrift/lib/cpp/transport/TSocketAddress\.h[>"]$' '#include <folly/SocketAddress.h>'
    yes | codemod --extensions h,tcc '\b(((apache::)?thrift::)?transport::)?TSocketAddress\b' 'folly::SocketAddress'
    yes | codemod --extensions cpp '^using apache::thrift::transport::TSocketAddress;$' 'using folly::SocketAddress;'
    yes | codemod --file-list "$(git ls-files "**/*.cpp" | xargs grep -P '^using (namespace folly|folly::SocketAddress);$' | cut -d: -f1 | paste -s -d,)" '\b(((apache::)?thrift::)?transport::)?TSocketAddress\b' 'SocketAddress'
    yes | codemod --extensions cpp '\b(((apache::)?thrift::)?transport::)?TSocketAddress\b' 'folly::SocketAddress'
    yes | codemod --extensions h,tcc,cpp -m '^\s*typedef folly::SocketAddress folly::SocketAddress;\n' ''
    yes | codemod --file-list thrift/lib/cpp/Makefile.am -m '^\s*transport/TSocketAddress\.h \\\n' ''
    rm thrift/lib/cpp/transport/TSocketAddress.h

Reviewed By: @Invalid auth token., @​luk

Differential Revision: D2325523

9 years agoDisable VDSO on MSVC
Orvid King [Wed, 12 Aug 2015 20:12:46 +0000 (13:12 -0700)]
Disable VDSO on MSVC

Summary: MSVC will never be able to load VDSO, and doesn't even have dlopen, so just return `nullptr`, and let the fallback mechanisms handle it from there.
Closes #282

Reviewed By: @yfeldblum

Differential Revision: D2307461

Pulled By: @sgolemon

9 years ago(Wangle) Use perfect forwarding for LambdaBufHelper
Hannes Roth [Tue, 11 Aug 2015 23:11:59 +0000 (16:11 -0700)]
(Wangle) Use perfect forwarding for LambdaBufHelper

Summary: Perfect forwarding only works if the function is templated on the same type, not if the type is a class template.

Discovered by @lbrandy.

Reviewed By: @yfeldblum, @lbrandy

Differential Revision: D2333005

9 years ago(Wangle) Align lambdaBuf_
Hannes Roth [Tue, 11 Aug 2015 23:11:11 +0000 (16:11 -0700)]
(Wangle) Align lambdaBuf_

Summary: Not aligning `lambdaBuf_` can lead to unaligned reads, which can be a problem on some platforms.

We use `lambdaBuf_` to store a type of up to `lambdaBufSize`, so aligning it to that should always be safe.

Reviewed By: @alexshap

Differential Revision: D2319347

9 years agoEmplacement in folly::padded::Adaptor, if the adapted class allows.
Yedidya Feldblum [Tue, 11 Aug 2015 18:47:39 +0000 (11:47 -0700)]
Emplacement in folly::padded::Adaptor, if the adapted class allows.

Summary: [Folly] Emplacement in folly::padded::Adaptor, if the adapted class allows.

Reviewed By: @Gownta

Differential Revision: D2157162

9 years agoAdded futures helpers times, when, and whileDo
Noel Sardana [Tue, 11 Aug 2015 18:13:29 +0000 (11:13 -0700)]
Added futures helpers times, when, and whileDo

Summary: Implemented the given functions by porting similar functionality from the twitter Future utility.

Reviewed By: @​hannesr

Differential Revision: D2303701

9 years agoBump version to 53:0 v0.53.0
Sara Golemon [Mon, 10 Aug 2015 20:18:38 +0000 (13:18 -0700)]
Bump version to 53:0

9 years agoSupport dynamic field width in folly::format()
Brett Simmers [Sun, 9 Aug 2015 22:41:15 +0000 (15:41 -0700)]
Support dynamic field width in folly::format()

Summary: I added this to support logging with varying indentation levels, but
it could also be useful in other situations. Examples are in the
test/documentation.

Reviewed By: @tudor

Differential Revision: D2322206

9 years agoAvoid incorrect constexpr in folly/AtomicHashArray.h.
Yedidya Feldblum [Fri, 7 Aug 2015 19:34:34 +0000 (12:34 -0700)]
Avoid incorrect constexpr in folly/AtomicHashArray.h.

Summary: [Folly] Avoid incorrect constexpr in folly/AtomicHashArray.h.

It's actually not transitively constexpr, because it uses const values that are not themselves constexpr. Depending on the compiler, it could theoretically fail to build.

Reviewed By: @Gownta

Differential Revision: D2322143

9 years agoEasy: disable guard pages by default
Anton Likhtarov [Thu, 6 Aug 2015 22:24:56 +0000 (15:24 -0700)]
Easy: disable guard pages by default

Summary: Mcrouter still enables these by default.  Tracking down a perf regression in another code path that uses fibers.

Reviewed By: @JohnRambo

Differential Revision: D2320772

9 years agoMake Core.size test portable
Alexander Shaposhnikov [Thu, 6 Aug 2015 02:25:51 +0000 (19:25 -0700)]
Make Core.size test portable

Summary: Add a golden struct for checking the size of Core.
It makes this test pass on OSX
(now failing because of the different size of std::function).

Reviewed By: @​hannesr

Differential Revision: D2315429

9 years agoScopedEventBaseThread should support an EventBaseManager context.
Yedidya Feldblum [Wed, 5 Aug 2015 21:44:14 +0000 (14:44 -0700)]
ScopedEventBaseThread should support an EventBaseManager context.

Summary: [Folly] ScopedEventBaseThread should support an EventBaseManager context.

Reviewed By: @Gownta

Differential Revision: D2314049

9 years agoUse static const keys in AtomicHashArray::Config.
Yedidya Feldblum [Wed, 5 Aug 2015 18:48:13 +0000 (11:48 -0700)]
Use static const keys in AtomicHashArray::Config.

Summary: [Folly] Use static const keys in AtomicHashArray::Config.

From https://github.com/facebook/folly/pull/264/, MSVC may have a hard time with certain expressions. D2284130 factored them out as `static constexpr` members, but Clang had a hard time with that in HPHP. This adds a test case that triggers the same failure to the Folly build. Not quite sure how this impacts MSVC though.

Reviewed By: @Gownta

Differential Revision: D2304346

9 years agoUse .string() not .native() in TestUtil.cpp
Orvid King [Tue, 4 Aug 2015 23:02:44 +0000 (16:02 -0700)]
Use .string() not .native() in TestUtil.cpp

Summary: Because `.native()` returns a wide string on MSVC, but a normal string is expected by the rest of the code.
Closes #283

Reviewed By: @yfeldblum

Differential Revision: D2307488

Pulled By: @sgolemon

9 years agoMake some types and constexprs public
Orvid King [Tue, 4 Aug 2015 23:01:48 +0000 (16:01 -0700)]
Make some types and constexprs public

Summary: MSVC has some odd accessibility rules,
so this makes a couple of things public rather than private.
Closes #284

Reviewed By: @yfeldblum

Differential Revision: D2307578

Pulled By: @sgolemon

9 years agomake RetryingTest more robust
Nathan Bronson [Tue, 4 Aug 2015 21:02:33 +0000 (14:02 -0700)]
make RetryingTest more robust

Summary: Make RetryingTest more robust by giving it multiple chances to
meeting timing criteria.

Reviewed By: @yfeldblum

Differential Revision: D2306245

9 years agoRefactor extract FOLLY_SYNCHRONIZED_HAVE_TIMED_MUTEX.
Yedidya Feldblum [Tue, 4 Aug 2015 16:54:07 +0000 (09:54 -0700)]
Refactor extract FOLLY_SYNCHRONIZED_HAVE_TIMED_MUTEX.

Summary: [Folly] Refactor extract FOLLY_SYNCHRONIZED_HAVE_TIMED_MUTEX.

The same complex check is done in two places. Ick. Extract it to a single place.

Reviewed By: @​mzlee

Differential Revision: D2302885

9 years agoFix a bad bug in folly::ThreadLocal (incorrect using of pthread)
Alexander Shaposhnikov [Tue, 4 Aug 2015 06:24:18 +0000 (23:24 -0700)]
Fix a bad bug in folly::ThreadLocal (incorrect using of pthread)

Summary: Fix incorrect using of pthread in folly::ThreadLocal.

The root of the trouble (see man pthread_key_create):
"At thread exit, if a key value has a non-NULL destructor pointer,
and the thread has a non-NULL value associated with that key,
the value of the key is set to NULL, and then the function pointed to is called
with the previously associated value as its sole argument."

At thread exit we need to recover the thread-specific threadEntry
otherwise the subsequent calls of getThreadEntry may recreate it
(what actually DOES  happen in the test ThreadLocalPtr.CreateOnThreadExit)
and the newly created threadEntry will "leak". It will live longer than the corresponding
thread violating the internal invariant of StaticMeta and also it will break
the code of the method onThreadExit. In particular this bug causes the failure
of the test ThreadLocalPtr.CreateOnThreadExit on OSX.

Reviewed By: @lbrandy

Differential Revision: D2304950

9 years agoAdd MSVC support to futures/Deprecated.h
Orvid King [Mon, 3 Aug 2015 19:36:24 +0000 (12:36 -0700)]
Add MSVC support to futures/Deprecated.h

Summary: It was originally unconditionally useing `__attribute__` syntax, so this makes it conditionally use the `__declspec` syntax.
Closes #268

Reviewed By: @yfeldblum

Differential Revision: D2283909

Pulled By: @sgolemon

9 years agoFix ASAN failure in folly/io/async/test/NotificationQueueTest.cpp.
Yedidya Feldblum [Sun, 2 Aug 2015 23:15:04 +0000 (16:15 -0700)]
Fix ASAN failure in folly/io/async/test/NotificationQueueTest.cpp.

Summary: [Folly] Fix ASAN failure in folly/io/async/test/NotificationQueueTest.cpp.

Reviewed By: @djwatson

Differential Revision: D2299112

9 years agoRevert "Use constexpr initializers for AtomicHashArray Config"
Brett Simmers [Sat, 1 Aug 2015 20:39:19 +0000 (13:39 -0700)]
Revert "Use constexpr initializers for AtomicHashArray Config"

Summary: D2284130 broke the HHVM clang build.

Reviewed By: @mxw

Differential Revision: D2303914

9 years agoNot to use EventBaseLocal on mobile
Michael Lee [Fri, 31 Jul 2015 22:51:59 +0000 (15:51 -0700)]
Not to use EventBaseLocal on mobile

Summary: Temp remove EventBaseLocal on mobile.

Reviewed By: @djwatson

Differential Revision: D2302322

9 years agoNo std::recursive_timed_mutex and std::timed_mutex.
Michael Lee [Fri, 31 Jul 2015 21:06:17 +0000 (14:06 -0700)]
No std::recursive_timed_mutex and std::timed_mutex.

Summary: Do not use these if __ANDROID__ is defined as well.

Reviewed By: @​yangchi

Differential Revision: D2301782

9 years agoFix a parse error in detail/ThreadLocalDetail.h under MSVC
Orvid King [Mon, 27 Jul 2015 21:41:06 +0000 (14:41 -0700)]
Fix a parse error in detail/ThreadLocalDetail.h under MSVC

Summary: I have no idea why this specific declaration would error, or if there is a difference in meaning, but this fixes MSVC's absurd parser error.
Closes #277

Reviewed By: @yfeldblum

Differential Revision: D2284096

9 years agoGeneralize FOLLY_SPIN_WAIT to use Portability methods
Orvid King [Fri, 31 Jul 2015 19:43:41 +0000 (12:43 -0700)]
Generalize FOLLY_SPIN_WAIT to use Portability methods

Summary: Improves MSVC support.
Closes #274

Note that this diff has been heavily modified from @Orvid's original PR by @yfeldblum and @sgolemon

Reviewed By: @yfeldblum

Differential Revision: D2284035

Pulled By: @sgolemon

9 years agoUse constexpr initializers for AtomicHashArray Config
Orvid King [Fri, 31 Jul 2015 19:40:07 +0000 (12:40 -0700)]
Use constexpr initializers for AtomicHashArray Config

Summary: Closes #264

Modified by @sgolemon from the original PR to declare MSVC2015-final as the official minimum version, making the defines in the original PR unnecessary.

Reviewed By: @yfeldblum

Differential Revision: D2284130

Pulled By: @sgolemon

9 years agoOverload on dynamic object reference type.
Nick Terrell [Fri, 31 Jul 2015 16:57:00 +0000 (09:57 -0700)]
Overload on dynamic object reference type.

Summary: There are a bunch of methods in `folly::dynamic` that return a
reference to a sub-object, e.g. `getString()`.
These methods are a bit unsafe because it allows you to write code with dangling
references when the `folly::dynamic` object is an rvalue:

  auto& obj = parse_json(some_string).at("key");

However, the bigger win is that when we have an rvalue `folly::dynamic`, such as
returned by `getDefault(...)`, we can move the sub-object out:

  auto obj = parse_json(some_string).at("key");
  auto str = obj.getDefault("another-key", "").getString();

In the first line, the subobject is copied out when it could be safely moved out.
In the second line `getDefault(...)` copies the dynamic sub-object out, and then
`getString()` copies the string out, when the string could be moved.

Also in the case of `getDefault()` being called on a rvalue, we can move the
sub-object out.

Reviewed By: @marcinpe

Differential Revision: D2267588

9 years agoDelayedDestruction cleanup
Sophia Wang [Fri, 31 Jul 2015 16:32:55 +0000 (09:32 -0700)]
DelayedDestruction cleanup

Summary: remove unnecessary stuff

Reviewed By: @siyengar

Differential Revision: D2284095

9 years agoAdd accessor to estimate a FiberManager's run queue size
Brian Watling [Fri, 31 Jul 2015 15:52:36 +0000 (08:52 -0700)]
Add accessor to estimate a FiberManager's run queue size

Summary: Add accessor to estimate a FiberManager's run queue size

Reviewed By: @sarangbh

Differential Revision: D2293367

9 years agofolly: fix another test running under buck
Andrew Gallagher [Fri, 31 Jul 2015 10:31:44 +0000 (03:31 -0700)]
folly: fix another test running under buck

Reviewed By: @yfeldblum

Differential Revision: D2300047

9 years agofolly: fix tests running under buck (w/ clang and dynamic linking)
Andrew Gallagher [Fri, 31 Jul 2015 10:10:03 +0000 (03:10 -0700)]
folly: fix tests running under buck (w/ clang and dynamic linking)

Summary: Various fixes to get tests passing using buck's dev mode.

Reviewed By: @yfeldblum

Differential Revision: D2299981

9 years agofutures::retrying.
Yedidya Feldblum [Fri, 31 Jul 2015 03:10:19 +0000 (20:10 -0700)]
futures::retrying.

Summary: [Folly] futures::retrying.

Reviewed By: @fugalh

Differential Revision: D2201630