1. 29 Aug, 2019 2 commits
    • 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
  2. 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
  3. 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
  4. 26 Aug, 2019 5 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
    • Adam Simpkins's avatar
      fbcode_builder: fix the shipit path map for fbzmq · 40e15ce0
      Adam Simpkins authored
      Summary:
      Fix the fbzmq pathmap listed in its manifest file to match the path map
      actually used by ShipIt.  The fact that this was broken was why internal
      getdeps builds did not detect that D16577367 broke the build.
      
      Reviewed By: wez, jstrizich
      
      Differential Revision: D17005360
      
      fbshipit-source-id: 046ff58ad70c03b860c3fccebaba975808df244d
      40e15ce0
  5. 25 Aug, 2019 4 commits
    • Adam Simpkins's avatar
      fbcode_builder: ThriftCppLibrary: the output depends on the thrift templates · 09ac30c9
      Adam Simpkins authored
      Summary:
      Update ThriftCppLibrary.cmake to record that the output depends on the thrift
      `cpp2` template files.  The `THRIFT_TEMPLATE_FILES` variable was defined in
      D16062657 but doesn't appear to be used anywhere.  This uses it, and also
      updates it to only match the C++ template files.
      
      Reviewed By: wez
      
      Differential Revision: D16738442
      
      fbshipit-source-id: aa4097e9ec1d009ef1e3ee2efd03ffa19a82ed12
      09ac30c9
    • Adam Simpkins's avatar
      fbcode_builder: minor style cleanup in ThriftCppLibrary.cmake · a35a5f9a
      Adam Simpkins authored
      Summary:
      Add explicit double quotes around arguments that are intended to be exactly a
      single parameter.  Also line wrap to 80 characters.
      
      Reviewed By: wez
      
      Differential Revision: D16738443
      
      fbshipit-source-id: b8c9b6d50da72b44e23eaf5effbc384b6cbbc1c0
      a35a5f9a
    • Adam Simpkins's avatar
      fbcode_builder: update ThriftCppLibrary to use fb_cmake_parse_args() · abc21143
      Adam Simpkins authored
      Summary:
      Change ThriftCppLibrary to use `fb_cmake_parse_args()`
      
      This code doesn't really care much about handling empty arguments, so we could
      use the standard `cmake_parse_arguments()` function here instead of
      `fb_cmake_parse_args()`.  However, it is slightly more convenient that
      `fb_cmake_parse_args()` automatically errors out on unhandled arguments, so
      that we don't have to check for this ourselves.
      
      Reviewed By: wez
      
      Differential Revision: D16738445
      
      fbshipit-source-id: 67b9761f2ceaf7665bd336290bb44af32fec6f4a
      abc21143
    • Adam Simpkins's avatar
      fbcode_builder: update current commit for iproute2 · 4c502a7f
      Adam Simpkins authored
      Summary:
      The manifest file for iproute2 previously listed the commit to check out as
      7ca63aef7d1b0c808da0040c6b366ef7a61f38c1.  However, this is not a commit, but
      a tag object that refers to commit 92a0236a3cdf3438000834121b7ea8a09f1f52b1.
      
      This caused getdeps to think that iproute2 was always out-of-date, even when
      it was already on the correct commit, since it was comparing current commit ID
      against the tag ID.
      
      This updates the manifest to refer to the commit ID instead of the tag ID.
      
      Reviewed By: shri-khare
      
      Differential Revision: D17005418
      
      fbshipit-source-id: c7145c73b66ae93a2e9097ddcf8c53237b135d32
      4c502a7f
  6. 24 Aug, 2019 2 commits
    • Dan Melnic's avatar
      Enable FOLLY_TLS on FOLLY_MOBILE too · 2f828c04
      Dan Melnic authored
      Summary: Enable FOLLY_TLS on FOLLY_MOBILE too
      
      Reviewed By: guangyfb
      
      Differential Revision: D16883165
      
      fbshipit-source-id: 1a8f0991088f6963dc2acf84b74b294be998b877
      2f828c04
    • Yedidya Feldblum's avatar
      Avoid __forceinline for catch_exception under MSVC · 2fc030b4
      Yedidya Feldblum authored
      Summary: [Folly] Avoid `__forceinline` for `catch_exception` under MSVC, which warns about functions which contain `try`-and-`catch` blcoks having the `__forceinline` modifier.
      
      Reviewed By: akrieger
      
      Differential Revision: D16982707
      
      fbshipit-source-id: 68c443c4ce8ca77edd49d509a88ef4b0ab9488a9
      2fc030b4
  7. 23 Aug, 2019 4 commits
    • Aaryaman Sagar's avatar
      Fix definition of SynchronizedBase::RLockedPtr · 16b42cc0
      Aaryaman Sagar authored
      Summary:
      The definition of RLockedPtr should use a non-const Subclass type, and not a
      const one.
      
      Reviewed By: ot
      
      Differential Revision: D15356827
      
      fbshipit-source-id: b8ad41e263f0e15ffa25b0698aa85eab8ca2ccb8
      16b42cc0
    • Tristan Rice's avatar
      folly: move SemiFuture::within to be with the other within methods · 7cfb9591
      Tristan Rice authored
      Summary: This moves within to be in a more logical spot. In the parent diff we kept it where it was to make it easier to see the differences.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D16967106
      
      fbshipit-source-id: 9f9cd2ea38a996ac12d3ca8256c1ec050d57dfc0
      7cfb9591
    • Tristan Rice's avatar
      folly: make within be a SemiFuture and fix deadlock bug · 4594bbdf
      Tristan Rice authored
      Summary:
      This fixes a deadlock bug where the after continuation runs inline.
      
      We resolve this by using defer to delay execution until both futures are created thus avoiding any extra synchronization.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D16952748
      
      fbshipit-source-id: a88a40d3135bdabc43bb51f9b5ea072f8e6564a3
      4594bbdf
    • Joe Romano's avatar
      Add docs to insert_or_assign re: inconsistency with std::map interface · 33fb91d9
      Joe Romano authored
      Summary:
      `ConcurrentHashMap::insert_or_assign` does not follow the interface for `std::map::insert_or_assign`.  Making this clear for future users to avoid confusion.
      
      Code:
      ```
      int main(int argc, char** argv) {
        folly::ConcurrentHashMap<int, std::string> map;
        std::cout << "Insertion took place?: " << map.insert_or_assign(1, "hey").second << std::endl;
        std::cout << "Insertion took place?: "
      << map.insert_or_assign(0, "wow").second << std::endl;
        std::cout << "Insertion took place?: "
      << map.insert_or_assign(1, "wow").second << std::endl;
      }
      ```
      
      Output:
      ```
      Insertion took place?: 1
      Insertion took place?: 1
      Insertion took place?: 1
      ```
      
      Also see: https://github.com/facebook/folly/blob/master/folly/concurrency/test/ConcurrentHashMapTest.cpp#L86-L87
      
      Reviewed By: magedm
      
      Differential Revision: D16967939
      
      fbshipit-source-id: ce0d32813371b31a94e14e404665d4fb2e7ffdfe
      33fb91d9
  8. 22 Aug, 2019 2 commits
    • Lewis Baker's avatar
      Add cancellable folly::coro::sleep() · 1a0ddc9c
      Lewis Baker authored
      Summary:
      Adds folly::coro::sleep() function as an alternative to using folly::futures::sleep().
      
      The coro version returns a Task<void> and supports cancellation of the sleep operation when awaited within another Task.
      
      Reviewed By: kirkshoop
      
      Differential Revision: D16816328
      
      fbshipit-source-id: 46bc4ee2475e6bd0bdfd0f7f30f3e0f1ea54d4d5
      1a0ddc9c
    • Lewis Baker's avatar
      Integrate CancellationToken support into Task · 14959740
      Lewis Baker authored
      Summary:
      The `folly::coro::Task` coroutine type now has an associated `CancellationToken` that is implicitly passed down to child operations that it awaits.
      
      This is a first step towards supporting cancellation of persistent async streams.
      
      This adds a new `co_withCancellation()` customisation point that awaitable types can customise to allow them to opt-in to cancellation. Currently only `Task` customises this operation.
      
      Also provided a new `co_current_cancellation_token` object that can be awaited within a `Task` to retrieve the current `CancellationToken`.
      
      Note that I have not yet hooked up the `Future` or `SemiFuture` to integrate with this cancellation mechanism (most `Future`-based code is not cancellation-aware). So a coroutine that is currently suspended awaiting for a `Future` may not currently respond to a cancellation request.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D16610810
      
      fbshipit-source-id: 72a31d7a3ba4c281db54c1942ab41d4ea2f34d21
      14959740