1. 03 Apr, 2018 1 commit
    • 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
  2. 02 Apr, 2018 1 commit
  3. 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
  4. 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
  5. 30 Mar, 2018 3 commits
  6. 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
  7. 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
  8. 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
  9. 26 Mar, 2018 5 commits
    • Dan Melnic's avatar
      Fix "declaration of 'h' shadows a previous local [-Werror=shadow-compatible-local]" · db2cedc7
      Dan Melnic authored
      Summary:
      Fix "declaration of 'h' shadows a previous local [-Werror=shadow-compatible-local]"
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: djwatson
      
      Differential Revision: D7406485
      
      fbshipit-source-id: f23548022a3ccb1f480c7265b11c31d2e2876fd4
      db2cedc7
    • Orvid King's avatar
      Fix the forward declarations of F14 under MSVC · 8c80ad9e
      Orvid King authored
      Summary:
      Due to a quirk in how MSVC does name resolution, if a default value is declared in the forward declaration of a template, and the definition is made available in the same unit, the default values in the forward declaration must use the names given in the definition, not the declaration.
      To keep it sane, just use the same template parameter names for both the declaration and definition.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: shixiao
      
      Differential Revision: D7405057
      
      fbshipit-source-id: dda14043fec30fa505bb0bb3e2e31d0abb52ba1f
      8c80ad9e
    • Xiao Shi's avatar
      Forward iterator for F14VectorMap · 3f0f6c97
      Xiao Shi authored
      Summary:
      This diff adds a reverse iterator to F14VectorMap/Set; this is mainly useful because
      if there have been no calls to erase(), the reverse iterator will visit the entries in
      insertion order.
      
      Reviewed By: nbronson
      
      Differential Revision: D7173038
      
      fbshipit-source-id: 0a64c4e753c9c36c6ac8b6141654b6f29f410580
      3f0f6c97
    • Shoaib Meenai's avatar
      Correct exception wrapper MSVC conditional · a228d714
      Shoaib Meenai authored
      Summary:
      The layout of an exception_ptr is determined by the ABI, not the OS. MinGW (and
      Cygwin, depending on the build settings) define `_WIN32` and would therefore
      have `kIsWindows` be true, but they use the Itanium ABI instead of Microsoft's,
      so we shouldn't take the MSVC codepath for them.
      
      Unfortunately, there isn't a reliable preprocessor method to determine the ABI
      being used. `_MSC_VER` can be defined even when using the Itanium ABI (e.g.
      when using windows-itanium triples with clang), and `_MSC_VER` can be undefined
      even when using the Microsoft ABI (e.g. when building with `-fno-ms-extensions`
      with clang).
      
      To address this, introduce `kMicrosoftAbiVer`, which defaults to `_MSC_VER`,
      but can be overridden manually if necessary. This should do the right thing by
      default most of the time, while providing an escape hatch for when `_MSC_VER`
      would be incorrect to use directly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7377853
      
      fbshipit-source-id: dd868370e9a496b98dd26dec77c4a75c49147c3c
      a228d714
    • Kevin Doherty's avatar
      Avoid calling emplace_back from collectN future callbacks · 37515540
      Kevin Doherty authored
      Summary:
      Currently, `collectN` attaches a callback to each input future. When the callback fires, it calls `emplace_back` on vector `ctx->v` with the result of the future. As the added unit test shows, this does not work if the futures are completed in parallel.
      
      See https://fb.facebook.com/groups/474291069286180/permalink/1838209692894304/ for more discussion.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7372982
      
      fbshipit-source-id: 875eff19172bdbfb7d4f687911f4fa22061e4ed8
      37515540
  10. 24 Mar, 2018 3 commits
    • Orvid King's avatar
      Eliminate std::tr1 references · 1d4b2e2e
      Orvid King authored
      Summary:
      `std::tuple` and `std::unordered_map` have long been standardized and supported by every platform we care about.
      Beyond that MSVC is starting to remove the tr1 namespace entirely, so these references don't work under the newest MSVC.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7389783
      
      fbshipit-source-id: c089490360ebf15ac23925f71e991602fda3d7a0
      1d4b2e2e
    • Orvid King's avatar
      Add an additional guard to only enable std::launder aliasing if launder is actually enabled · 091bfa60
      Orvid King authored
      Summary: The nightlies for MSVC included support for std::launder, but the version that released with VS2017.7 Preview 2 doesn't actually support it. The version included in the preview also adds a macro to detect if it's been enabled, so use that.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7388311
      
      fbshipit-source-id: 197230c9947cb271d6107d0cd5e905643e5589d1
      091bfa60
    • Orvid King's avatar
      Add an option to the MSVC build to suppress boost's out of date config messages · 5777c54e
      Orvid King authored
      Summary:
      MSVC moves faster than boost updates, so it's not unusual to be building with an MSVC newer than the boost being used was able to be tested against. This causes Boost to emit a message at compile time for every compilation unit it is included in.
      Luckly, boost provides a way out of the message, so add a config option to do so and enable it by default.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7388583
      
      fbshipit-source-id: 8ecddc048df432df5200f4601e4121bdbd275220
      5777c54e
  11. 23 Mar, 2018 7 commits
    • Yedidya Feldblum's avatar
      Use C++ thread_local for fast-path cache in SingletonThreadLocal · d6dd4b47
      Yedidya Feldblum authored
      Summary:
      [Folly] Use C++ `thread_local` for fast-path cache in `SingletonThreadLocal`.
      
      Because modules might be `dlclose`'d, use `static thread_local` rather than `static __thread` in the slow path which integrates the dtor into both `dlclose` and thread exit.
      
      Because there might be multiple dynamically-loaded modules where the `static __thread` caches cannot be merged into a single cache, let all caches be tracked in a list. We have not found a case where this can happen while at the same time the `StaticSingletonManager` singleton does get merged, but this is at least not strictly wrong.
      
      Reviewed By: djwatson
      
      Differential Revision: D7316155
      
      fbshipit-source-id: 0bf06638853ed70464856853349445d9fa6eabc0
      d6dd4b47
    • Mainak Mandal's avatar
      better error handling for ThreadLocal ctor · 3ce3a0c3
      Mainak Mandal authored
      Summary: Currently, initializing a `ThreadLocal` with 0 silently passes and then fails at a later stage making it very hard to debug what went wrong
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7326627
      
      fbshipit-source-id: dab62166753168e292f67938c52f82a1b610be2a
      3ce3a0c3
    • Igor Sugak's avatar
      remove trailing ; · 13cf726e
      Igor Sugak authored
      Summary:
      Latest clang reported `-Wextra-semi` in `BOOST_MPL_HAS_XXX_TRAIT_DEF` uses with the trailing `;`. Codemod them away before the upgrade.
      ```lang=bash
      fbgr -sl 'BOOST_MPL_HAS_XXX_TRAIT_DEF\(.*\);$' | xargs perl -pi -e 's,(BOOST_MPL_HAS_XXX_TRAIT_DEF\(.*\));$,\1,'
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7383619
      
      fbshipit-source-id: f7f9415617cf6d4a876ebe8bf782d0115cd01c23
      13cf726e
    • yuyoyuppe's avatar
      Fix msvc ProducerConsumerQueue compilation and update its doc · 2598a080
      yuyoyuppe authored
      Summary:
      Compilation of basic sample from doc using VS2017 currently fails with:
      ```
      C2327 'folly::ProducerConsumerQueue<folly::fbstring>::writeIndex_': is not a type name, static, or enumerator
      ```
      Fixed it and updated the docs.
      Closes https://github.com/facebook/folly/pull/806
      
      Reviewed By: akrieger
      
      Differential Revision: D7379931
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 6b7a72abd3324af56de355a6e65bdc7e1195596d
      2598a080
    • Igor Sugak's avatar
      require trailing ; when using BENCHMARK_DRAW_LINE macro · b20cd8da
      Igor Sugak authored
      Summary:
      Macro BENCHMARK_DRAW_LINE can be used as the following:
      ```lang=bash
      BENCHMARK_DRAW_LINE()
      BENCHMARK_DRAW_LINE();
      ```
      This inconsistency was detected by `-Wextra-semi` in the latest clang. This diff removes the trailing `;` inside `BENCHMARK_DRAW_LINE` and updates all of the references.
      
      ```lang=bash
      fbgr -sl 'BENCHMARK_DRAW_LINE\(\)' | xargs perl -pi -e 's,(?<!#define )BENCHMARK_DRAW_LINE\(\)(?!;),BENCHMARK_DRAW_LINE\(\);,'
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7382525
      
      fbshipit-source-id: 76f1da01bb4dde1b0fa4ebf98748d001d8e04ab0
      b20cd8da
    • Aaryaman Sagar's avatar
      Add piecewise_construct constructor to folly::Syncronized · 8581e9e0
      Aaryaman Sagar authored
      Summary: As title
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7379148
      
      fbshipit-source-id: 6865940adee5899a055e1dac6b23705db2bc8ed7
      8581e9e0
    • Xiao Shi's avatar
      fix bulk erase in `F14VectorMap` · 26262a91
      Xiao Shi authored
      Summary:
      `iterator F14VectorMap::erase(const_iterator, const_iterator)` was missing a
      conversion from `const_iterator` to `iterator`. This diff adds it as well as a
      test. For sets, `iterator == const_iterator` so no need for anything special.
      
      Perhaps we could save the roundtrip from iterator space to index space and
      back using some const_cast of fancy pointers? The cost is going to be amortized
      anyway...
      
      Reviewed By: nbronson
      
      Differential Revision: D7373152
      
      fbshipit-source-id: 91f651b3e4a1314c68fb8809baeb1477f8881790
      26262a91