1. 05 Apr, 2018 1 commit
    • Orvid King's avatar
      Fix build under MSVC 2015 Update 3 · b3141b5d
      Orvid King authored
      Summary: MSVC 2015 Update 3 can't parse these with curly-brace init'd, so swap the assignment. The result is the exact same.
      
      Reviewed By: simpkins
      
      Differential Revision: D7508756
      
      fbshipit-source-id: 5e60607f978a87ae8bfed22086d1dccef15759ac
      b3141b5d
  2. 04 Apr, 2018 10 commits
    • Brian Gesiak's avatar
      Fix Coro.Sleep test for opt builds · db453a5b
      Brian Gesiak authored
      Summary:
      Optimized builds of //folly/experimental/coro test Coro.Sleep
      would almost always fail because the compiler would generate
      code that would only sleep for 0.98 seconds. Perform some
      simple rounding in order to ignore slight optimizations like
      these.
      
      Reviewed By: wqfish
      
      Differential Revision: D7496416
      
      fbshipit-source-id: f81ff30922fbf3e5d2086fde50f4a469bdf72e51
      db453a5b
    • Nathan Bronson's avatar
      document transferrability of F14HashToken between instances · dad687f7
      Nathan Bronson authored
      Summary:
      F14HashToken encapsulates the work of hash_function(), which
      is the same across F14 containers that have the same key_type and equal
      hash_function() (same type and operator==).  This diff adds documentation
      that callers may rely on this fact, which means they can use this feature
      to reduce work if a single key is access in multiple maps/sets.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: shixiao
      
      Differential Revision: D7506737
      
      fbshipit-source-id: 321032d619434501b1e0544962e54732bfc4c970
      dad687f7
    • Janusz Kudelka's avatar
      sorted_vector_types use the underlying container value_type · 9a31b9e8
      Janusz Kudelka authored
      Summary:
      Allow the user to give their own pair implementation. This allows
      using a packed pair.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7504521
      
      fbshipit-source-id: 11888594b8b3ef3f530ebd95b8006ef6f5afbc65
      9a31b9e8
    • Tom Jackson's avatar
      Pretty Big Numbers · 2caf3abc
      Tom Jackson authored
      Summary: Terabytes aren't Web Scale.
      
      Reviewed By: ot, philippv, luciang
      
      Differential Revision: D7479752
      
      fbshipit-source-id: fd353933e642b1ee024c28107c8fcb6a55fe755e
      2caf3abc
    • Tom Jackson's avatar
      double_conversion eats the 'e' in '123e' · 29fd00d2
      Tom Jackson authored
      Summary: Until I do a PR on `double_conversion`, we need to work around this by catching the trailing 'e' case.
      
      Reviewed By: luciang
      
      Differential Revision: D7481130
      
      fbshipit-source-id: 2734dbe834e6cd69c6dfe41d6b4e9a7a548a7da8
      29fd00d2
    • Jun Li (Wormhole)'s avatar
      Cancel immediate read callback when socket has error · ed0d101c
      Jun Li (Wormhole) authored
      Summary:
      When `startFail()` is called, it sets the state to StateEnum::ERROR.
      There is a chance that immediate read callback is scheduled to run in
      next event loop. The callback calls handleRead() then triggers
      `assert(state_ == StateEnum::ESTABLISHED)` in `AsyncSokcet::handleRead`.
      
      Cancel any immediate read callback when startFail is called.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7051956
      
      fbshipit-source-id: 0d6693d851b272355a4f36ab8d001969fa47750e
      ed0d101c
    • Brian Gesiak's avatar
      Reduce recursion, for ASAN at -O0 · f6ca0ac0
      Brian Gesiak authored
      Summary:
      At `-O0` each coroutine call results in a heap allocation. This
      combined with the increased memory pressure when using ASAN
      results in an invalid memory access beyond the maximum address.
      Avoid the problem by limiting the recursion to 5,000 frames deep,
      instead of 10,000. This still fulfills the intent of the test,
      but without pushing the limits of ASAN.
      
      Reviewed By: wqfish
      
      Differential Revision: D7503976
      
      fbshipit-source-id: 7850a9d9db23328d42c25b74a1290caa7773e6a7
      f6ca0ac0
    • Andrii Grynenko's avatar
      Remove sendRequestSync from RSocketClientChannel · 9d98a85d
      Andrii Grynenko authored
      Summary: sendRequestSync should only be implemented by channels, which own threads looping EventBases.
      
      Reviewed By: phoad
      
      Differential Revision: D7464392
      
      fbshipit-source-id: bde6edc85438bb406592291330869972f88c787a
      9d98a85d
    • Nathan Bronson's avatar
      make F14 prehash token default constructible · e5a6b518
      Nathan Bronson authored
      Summary:
      Using an array of prehash tokens is quite inconvenient without
      the ability to default construct them.
      
      Reviewed By: shixiao
      
      Differential Revision: D7490113
      
      fbshipit-source-id: f802a7dc6dc2c603c4682e5f384d9f135220cd54
      e5a6b518
    • Alex Wang's avatar
      Remove std:: from index_sequence in Synchronized ctor · 68cb50c5
      Alex Wang authored
      Summary:
      Apple Clang 9 (clang-900.0.39.2) on macOS 10.13.3, when configured with
      `FOLLY_USE_LIBCPP`, fails to build `SynchronizedTest.cpp` with the following
      error:
      
          In file included from /Users/awang/code/folly/folly/test/SynchronizedTest.cpp:20:
          /Users/awang/code/folly/folly/Synchronized.h:511:9: error: no matching constructor for
                initialization of 'folly::Synchronized<int, NonDefaultConstructibleMutex>'
                : Synchronized{std::piecewise_construct,
                  ^           ~~~~~~~~~~~~~~~~~~~~~~~~~~
          /Users/awang/code/folly/folly/test/SynchronizedTest.cpp:539:25: note: in instantiation
                of function template specialization 'folly::Synchronized<int,
                NonDefaultConstructibleMutex>::Synchronized<int &&, int &&>' requested here
            auto&& synchronized = folly::Synchronized<int, NonDefaultConstructibleMutex>{
                                  ^
          /Users/awang/code/folly/folly/Synchronized.h:499:12: note: candidate constructor not
                viable: no known conversion from 'const std::__1::piecewise_construct_t' to
                'in_place_t' (aka 'folly::in_place_tag (&)(folly::in_place_tag)') for 1st argument
            explicit Synchronized(in_place_t, Args&&... args)
                     ^
          /Users/awang/code/folly/folly/Synchronized.h:764:3: note: candidate template ignored:
                could not match 'std::__1::integer_sequence' against 'folly::integer_sequence'
            Synchronized(
            ^
          <other constructors not viable due to number-of-parameter mismatches>
      
      The proximate cause of the error is that `make_index_sequence` is
      generating a `folly::index_sequence`, but the delegatee constructor only
      accepts `std::index_sequence`.
      
      Changing the delegatee constructor to take an unqualified `index_sequence`
      solves the problem, since the return type for an unqualified
      `make_index_sequence` should be the same as the unqualified
      `index_sequence`.
      
      This appears to have been introduced in
      8581e9e0.
      
      Clang ends up using the Folly implementation of
      `make_integer_sequence` because `__cpp_lib_integer_sequence` is
      still not defined, even though `integer_sequence` support was added
      to libc++ way back in mid-2013, in revision 185343. There is a bug open
       on the LLVM bug tracker (#18584 [1]) to add the
      `__cpp_lib_integer_sequence` and other feature test macros,
      but the last activity on it was in late 2014. This results in
      the compiler successfully finding the definition for `std::index_sequence`
      (unlike what would happen with C++11 compilers), but using the folly
      implementation for `make_index_sequence`.
      
      Qualified `std::index_sequence` is used in a few other places, but `std::`
      was not removed from those usages because they reside in functions that
      have C++14 features that would prevent a C++11 compiler from compiling
      them at all, let alone with a `std::` v.s. `folly::`
      mismatch:
      
          - folly/test/FormatBenchmark.cpp
              - decltype(auto) is used for format20Numbers()
          - folly/container/Foreach-inl.h
              - decltype(auto) and generic lambdas are used in a few of the
                for_each_range_impl() overloads
              - decltype(auto) is used in some of the impl() overloads
              - decltype(auto) is used as the return type for fetch()
          - folly/container/Iterator.h
              - decltype(auto) is used as the get_emplace_arg() and unwrap_emplace_arg() return type
      
      A different way of solving the problem would be to add a special case
      for Clang to the `integer_sequence` check, similar to what is done for
      MSVC, but that seemed like partially papering over the problem. The best
      solution would be to get those feature macros into libc++, but that
      wouldn't help for already-released versions of LLVM.
      
          [0]: https://blogs.msdn.microsoft.com/vcblog/2014/06/06/c14-stl-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1/
          [1]: https://bugs.llvm.org/show_bug.cgi?id=18584
      Closes https://github.com/facebook/folly/pull/810
      
      Reviewed By: aary
      
      Differential Revision: D7482813
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 36310acbc227bfe646d6fad877a406b8d57407e5
      68cb50c5
  3. 03 Apr, 2018 4 commits
    • Orvid King's avatar
      Always use folly::index_sequence · ec7690d7
      Orvid King authored
      Summary:
      Continuing from D7482813, ensure everywhere in folly is using the folly versions of integer and index sequences.
      Also implement index_sequence_for and use it.
      
      Reviewed By: aary
      
      Differential Revision: D7490483
      
      fbshipit-source-id: 082209dd6c6ca11f67b38dbe4529d46e9dce57ce
      ec7690d7
    • Steve O'Brien's avatar
      folly/String: split out `UTF8StringPiece` · 92320e04
      Steve O'Brien authored
      Summary:
      This has functionality not overlapping with `FBString` or `folly::fbstring` or `folly::StringPiece`; and a pretty expensive dependency on `boost/regex`.
      
      Much of the thrift-gen `_types.h` code comes from this inclusion chain:
      
      * `_types.h` uses strings (for `str` fields in thrift structs); these are represented by `folly::fbstring`, from...
      * `folly/String.h` includes `FBString.h` and other things to support string-related stuff; simple enough.  But it has a class `UTF8StringPiece`, which uses an iterator, from Boost called `boost::u8_to_u32_iterator<char const *>`.  So then we have...
      * `boost/regex/pending/unicode_iterator.hpp` includes tons of things in the usual boost header avalanche: iterator facades, lots of `mpl` code.
      
      Reviewed By: meyering
      
      Differential Revision: D7373577
      
      fbshipit-source-id: efdb920b6fe8c7b7c57d3becf2bf0710975fcf73
      92320e04
    • Xiao Shi's avatar
      fix erase use-after-free in F14Vector containers · d22d402e
      Xiao Shi authored
      Summary:
      Upon `erase`, F14 vector containers destroys the value and erases the item
      (i.e., index into the `values_` vector) from the underlying hashtable. However,
      the item still needs to be hashable when erasing from the hashtable, so we have
      to destroy the value _afterwards_.
      
      This diff fixes the bug.
      
      There are a couple of reasons that this was previous undetected / did not cause
      a problem:
        * for POD types, `allocator_traits::destroy` is a no-op.
        * this code path is only hit if the chunk of the destroyed item has hosted
          overflowed items
        * the use was immediately after free
        * our test coverage did not have vector policy + non-SSO string keys
      
      Reviewed By: nbronson
      
      Differential Revision: D7488050
      
      fbshipit-source-id: ea29e875a0c7a39b8deed40a15777a6983438836
      d22d402e
    • Anton Likhtarov's avatar
      folly::settings basic functionality · 3cec1c6b
      Anton Likhtarov authored
      Summary:
      A library that provides gflags-like functionality, with the addition of:
      - Threadsafe read/writes for all flags
      - Arbitrary C++ types
      - No declare/define split, all setting definitions are declaration and are safe to place in headers
      - Runtime introspection of all flags
      - Compile time and runtime collision checks
      - Namespaces per project
      
      Down the road:
      - Overlay support (change a set of settings based on some context)
      - Construct arbitrary user types from string
      - Support multiple library instances with distinct settings in a single process
      - Callbacks on setting updates
      
      Reviewed By: aary, mnv104
      
      Differential Revision: D6217956
      
      fbshipit-source-id: 7c03d79c7601ce7b266df78e62b7193712d8331e
      3cec1c6b
  4. 02 Apr, 2018 1 commit
  5. 01 Apr, 2018 1 commit
    • Andrew Gallagher's avatar
      folly/Singleton: remove use of `link_whole` · 7c996f43
      Andrew Gallagher authored
      Summary:
      We used `link_whole` to make sure the `setStackTraceGetter` constructor is
      always linked when using Singleton's to setup symbolizer for stack traces.
      However, using `link_whole` means we always link in the singleton library, even
      if it's never used.
      
      This diff merges `SingletonStackTrace.cpp` into `Singleton.cpp` to avoid the
      need for `link_whole` and to link the former if and only if we use the latter.
      
      Reviewed By: pixelb
      
      Differential Revision: D7230733
      
      fbshipit-source-id: de9be51a4eefee201563523d25800ab19ea777e3
      7c996f43
  6. 31 Mar, 2018 3 commits
    • Orvid King's avatar
      Explicitly mark the pthread forward declarations as extern C · c73cbb82
      Orvid King authored
      Summary: These were being mangled as C++ functions rather than C functions.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7462668
      
      fbshipit-source-id: e4e83e16aafad3d888599dd78bdbb4ac2711ad7f
      c73cbb82
    • Orvid King's avatar
      Drop unused exception local · 9f878bfe
      Orvid King authored
      Summary: It's unused, remove it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7462683
      
      fbshipit-source-id: 604c5691d69f2576c83c25350d29515efbc77a7b
      9f878bfe
    • Orvid King's avatar
      Fix build of chrono/Conv.h under MSVC · 1b2d5ef8
      Orvid King authored
      Summary: `timespec` is defined in `sys/time.h`, so don't rely on `<chrono>` including it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7462731
      
      fbshipit-source-id: 590954e2230a0da322e2f5eb966bb49b18aa56f7
      1b2d5ef8
  7. 30 Mar, 2018 3 commits
  8. 29 Mar, 2018 4 commits
    • Dave Watson's avatar
      Remove batch · 1e71e4c0
      Dave Watson authored
      Summary:
      Remove hazptr_obj_batch feature.  Not required after D7429494:
      
      After timer runs out, *all* thread caches are cleaned up, not just the current one,
      so it should be safe to push anything to local thread cache, even if thread isn't used often,
      as long as *some* thread is used.
      
      Reviewed By: magedm
      
      Differential Revision: D7433978
      
      fbshipit-source-id: 01508fd199fcd267550efc08d2695b53f1569c84
      1e71e4c0
    • Dave Watson's avatar
      Timed reclamation · d211a58c
      Dave Watson authored
      Summary:
      Continued reclamation issues from lots of UnboundedQueue batches, or lots of threads.
      
      In addition to the current number of outstanding objects, cleanup *all threads* on a timer
      basis.
      
      Reviewed By: magedm
      
      Differential Revision: D7429494
      
      fbshipit-source-id: 7e9bdae9ae49927ca0b6e3f24963a4d4b23a4f0b
      d211a58c
    • Boris Burkov's avatar
      add StrictlyOrderable interface · a8e02287
      Boris Burkov authored
      Summary:
      I would like to store a folly::Poly I'm defining in an ordered
      container (boost::containers::flat_set). While I could implement operator<
      for exactly my type, it seems nicer to add it as another interface all
      Poly users can reuse.
      
      Reviewed By: ericniebler
      
      Differential Revision: D7415861
      
      fbshipit-source-id: 1912eaa009acea5c243db3e14fc0715a0829f251
      a8e02287
    • Yedidya Feldblum's avatar
      Move Replaceable mixin param defaults to base template · 87305387
      Yedidya Feldblum authored
      Summary:
      [Replaceable] Move `Replaceable` mixin param defaults to base template.
      
      Saves a few lines overall.
      
      Reviewed By: WillerZ
      
      Differential Revision: D7421561
      
      fbshipit-source-id: f56d1ffdd081b0a8a20cb7a492f06c9647445782
      87305387
  9. 28 Mar, 2018 7 commits
    • Erik Hortsch's avatar
      Remove check for uncaught exception · f2b80e52
      Erik Hortsch authored
      Summary: This check is causing some issues in github commits. Figuring out exactly which versions of 4.9 have the bug is a pain, so let's just get rid of it. See D6695110 for more context.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7431713
      
      fbshipit-source-id: 17d1b025edf52592495c5f69c5a15025b33b3895
      f2b80e52
    • Orvid King's avatar
      Support setThreadName on Windows · 1674ee82
      Orvid King authored
      Summary: Windows doesn't have a nice function to do this, so we have to do it ourself, throwing the right exception with a struct that no public header defines, because Windows.
      
      Reviewed By: akrieger
      
      Differential Revision: D5100900
      
      fbshipit-source-id: 4f6840e50c5c1aef36adade098739201c97b9af7
      1674ee82
    • Orvid King's avatar
      Remove FOLLY_DEPRECATED entirely · 511ddcc6
      Orvid King authored
      Summary: Actually remove it. All uses of it (outside of thrift) were removed in the previous diff.
      
      Reviewed By: ot
      
      Differential Revision: D7422614
      
      fbshipit-source-id: 6a59c34b3cbc0ee7c50f8cbf8c5e641352f2db1a
      511ddcc6
    • Joe Loser's avatar
      Fix F14TestUtil printing · 04ac9609
      Joe Loser authored
      Summary:
      There is a missing `#include <ostream>`.  Add it.
      Closes https://github.com/facebook/folly/pull/807
      
      Reviewed By: shixiao
      
      Differential Revision: D7425693
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: cb645f7da94ca5fe5f8d4314b99621557109f360
      04ac9609
    • Jason Fried's avatar
      Safer Clients · cf504d17
      Jason Fried authored
      Summary:
      Python is considered a Safe Enivronment, where things like aborts and segfaults
      can not happen.
      
      If clients where used outside of "async with" we use to print a error message
      and then C++ would abort.
      
      This fix makes sure C++ no longer aborts but we still print the message
      that the "async with" should be used.
      
      All futures are now shielded so cancel will not produce strange exceptions when
      C++ decides to fullfill the canceled future.
      
      Also we now pass a tuple of client and future to all bridgeFutureWith calls.
      This has the affect of making sure the client can not GC before the future
      is completed.
      
      We now use a unique_ptr for RequestChannel so there is no more race to delete
      the shared pointer.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7389380
      
      fbshipit-source-id: 6a3ca019190907e726c550c9b379a2a2610d0b0a
      cf504d17
    • Igor Sugak's avatar
      fix -Wextra-semi exposed by the latest clang · 3daa8962
      Igor Sugak authored
      Summary: `-Wextra-semi` became more strict. This fixes folly build with the latest clang.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7359992
      
      fbshipit-source-id: ce7caf05aa536f35e9af4ed33a86072afd09f387
      3daa8962
    • Xiao Shi's avatar
      fix default hasher · dc45f4c0
      Xiao Shi authored
      Summary: Revert changes accidentally slipped into D7405057.
      
      Reviewed By: yfeldblum, Orvid
      
      Differential Revision: D7419691
      
      fbshipit-source-id: ab9bea3393eb33aa19b3009263a53ac91e30692c
      dc45f4c0
  10. 27 Mar, 2018 5 commits
    • Dave Watson's avatar
      Remove hazptr_priv_list · b403ae13
      Dave Watson authored
      Summary: folly::ThreadLocal already maintains this list for us.  Add an accessor in folly::SingletonThreadLocal, and use it
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7264843
      
      fbshipit-source-id: 45278f7a074e50b96b451437c327de5d6713363a
      b403ae13
    • Yedidya Feldblum's avatar
      Fix retrying when the policy throws · 40b40a1d
      Yedidya Feldblum authored
      Summary: [Folly] Fix `retrying` when the policy throws.
      
      Differential Revision: D7392852
      
      fbshipit-source-id: 3cb1d19697f111bf19047dc382056b39ad241035
      40b40a1d
    • Orvid King's avatar
      Eliminate uses of FOLLY_DEPRECATED · f9326ade
      Orvid King authored
      Summary: Every compiler we currently support supports the `[[deprecated]]` attribute, so use that instead.
      
      Reviewed By: yfeldblum, ot
      
      Differential Revision: D7405895
      
      fbshipit-source-id: 541c537cd7a0be0d901378c0e79f5cd0f55b85e3
      f9326ade
    • Andrii Grynenko's avatar
      Improve SequencedExecutor documentation · 5d09018c
      Andrii Grynenko authored
      Summary: Adding more details to the documentation and a unit test which checks various executors.
      
      Reviewed By: yfeldblum, djwatson
      
      Differential Revision: D7410461
      
      fbshipit-source-id: 2ae6926f43862ec45a06ff76dbacae681fe6feaa
      5d09018c
    • Andrii Grynenko's avatar
      Implement coro::Future -> Future conversion · 426eb685
      Andrii Grynenko authored
      Reviewed By: wqfish
      
      Differential Revision: D7205067
      
      fbshipit-source-id: 2236c132b2150e38da6d5a5c9970347320e19a60
      426eb685
  11. 26 Mar, 2018 1 commit