1. 04 Sep, 2019 4 commits
    • Dan Melnic's avatar
      Disable FOLLY_TLS under 32 bit Apple/iOS · 67dc542a
      Dan Melnic authored
      Summary: Disable FOLLY_TLS under 32 bit Apple/iOS
      
      Reviewed By: mzlee
      
      Differential Revision: D17172252
      
      fbshipit-source-id: ab47bb9ddb810aec45a940fc2ae834bac6a48f7c
      67dc542a
    • László Várady's avatar
      Remove std::move() calls that prevent NRVO (#1217) · ee3a3a1e
      László Várady authored
      Summary:
      > Under the following circumstances, the compilers are permitted to omit the copy and move construction of class objects:
      
      > In a return statement, when the operand is the name of a non-volatile object with automatic storage duration, which isn't a function parameter or a catch clause parameter, and which is of the same class type (ignoring cv-qualification) as the function return type. This variant of copy elision is known as NRVO, "named return value optimization".
      
      `std::move()` prevents this optimization.
      
      GCC 9.1.0 warning:
      ```
      moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
      ```
      Pull Request resolved: https://github.com/facebook/folly/pull/1217
      
      Reviewed By: LeeHowes
      
      Differential Revision: D17173234
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: ed63ef89dfd01883ddd6fd775285997f96a029fd
      ee3a3a1e
    • Yedidya Feldblum's avatar
      Cut mstch manifest · eea51e2d
      Yedidya Feldblum authored
      Summary: [OpenSource] Cut `mstch` manifest, which was but is no longer used by `fbthrift`.
      
      Reviewed By: avalonalex, davidtgoldblatt
      
      Differential Revision: D17160816
      
      fbshipit-source-id: 3b96142455d6990870e8ed3e5ce330d339d5a657
      eea51e2d
    • Wez Furlong's avatar
      getdeps: assign test owner in continuous runs · 241df17c
      Wez Furlong authored
      Summary:
      Feed the first-party oncall data through to the testpilot
      invocation.  This will set the owner of the test in continuous runs.
      
      The oncall is passed through via the sandcastle module, which means
      that you will have to manually pass it through for local testing
      (see test plan), but it should automatically get picked up when
      sandcastle schedules the `test` step of the job.
      
      Reviewed By: chadaustin
      
      Differential Revision: D17146802
      
      fbshipit-source-id: a4f0e65853a46ed8709594c96db859ede2530b00
      241df17c
  2. 03 Sep, 2019 6 commits
    • John Strizich's avatar
      add generated constant definitions to library · 7b373430
      John Strizich authored
      Summary: when trying to build openr with `getDeps.py` constant definitions where not available since they were not part of the generated thrift lib. this fixes it.
      
      Reviewed By: chadaustin
      
      Differential Revision: D16064417
      
      fbshipit-source-id: ee2b3e061caf67235f4a873405cf6cd6fb663ef4
      7b373430
    • Kirk Shoop's avatar
      Add folly::coro::multiplex() algorithm · b963f391
      Kirk Shoop authored
      Summary: This algorithm multiplexes values from a stream-of-streams into a single stream of events that identifies the stream index the event originated from and also the end-of-stream and stream-error events.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D15643142
      
      fbshipit-source-id: a309a485f11465d9068ea81f4bc32823dd34291f
      b963f391
    • Kirk Shoop's avatar
      Add folly::coro::transform() algorithm · 600a1046
      Kirk Shoop authored
      Summary: The `transform()` algorithm uses the provided function to transform each value in the provided input stream and produces each transformed value on the returned output stream.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D16774893
      
      fbshipit-source-id: 7ab33706c667b1706c0cb0b1c0ecb9046f47a325
      600a1046
    • Kirk Shoop's avatar
      Add folly::coro::merge() operator for AsyncGenerator. · 189c99a6
      Kirk Shoop authored
      Summary: Adds a new `folly::coro::merge()` algorithm that accepts an async stream of async streams and returns an async stream that merges and interleaves the results.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D15617383
      
      fbshipit-source-id: cafb8e31725cdb21cfa00ce186901329828c2b68
      189c99a6
    • Luca Niccolini's avatar
      BUILD_SHARED_LIBS=OFF for CI build · 6e4965ce
      Luca Niccolini authored
      Summary: fixes the CI build
      
      Reviewed By: dddmello
      
      Differential Revision: D17158685
      
      fbshipit-source-id: 44ea871eab4d8c964b8372fb8d84879fa823ca50
      6e4965ce
    • Eric Niebler's avatar
      Update fbcode for range-v3 0.9.1-pre · 3685bdd1
      Eric Niebler authored
      Summary:
      Range-v3 v0.9.1-pre deprecated and renamed a bunch of interfaces to harmonize with the direction of C++20's `std::ranges`. In this diff, I:
      
      * Rename the `ranges::view` namespace qualification to `ranges::views` (plural),
      * Rename the `ranges::action` namespace qualification to `ranges::actions` (plural),
      * Rename `ranges::view::bounded` to `ranges::views::common`,
      * Rename `ranges::to_` to `ranges::to`,
      * Replace _some_ implicit conversions of views to containers with explicit invocations of `ranges::to` (more work to be done here, but can wait).
      
      Reviewed By: mzlee
      
      Differential Revision: D17061465
      
      fbshipit-source-id: f28205ecf3965d3560e9cffe2805d0b404597b21
      3685bdd1
  3. 02 Sep, 2019 1 commit
    • Lee Howes's avatar
      Remove executor-taking form of then · 2d5ad1d0
      Lee Howes authored
      Summary:
      Remove calls to Future::then(executor, callback).
      
      This form of Future::then is ambiguous, and does not yet implement the stronger
      typing of thenValue and thenTry. It is also tempting to use instead of via,
      where it is not obvious that it has the behaviour of wrapping a via call in a
      push and pop of the current executor:
      .pushCurrentExecutor().via(executor).then(callback).popCurrentExecutor().
      
      With the addition of inline continuations, we can instead make the nesting
      explicit at low cost by making it an inline continuation that launches an
      asynchronous task on the passed executor.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15100419
      
      fbshipit-source-id: e929e2eaf2fc30313cb099150be3a9535ae729a6
      2d5ad1d0
  4. 01 Sep, 2019 1 commit
    • Lee Howes's avatar
      Make folly::TimeKeeper::after and ::at return SemiFuture · 11003288
      Lee Howes authored
      Summary:
      TimeKeeper::after and TimeKeeper::at return Futures that for the majority of implementations complete on a TimeKeeper owned executor. This can lead to problems.
      
      Consistent with other API cleanups, this diff switches TimeKeeper APIs to return SemiFuture, requiring that the caller attach an explicit executor when work is to be scheduled downstream of the TimeKeeper.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D17005944
      
      fbshipit-source-id: 98d7e8aaf1ad40ce2180503f632f2f0003bb12be
      11003288
  5. 31 Aug, 2019 3 commits
    • Lee Howes's avatar
      Add result DeferredExecutor to avoid risk of double nesting · eb5c5900
      Lee Howes authored
      Summary: Under some circumstances the DeferredExecutor might already have nested executors and this code adds more. Both incoming futures should instead nest within a fresh DeferredExecutor returned that is part of the SemiFuture from the operation.
      
      Reviewed By: mpark
      
      Differential Revision: D17121117
      
      fbshipit-source-id: b4507bf5d7b0c98e5e5de6f73ff4bd3e2790374c
      eb5c5900
    • Yedidya Feldblum's avatar
      RTM re-nits for xabort · 5db275b9
      Yedidya Feldblum authored
      Summary:
      [Folly] RTM re-nits for `xabort`.
      
      * Remove param pack.
      * Always noreturn.
      
      Reviewed By: nbronson
      
      Differential Revision: D17117350
      
      fbshipit-source-id: b16056b1f02956d334da4494c689a4b988a961d4
      5db275b9
    • Kirk Shoop's avatar
      Add folly::coro::materialize() & folly::coro::dematerialize() algorithms · 37a33e67
      Kirk Shoop authored
      Summary:
      The `materialize()` algorithm meterializes values from a stream into a stream of events that represent each value and also the end-of-stream and stream-error events.
      
      `dematerialize()` reverses a materialized stream by replaying the events recorded in the input stream to an output stream.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D16772236
      
      fbshipit-source-id: 27de543ea2d02691a376fd0f11d0113c5c39287d
      37a33e67
  6. 30 Aug, 2019 8 commits
    • Wez Furlong's avatar
      fbzmq: disable build on darwin and windows · f3352d86
      Wez Furlong authored
      Summary:
      boost.fiber is not available on macos and is required by fbzmq,
      so disable the build on darwin.
      
      In D17128935 I tried to make libzmq build with cmake to build
      on windows, but there's a problem with its cmake and it fails
      to configure.
      
      So let's just nop out the build for !linux for now.
      
      Reviewed By: jstrizich
      
      Differential Revision: D17129362
      
      fbshipit-source-id: db89010d18707a4105b8d395b1758f738336495d
      f3352d86
    • Paul O'Shannessy's avatar
      Adopt Contributor Covenant · 714c7a17
      Paul O'Shannessy authored
      Summary:
      In order to foster healthy open source communities, we're adopting the
      [Contributor Covenant](https://www.contributor-covenant.org/). It has been
      built by open source community members and represents a shared understanding of
      what is expected from a healthy community.
      
      Reviewed By: josephsavona, danobi, rdzhabarov
      
      Differential Revision: D17104640
      
      fbshipit-source-id: d210000de686c5f0d97d602b50472d5869bc6a49
      714c7a17
    • Adam Simpkins's avatar
      fbcode_builder: add a FBThriftLibrary.cmake file · 37507450
      Adam Simpkins authored
      Summary:
      This module provides a `add_fbthrift_library()` convenience function that can
      be used to generate thrift libraries for multiple languages with a single
      call.
      
      Reviewed By: wez
      
      Differential Revision: D16742275
      
      fbshipit-source-id: c13120cf9e051629951282141eb22f3e085782f9
      37507450
    • Adam Simpkins's avatar
      fbcode_builder: add an FBThriftPyLibrary.cmake module · 2dcce6ca
      Adam Simpkins authored
      Summary:
      This module helps generate Python libraries from thrift files.
      It is the Python equivalent of `FBThriftCppLibrary.cmake`
      
      Reviewed By: wez
      
      Differential Revision: D16742274
      
      fbshipit-source-id: ef0dc7f24eb1c7375d2587ee6b71fd25bd6f35a7
      2dcce6ca
    • Adam Simpkins's avatar
      fbcode_builder: fix a minor bug in THRIFT_INCLUDE_DIR argument parsing · 87f0031a
      Adam Simpkins authored
      Summary:
      Fix a minor bug in the argument parsing for `add_fbthrift_cpp_library()`:
      only a single value should be supplied for the `THRIFT_INCLUDE_DIR` argument.
      This parameter should not accept a list of arguments.
      
      Reviewed By: strager
      
      Differential Revision: D17125810
      
      fbshipit-source-id: 31f354e4d6299d3626a94f3b4b5ff8c58bb0cf7b
      87f0031a
    • Lewis Baker's avatar
      Add CancellationToken support to AsyncGenerator · 50f425bb
      Lewis Baker authored
      Summary:
      An AsyncGenerator coroutine now has an implicit associate CancellationToken that is inherited from the calling context of each `co_await gen.next()` call.
      
      This means that generators that correspond to long-running subscriptions now have an in-built channel that allows them to cancel the subscription.
      
      This is also useful for algorithms that introduce concurrency in processing of stream data. eg. The `buffer()` or `merge()` algorithms.
      
      Reviewed By: kirkshoop
      
      Differential Revision: D16833864
      
      fbshipit-source-id: be8faf1ec438c4248091e02d6a264d3760e2d73d
      50f425bb
    • Uladzislau Paulovich's avatar
      folly | Inline Future constructors to workaround MSVC bug (#1212) · 178fe966
      Uladzislau Paulovich authored
      Summary:
      Pull Request resolved: https://github.com/facebook/folly/pull/1212
      
      MSVC has a bug and can't match definitions of some of the constructors to the corresponding declarations in a class body. This diff workarounds the bug by inlining constructors.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D17119718
      
      fbshipit-source-id: eb7a9d4916b962c718d047eb0ee7fa4a9761776e
      178fe966
    • Lewis Baker's avatar
      Add CancellationToken support to collectAll() · b1ac6a22
      Lewis Baker authored
      Summary:
      The `collectAll()`, `collectAllRange()` and `collectAllWindowed()` functions now cancel their subtasks when either the parent task is cancelled or when any of the subtasks fail with an exception.
      
      The `collectAllTry()`, `collectAllTryRange()` and `collectAllTryWindowed()` functions now cancel their subtasks if the parent task is cancelled, but not if the child tasks fail with an exception.
      
      The logic between the distinction here is that if you are calling one of the 'try' functions then you are intending to handle partial failure and so probably want each of the operations to run to completion independently of the others.
      
      Reviewed By: kirkshoop
      
      Differential Revision: D16820619
      
      fbshipit-source-id: 5c203b41592a0145ff7be1c609dfccd39c41a3df
      b1ac6a22
  7. 29 Aug, 2019 10 commits
    • Uladzislau Paulovich's avatar
      folly | Improve support for clang-cl compiler in folly/Portability.h · 412928c4
      Uladzislau Paulovich authored
      Summary: `clang-cl` on Windows also defines `__PRETTY_FUNCTION__` which has a format different from `__FUNCSIG__`. Therefore folly breaks users of this macro. Alias should be defined only when "real" MSVC compiler is used.
      
      Reviewed By: akrieger, Orvid, blackm00n
      
      Differential Revision: D17094657
      
      fbshipit-source-id: 4b191a61201704382e6b6e178bcc1c673511c537
      412928c4
    • Adam Simpkins's avatar
      fbcode_builder: rename add_thrift_cpp2_library() to add_fbthrift_cpp_library() · 464fac7e
      Adam Simpkins authored
      Summary:
      Rename the `ThriftCppLibrary.cmake` file to `FBThriftCppLibrary.cmake`, and
      also rename `add_thrift_cpp2_library()` to `add_fbthrift_cpp_library()`.
      
      Explicitly calling this `fbthrift` helps clearly distinguish that this is
      intended for use with fbthrift (https://github.com/facebook/fbthrift/), as
      opposed to Apache thrift.
      
      Reviewed By: wez
      
      Differential Revision: D16738440
      
      fbshipit-source-id: 9b255e06b71c98ad74a34989f564a211958dcdd5
      464fac7e
    • Nathan Bronson's avatar
      skip CacheLocality optimizations if there are offline CPUs · e545b9a9
      Nathan Bronson authored
      Summary:
      CacheLocality's parsing code for /proc/cpuinfo doesn't properly
      handle systems in which there are offline CPUs. This diff makes it so
      we fall back onto the sequential cache locality implementation in the
      problematic scenarios.
      
      This should address https://github.com/facebook/folly/issues/1208
      
      Reviewed By: shixiao
      
      Differential Revision: D17093176
      
      fbshipit-source-id: 4da3a9dc53622f829af37ed70a2531c66fd92ddb
      e545b9a9
    • Aaryaman Sagar's avatar
      Use folly::cacheline_align_v for cache alignment in thread pools · 27045b27
      Aaryaman Sagar authored
      Summary:
      Use folly::cacheline_align_v to prevent failures when running folly on platforms
      where extended alignment is not supported.  The thread pools only used extended
      alignment as an optimization; so it is safe to disable it when not needed
      
      Reviewed By: yfeldblum
      
      Differential Revision: D17077439
      
      fbshipit-source-id: 63ba59aaf7ce45231bb25427af84292c3a3464a9
      27045b27
    • Haijun Zhu's avatar
      Fix race condition in fibers CacheManager · 7cfbc254
      Haijun Zhu authored
      Summary:
      The non-atomic field `inUse_` is protected by a lock in `getStackCache`, but not in `giveBack`. This
      is a data race and it is caught by TSAN.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D17109710
      
      fbshipit-source-id: 7c0d5d948740516422efca0895a702566c804bb4
      7cfbc254
    • Wez Furlong's avatar
      folly: fix placement of noreturn attribute · 7c8c8039
      Wez Furlong authored
      Summary:
      Windows and macOS compilers are sensitive to this,
      and this was overlooked in D16636130
      
      Reviewed By: selat
      
      Differential Revision: D17113825
      
      fbshipit-source-id: 16fe9210b07a096a58f3370df64874514e28ea46
      7c8c8039
    • Nick Sukhanov's avatar
      Remove std::move after co_return for local variables · 43b93a0a
      Nick Sukhanov authored
      Summary:
      Compiler passes rvalue reference for named local variable to return_value:
      https://reviews.llvm.org/D51741
      
      Reviewed By: lewissbaker
      
      Differential Revision: D16963353
      
      fbshipit-source-id: 98d846153adb2235b61bb8fb54d10f032d4c0055
      43b93a0a
    • Joe Loser's avatar
      Add assert in Range::size() (#1155) · 823a28c3
      Joe Loser authored
      Summary:
      - Prior to commit 8cb615a2
        (Differential Revision: D3394612), `Range:size()` had an assert checking
        that the beginning iterator of the range is less than or equal to the end
        iterator. Unfortunately, due to GCC bug 71448, the `assert` was not allowed
        if we wanted `size()` to remain a `constexpr` function.
      - This bug is no longer an issue with our current supported versions of GCC.
        As such, add the assert back in.
      Pull Request resolved: https://github.com/facebook/folly/pull/1155
      
      Reviewed By: ericniebler
      
      Differential Revision: D15641627
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 0677053c18fa55aaa4727947c241f0675362861b
      823a28c3
    • Adam Simpkins's avatar
      fbcode_builder: fix install_fb_python_library() to work with old CMake versions · 0a36d34f
      Adam Simpkins authored
      Summary:
      Update install_fb_python_library() to work with CMake versions older than 3.7.
      
      Previously the code used a generator expression in the directory argument
      supplied to `install(DIRECTORY)`.  Support for generators in this parameter
      was only added in CMake 3.5, but it was buggy and did not correctly handle
      absolute paths until 3.7.
      
      This updates the code to avoid using a generator expression.  This does
      require that the corresponding `add_fb_python_library()` statement appear
      before the `install_fb_python_library()` statement, but this seems like a
      pretty reasonable restriction.
      
      Reviewed By: chadaustin
      
      Differential Revision: D17103597
      
      fbshipit-source-id: 54d6af93a3f530373cfe3137db99436d8484f308
      0a36d34f
    • Yedidya Feldblum's avatar
      RTM nits · 488fe98c
      Yedidya Feldblum authored
      Summary:
      [Folly] RTM nits.
      
      * No nested namespace.
      * All status values supported.
      * Tests included in cmake builds.
      * API functions avoid `SIGILL` at runtime.
      
      Reviewed By: nbronson
      
      Differential Revision: D16636130
      
      fbshipit-source-id: 9f9dc99b0826abbda295b069eb4823b3416af5d1
      488fe98c
  8. 28 Aug, 2019 7 commits
    • Aaryaman Sagar's avatar
      Move ManualTimekeeper to its own file in folly/futures · c20009d3
      Aaryaman Sagar authored
      Summary:
      This is a useful testing utility that people can use if they use timeout APIs
      like `folly::futures::sleep()`
      
      Reviewed By: LeeHowes
      
      Differential Revision: D17065352
      
      fbshipit-source-id: f9ea8366af7fc9429bfb1065328ed746c824f810
      c20009d3
    • Mark Santaniello's avatar
      additional tests for sorted_vector_types · 9205b9d2
      Mark Santaniello authored
      Summary: The sorted vector types have constructors which "steal" capacity from a pre-filled container.  Add tests to cover the cases where this is a folly:small_vector, and a std::pmr::vector.
      
      Reviewed By: nbronson
      
      Differential Revision: D17074150
      
      fbshipit-source-id: e94b7e136553653081abe86559c4c013b9aac031
      9205b9d2
    • Lewis Baker's avatar
      Add ability to construct an invalid CancellationSource · 5bf0e525
      Lewis Baker authored
      Summary:
      Adds static factory `CancellationSource::invalid()`.
      
      This can be used to construct a `CancellationSource` that can't be cancelled but that doesn't perform any heap-allocations.
      
      Reviewed By: kirkshoop
      
      Differential Revision: D16816764
      
      fbshipit-source-id: bb87273903a6a8d245d207f4e6bda94e5c3d3dad
      5bf0e525
    • Lee Howes's avatar
      Reorder SemiFuture::within to propagate executor · a745237d
      Lee Howes authored
      Summary: Tweak futures::within to be completely deferred, including the timeout path, allowing it to support a SemiFuture-returning TimeKeeper.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D17006080
      
      fbshipit-source-id: cbed58579d33f6d6ecf60dce5f9c8b886fc4d4c4
      a745237d
    • Chris Keeline's avatar
      Skip shared_ptr in futures waitImpl · 44a17b1f
      Chris Keeline authored
      Summary:
      wait() is guaranteed to succeed and not throw for either Baton type, so
      using a reference here is safe. When the future is completed on another thread,
      the shared_ptr causes cache contention.
      
      ```
      Thread 1            Thread 2
      make_shared/inc
      inc
      ...
                          dec ref
      dec ref/free
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D17077672
      
      fbshipit-source-id: a6010ed159353decefbd5c51f4347370b16f7f60
      44a17b1f
    • Adam Simpkins's avatar
      fbcode_builder: fix run_cmake.py to propagate the command return code · 8faaa1a9
      Adam Simpkins authored
      Summary:
      Update the generated `run_cmake.py` script to use `os.execve()` rather than
      `subprocess.call()`, so that it now propagates CMake's return code back to its
      caller.
      
      Reviewed By: chadaustin
      
      Differential Revision: D17089206
      
      fbshipit-source-id: e01f05f492ccb842d4967e59fd0bc9a3e59b8a42
      8faaa1a9
    • Adam Simpkins's avatar
      fbcode_builder: fix the error message if we cannot find a project fetcher · 74aeab1c
      Adam Simpkins authored
      Summary:
      Fix printing the manifest context in the error message if we cannot find a
      project fetcher.  Previously the context in the message would be printed as
      something like `<getdeps.manifest.ManifestContext object at 0x7fcce987e610>`,
      now it shows instead as something like
      `{distro=ubuntu, distro_vers=18.04, fb=off, os=linux, test=off}`
      
      Reviewed By: chadaustin
      
      Differential Revision: D17089208
      
      fbshipit-source-id: c16549b61030d813b7b5ff9f65966436dc1e1898
      74aeab1c