1. 30 Aug, 2019 5 commits
    • 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
  2. 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
  3. 28 Aug, 2019 18 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
    • Alex Eckert's avatar
      use facebook::fb303 instead of common::stats where possible · f4ff8900
      Alex Eckert authored
      Summary:
      Most stat code in fbcode was moved in to open source under
      fbcode/fb303. The only exception that we use internally is the
      MonotonicCounter class. This diff moves all of our stats code to use
      the open source headers and updates cmake files to pull in the open
      source fb303.
      
      Reviewed By: chadaustin, shri-khare
      
      Differential Revision: D16969960
      
      fbshipit-source-id: 12b7abb54c956c242c8e27eb69fd96925c7e61f7
      f4ff8900
  4. 27 Aug, 2019 3 commits
    • Orvid King's avatar
      Drop support for C++14 from the CMake build · f76e78e4
      Orvid King authored
      Summary:
      Latest and C++17 are all we currently intend to support.
      
      Created from Diffusion's 'Open in Editor' feature.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D17053747
      
      fbshipit-source-id: 7ef2404b82242e363c9ccf1c5d7136eb52f356dc
      f76e78e4
    • Lee Howes's avatar
      Add unsafe versions of TimeKeeper::after and TimeKeeper::at · 9900b0f7
      Lee Howes authored
      Summary: In preparation for making TimeKeeper::at and TimeKeeper::after return SemiFutures to make more explicit the need to keep work off of the TimeKeeper's executor, add *Unsafe versions of both functions to migrate code to.
      
      Differential Revision: D17052948
      
      fbshipit-source-id: 4fb138862e417f02746ad4eaf71f091d37302e7a
      9900b0f7
    • Ying Hu's avatar
      Fix a comment in EvictingCacheMap · 15a8ca73
      Ying Hu authored
      Summary:
      Fixing a comment in Evicting Cache Map, no functional code change.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D17051293
      
      fbshipit-source-id: 7a1197790bd9a0905934888dabeecde9f7c9c165
      15a8ca73
  5. 26 Aug, 2019 4 commits
    • Adam Simpkins's avatar
      fbcode_builder: support installing thrift generated header files · da5c228a
      Adam Simpkins authored
      Summary:
      Update add_thrift_cpp2_library() to add a PUBLIC_HEADER property to the
      generated library target, so that the generated headers can be installed using
      an `install()` call.  Also add a `HEADER_INSTALL_DIR` property which indicates
      the directory they should be installed into.  A `INCLUDE_DIR` argument was
      added to customize the include installation path, should anyone care to do so.
      
      This also removes code that was previously incorrectly installing the
      generated headers into the source tree.
      
      Reviewed By: wez
      
      Differential Revision: D16853404
      
      fbshipit-source-id: 6f640b2bd347c99804e074fca0209dda37c8a9cf
      da5c228a
    • László Várady's avatar
      Fix sorted_vector PMR test cases (#1207) · 74f346e7
      László Várady authored
      Summary:
      `folly::detail::std_pmr` uses either `std::pmr` or `std::experimental::pmr`.
      
      "Polymorphic Memory Resources" has been standardized in C++17, but `pmr::resource_adaptor` was [left behind](https://github.com/cplusplus/papers/issues/33), which means `resource_adaptor` is not available when a C++17 ready standard library is detected by folly.
      
      This commit reimplements `test_resource` without using the non-standard adaptor.
      
      ```
      folly/test/sorted_vector_test.cpp:862:31: error: ‘folly::detail::std_pmr::resource_adaptor’ has not been declared
        862 | using folly::detail::std_pmr::resource_adaptor;
            |                               ^~~~~~~~~~~~~~~~
      ```
      Pull Request resolved: https://github.com/facebook/folly/pull/1207
      
      Reviewed By: nbronson
      
      Differential Revision: D17003049
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 7bcd5b4bb4368366cd57d89b9ef88deaaff808d6
      74f346e7
    • Tristan Rice's avatar
      folly: within - grab executor keepalive before moving · 216aaafc
      Tristan Rice authored
      Summary: Previous within changes changed how long the executor keepalive existed for. This explicitly grabs the executor keepalive before calling within to ensure it still exists when we try to use it in `via`.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D17054622
      
      fbshipit-source-id: 7826c6ac0ad332a8f5f1331cd2d798619cf318c3
      216aaafc
    • Adam Simpkins's avatar
      fbcode_builder: update the old fbcode_builder spec for fbzmq · 986ce3f1
      Adam Simpkins authored
      Summary:
      The external Travis CI builds for fbzmq are still using the older
      fbcode_builder spec (as opposed to the newer getdeps manifest file).
      
      D16577367 moved the CMakeLists.txt file to the top-level directory, but the
      fbzmq spec file was still looking for it in the fbzmq subdirectory.
      
      Reviewed By: jstrizich
      
      Differential Revision: D17005361
      
      fbshipit-source-id: 3f7664eadfb60ec7606124a14445b44ae586b8a7
      986ce3f1