1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 28 Aug, 2019 17 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
    • Adam Simpkins's avatar
      fbcode_builder: minor fixup to normalize python installation paths · edb65d03
      Adam Simpkins authored
      Summary:
      This just strips off a trailing '/' from the `INSTALL_DIR` property that we
      set on python targets, to avoid having double-slashes in the paths that we use
      during installation.  This shouldn't really have any material difference other
      than cleaning up the paths that get printed during the installation phase.
      
      Reviewed By: chadaustin
      
      Differential Revision: D17089207
      
      fbshipit-source-id: ab36bb76c19fa60fe037f7a5290ccfd6bdbf13b0
      edb65d03
    • Adam Simpkins's avatar
      use ThriftCppLibrary.cmake from fbcode_builder · 975dd18e
      Adam Simpkins authored
      Summary:
      Update fboss to use `ThriftCppLibrary.cmake` directly from fbcode_builder
      rather than maintaining its own copy of this file.
      
      Reviewed By: chadaustin
      
      Differential Revision: D17005421
      
      fbshipit-source-id: a64df426118df6088b47f09410dad7b8b7e79a43
      975dd18e
    • Adam Simpkins's avatar
      fbcode_builder: cmake: propagate thrift include dependencies correctly · 875dd11c
      Adam Simpkins authored
      Summary:
      Update `add_thrift_cpp2_library()` to pass in the correct `-I` flags when
      invoking the thrift compiler so that it can find all of the other thrift files
      that this library depends on.
      
      D16062657 was a previous attempt to do this, but suffered from a few problems:
      - It required all dependencies to be defined before
        `add_thrift_cpp2_library()` was called.  This requires users to carefully
        order their CMake files and subdirectory include ordering.
      - It only handled one level of dependencies, and did not propagate include
        paths for deeper dependencies.
      - It set the include path for dependencies to the source directory path where
        the dependency was originally built, rather than the directory where the
        thrift file for that dependency would be installed.
      
      This change does require CMake 3.8+.  Previous versions of CMake do not
      support using generator expressions to generate multiple arguments for a
      custom command.
      
      Reviewed By: strager
      
      Differential Revision: D17005381
      
      fbshipit-source-id: 31190beba94b4d1010445375a5e2791450230f7d
      875dd11c
    • Lee Howes's avatar
      futures::when semifuture support · 8541be76
      Lee Howes authored
      Summary: Allow futures::when to pass through a SemiFuture-returning function.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D17001974
      
      fbshipit-source-id: dbe8b347f0a4c3fd19774c68c4e58e3b523b971f
      8541be76
    • Lee Howes's avatar
      Add unit() method to SemiFuture · 6a469b3f
      Lee Howes authored
      Reviewed By: yfeldblum
      
      Differential Revision: D17086382
      
      fbshipit-source-id: 318834a1d82025bc0c34bcf7a95fedfffdb02ddb
      6a469b3f
    • Lee Howes's avatar
      Add SemiFuture support to folly::times · b277c2bb
      Lee Howes authored
      Summary: times is hard to use with SemiFutures, leading to potential use of inline executors just to make it work. This adds native support.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D16992774
      
      fbshipit-source-id: 483110d923ca51e037439ccc80173ffa9299cd64
      b277c2bb
    • Dan Melnic's avatar
      Use FOLLY_CL_USE_FOLLY_TLS for CacheLocality to avoid an iOS build issue · 4a150ab2
      Dan Melnic authored
      Summary: Use FOLLY_CL_USE_FOLLY_TLS for CacheLocality to avoid an iOS build issue
      
      Reviewed By: mzlee
      
      Differential Revision: D17085507
      
      fbshipit-source-id: acd407c9e0045eb4d8a59348a20874dbe75fd651
      4a150ab2
    • Lee Howes's avatar
      Propagate interrupt handler through wait with duration · 54f83501
      Lee Howes authored
      Summary: Earlier change to duration waiting broke propagation of the interrupt handler. This change correctly propagates it into the new future that is returned.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D17061618
      
      fbshipit-source-id: b228221acbfab3ae94118c1197a485e01aa2e41e
      54f83501
    • Lee Howes's avatar
      Add SemiFuture support to folly::whileDo · 30f883ea
      Lee Howes authored
      Summary: whileDo is hard to use with SemiFutures, leading to potential use of inline executors just to make it work. This adds native support.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D16988569
      
      fbshipit-source-id: abaf36180d6ff8a5277eebb277f7f0a254315d36
      30f883ea
    • Alex Eckert's avatar
      break oss build dependency on fboss/common/ · a50ea0f9
      Alex Eckert authored
      Summary:
      All of the requisite headers are now open sourced and eden
      has been converted to use them. This removes any logic that references
      this directory and kills the now unused cmake file.
      
      Reviewed By: chadaustin
      
      Differential Revision: D16994732
      
      fbshipit-source-id: 573b8b50540ee64590682be2a54aa94659f12368
      a50ea0f9