1. 01 Nov, 2018 1 commit
    • Kirk Shoop's avatar
      migrate to gtest · d58fe683
      Kirk Shoop authored
      Summary:
      migrated tests
      fixed some bugs introduced while tests were disabled
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10515231
      
      fbshipit-source-id: 34cddb6588c4da9cd05256111bf9626b013dd4fa
      d58fe683
  2. 31 Oct, 2018 4 commits
    • Nathan Bronson's avatar
      allow TSAN hook linkage override at compile time · 20d6c1df
      Nathan Bronson authored
      Summary:
      This diff allows you to override the function attributes for TSAN
      hooks at compile time using -DFOLLY_ATTR_FOR_SANITIZE_THREAD_HOOKS=xyz.
      This is useful for builds that statically link with a library like abseil
      that has its own declarations for the hooks.
      
      Reviewed By: yfeldblum, kennyyu
      
      Differential Revision: D12866286
      
      fbshipit-source-id: 10d2921df998d5dc11f86a5383111d650d31dd8e
      20d6c1df
    • Nathan Bronson's avatar
      heterogeneous string keys by default in F14, with general mechanism · 05975ce4
      Nathan Bronson authored
      Summary:
      This diff adds folly types HeterogeneousAccessLess<T>,
      HeterogeneousAccessEqualTo<T>, and HeterogeneousAccessHash<T> that
      are suitable as the default functor types for containers that support
      heterogeneous access, and it makes those the default for F14 maps and
      sets.  The new functor types will be marked as transparent when possible,
      otherwise they will fall back to the non-transparent std::less<T>,
      std::equal_to<T>, and std::hash<T> respectively.
      
      Heterogeneous lookup is provided for types that are implicitly convertible
      to Range<T const*>, where T is an integral type.  This includes
      std::string, std::string_view (when available), folly::StringPiece,
      folly::MutableStringPiece, std::array, std::vector, folly::small_vector.
      
      HeterogeneousAccessHash<T> will use folly::hasher<folly::Range<
      T::value_type const*>> for hashing when it provides a transparent hash,
      except that for libstdc++ and libc++ we special-case the case hashing
      Range<char const*> to use the same hash function as std::string.
      That makes this diff performance neutral for existing use cases.
      
      Reviewed By: ot
      
      Differential Revision: D8768761
      
      fbshipit-source-id: ded7c86e30479409cf838ac8219241622a4e2332
      05975ce4
    • Jason Rahman's avatar
      Support move-only types in SemiFuture::promise_type · 4ac6c276
      Jason Rahman authored
      Summary:
      The SemiFuture::promise_type class didn't properly handle move only
      types in return_value(). Added overload to handle T&& case properly.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D12837450
      
      fbshipit-source-id: 74edbb2d9de32abc2859f337047ca4e32414de7f
      4ac6c276
    • Yedidya Feldblum's avatar
      Let EventBaseLocal::getOrCreateFn take the callable by value · df8f0965
      Yedidya Feldblum authored
      Summary:
      [Folly] Let EventBaseLocal::getOrCreateFn take the callable by value, rather than by non-const lvalue ref.
      
      This lets temporaries, including lambda expression temporaries, be passed as the callable argument.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D12831069
      
      fbshipit-source-id: 4c61f2cd3fb3eeaab6e7c72d2b0458b657c9d107
      df8f0965
  3. 30 Oct, 2018 7 commits
    • Kyle Nekritz's avatar
      Run OpenSSLCertUtils tests with a polluted OpenSSL error stack. · a81ce979
      Kyle Nekritz authored
      Summary:
      We have had several bugs due to this, running tests with an error in
      the stack by default should help catch them.
      
      Reviewed By: xybu
      
      Differential Revision: D12843909
      
      fbshipit-source-id: 82432b338f24b4a566c6290d39e34cf2e55092ca
      a81ce979
    • Andrii Grynenko's avatar
      Fix tail call optimization · a5ef29a1
      Andrii Grynenko authored
      Summary: The is_same check was unnecessary. The type of the future which .then() is called on, doesn't matter because it's core is not participating in the callback stealing.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12836654
      
      fbshipit-source-id: 8dcf3f0a4e44e01a1efda9534edafce9a591e9cf
      a5ef29a1
    • Kyle Nekritz's avatar
      Clear error stack in readCertsFromBuffer. · 3a7f777a
      Kyle Nekritz authored
      Summary:
      Otherwise this function throws if there was an error left in the
      stack.
      
      Reviewed By: AjanthanAsogamoorthy
      
      Differential Revision: D12840871
      
      fbshipit-source-id: 233c10e0448c937a68bf8f09d24ccaa12fcc57a4
      3a7f777a
    • Chad Austin's avatar
      Disallow construction of std::optional from folly::none · c36c506a
      Chad Austin authored
      Summary:
      I spent a day trying to convert some code from folly::Optional to
      std::optional. One hour of that was making the necessary syntax
      changes. The rest was diagnosing why certain bits of code broke. The
      reason turned out to be that `folly::Optional` allowed construction
      from nullptr and that `std::optional<bool>{folly::none}` would result
      in `std::make_optional(false)`, not `std::nullopt`.
      
      Instead of implementing folly::none with a pointer-to-member, copy the
      implementation of the upcoming std::nullopt.
      
      As teams switch to C++17, this should smooth the migration.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10475780
      
      fbshipit-source-id: 3a072b5e7e95209721d871361f5a24e3e30472cd
      c36c506a
    • Lee Howes's avatar
      Upgrade error level for deprecation attributes · edcd66e1
      Lee Howes authored
      Summary: Make deprecation messages firmer.
      
      Reviewed By: WillerZ
      
      Differential Revision: D10855134
      
      fbshipit-source-id: 181bc0ed6d5ccaefdca22264182e8fbe47c1a9b9
      edcd66e1
    • Aaryaman Sagar's avatar
      Initializer list constructor and emplace make_optional versions · 6eb37d26
      Aaryaman Sagar authored
      Summary: Add a missing initializer list constructor and variadic argument emplacing make_optional variants.
      
      Reviewed By: yfeldblum, ot
      
      Differential Revision: D8918866
      
      fbshipit-source-id: a343602f91b5e0ee0b5c293ca929a699b6104996
      6eb37d26
    • Aaryaman Sagar's avatar
      Remove return value check in folly::chrono::coarse_monotonic_clock · cd1ab8b9
      Aaryaman Sagar authored
      Summary: This shaves off 0.5ns
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10320634
      
      fbshipit-source-id: 1a790df14b128b3b02c810ec45ba48c2ce5e4612
      cd1ab8b9
  4. 28 Oct, 2018 1 commit
    • Jason Rahman's avatar
      Fix Uninitialized Try exception when co_awaiting on fulfilled futures. · e899e1af
      Jason Rahman authored
      Summary:
      FutureAwaitable currently does not properly handle the case where an
      already fulfilled future is awaited on. In particular, await_ready() is based
      on the value of future_.isReady(), while await_resume() pulls the value from
      result_, regardless of whether or not result_ has been correctly initialized by
      the callback registered in await_suspend. When an already fulfilled
      future is awaited on, await_ready() will return true immediately, and await_suspend() will
      be bypassed and await_resume() called immediately, throwing an exception since result_ hasn't been initialized.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D12816274
      
      fbshipit-source-id: f5f697e433c1621f829af6f5509d08bac2229ddb
      e899e1af
  5. 27 Oct, 2018 6 commits
    • Orvid King's avatar
      Use the right type for values · d2c2e40c
      Orvid King authored
      Summary: MSVC was complaining very loudly about these being implicitly truncated to `int`s in the initialization of OptionsMap, so declare them as `int`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10861911
      
      fbshipit-source-id: 0d5c52fe4b5e59c5e101546093a13849fe3b2a7a
      d2c2e40c
    • Orvid King's avatar
      Guard dlfcn include correctly · 7fb6c54e
      Orvid King authored
      Summary: It doesn't exist on Windows, so only include it when it's acutally used.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10861997
      
      fbshipit-source-id: 04156a09f2fab83ae3b958c1cbcd41c347d5f9e8
      7fb6c54e
    • Andrew Gallagher's avatar
      Back out "folly/memory/Malloc.h: include a few more JEMalloc macro definitions" · 76cf8b58
      Andrew Gallagher authored
      Summary:
      This was actually just incorrectly masking a inconsistency between
      `folly/memory/Malloc.h` and `<jemalloc/jemalloc.h>` and the proper fix is
      D10866789.
      
      Reviewed By: elsteveogrande
      
      Differential Revision: D12207144
      
      fbshipit-source-id: 2ecf818c04c8e124bcfe96433a7269b3deadb502
      76cf8b58
    • Yedidya Feldblum's avatar
      Fix as_const detection for libc++ · 7a053dd5
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix as_const detection for libc++, which has the function in C++17 mode as of clang-v5 but which does not define the recommended feature-test macro `__cpp_lib_as_const`.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: ngoyal
      
      Differential Revision: D12812804
      
      fbshipit-source-id: 25e01be2688346e9e434a44cf01df142129ae339
      7a053dd5
    • Xiangyu Bu's avatar
      OpenSSLCertUtils::readCertsFromBuffer() to throw on malformed cert. · 733bf267
      Xiangyu Bu authored
      Summary:
      Current behavior of OpenSSLCertUtils::readCertsFromBuffer() is that it stops
      parsing as soon as it encounters the first error. We don't know if the error
      is EOF or something else. Sometimes we want to reject the result
      if the buffer is malformed instead of accepting a partially parsed result.
      This diff makes the API throw when given malformed cert buffer.
      
      Reviewed By: anirudhvr
      
      Differential Revision: D10467792
      
      fbshipit-source-id: 2c15266e5f00866dfaafe0a5ce88d24459e8b561
      733bf267
    • Andrii Grynenko's avatar
      Implement collectAnyWithoutExceptionSemiFuture · a3949788
      Andrii Grynenko authored
      Summary: Adding support for SemiFutures with deferred work.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12812057
      
      fbshipit-source-id: 7da73124d27063eb730be1abe134ae9838494af0
      a3949788
  6. 26 Oct, 2018 3 commits
    • Lee Howes's avatar
      Future<T>::then Future<T>::then() -> Future<T>::thenValue or thenTry. · 0bf289ce
      Lee Howes authored
      Summary:
      Part of the larger project to modify Future<T>::then to be r-value qualified and use Future<T>::thenTry or Future<T>::thenValue.
      
      The goal is to disambiguate folly::Future and to improve type and lifetime safety of Future and its methods.
      
      Codemod:
        future<T>.then(callable with operator()(not-a-try)) to future<T>.thenValue(callable with operator()(not-a-try)).
        future<T>.then(callable with operator()()) to future<T>.thenValue(callable with operator()(auto&&)).
        future<T>.then(callable with operator()(auto)) to future<T>.thenValue(callable with operator()(auto)).
        future<T>.then(callable with operator()(folly::Try<T>)) to future<T>.thenTry(callable)
      
      Reviewed By: Orvid
      
      Differential Revision: D10859128
      
      fbshipit-source-id: 6df42d7d9bee324a118c114ff7ada76f93d94268
      0bf289ce
    • Aaryaman Sagar's avatar
      Very basic FunctionRef benchmarks · 6143f6f3
      Aaryaman Sagar authored
      Summary:
      FunctionRef was lacking benchmarks, this adds a couple very basic ones to
      compare against strategies like std::function, std::function with
      std::reference_wrapper and folly::Function.  With small and large closures
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10863252
      
      fbshipit-source-id: 40c3296095c693830d9fe6b4488f4708d4916af6
      6143f6f3
    • Song Zhou's avatar
      Make folly::collectAnyWithoutException return a SemiFuture · 8d639495
      Song Zhou authored
      Reviewed By: yfeldblum
      
      Differential Revision: D10851133
      
      fbshipit-source-id: 72493988c4d32011b1ee76af7191d3bbe5fe43b2
      8d639495
  7. 25 Oct, 2018 6 commits
    • David Lam's avatar
      add comment to singletonWarnDoubleRegistrationAndAbort · 6e5ef0b1
      David Lam authored
      Summary: Would help make these types of errors easier to debug
      
      Reviewed By: yfeldblum, ot
      
      Differential Revision: D10857148
      
      fbshipit-source-id: fbb1defbde2f3695e91da92ca502c0a0aed4c7ec
      6e5ef0b1
    • Orvid King's avatar
      Nuke AsyncSocketTest.ConnectionsStorm · ea2d4e84
      Orvid King authored
      Summary: This test is the definition of how not to write a reliable test, resulting in extreme flakyness and timeouts, so nuke it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10856270
      
      fbshipit-source-id: d8b585d439c091e763075a604d2fe21b517ae93c
      ea2d4e84
    • Jatin Kumar's avatar
      Warn when running benchmark in DEBUG mode · 37f21767
      Jatin Kumar authored
      Summary:
      Cognitive overhead of remembering to use mode/opt while running
      benchmarks is just too much and easy to forget.
      
      Adding a warning message at the bottom of the benchmark result output so
      that the user gets a signal.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10274914
      
      fbshipit-source-id: a84932fa16744da9bd025ed5b01df14f95550145
      37f21767
    • Harsh Poddar's avatar
      Fix reset sequence for CustomLogFormatter · 4d657866
      Harsh Poddar authored
      Summary: There is a bug in the coloring logic which leads to the color not being cleared after statement until we log a message with INFO severity.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10519966
      
      fbshipit-source-id: 9606f24c3436eb11f3f2e313dfe5dea81d3681db
      4d657866
    • Yedidya Feldblum's avatar
      Add bidi support to IteratorFacade · 03784170
      Yedidya Feldblum authored
      Summary: [Folly] Add bidi support to IteratorFacade
      
      Reviewed By: aary
      
      Differential Revision: D10477733
      
      fbshipit-source-id: 6779580a4fdea88d29fb51454da04c9605b026bb
      03784170
    • Lee Howes's avatar
      Remove nullary continuation form of then · 611dae9a
      Lee Howes authored
      Summary:
      Remove the form of Future::then that could take a continuation with no parameters, to force consistent use of parameters.
      
      This form was already deprecated.
      
      Reviewed By: Orvid
      
      Differential Revision: D10219141
      
      fbshipit-source-id: 4f8bdeaf617d8e78a5c85aa1374f6a0d38d63da9
      611dae9a
  8. 24 Oct, 2018 6 commits
    • Adam Simpkins's avatar
      cmake: compile with -std=gnu++1z by default · dacf5bc6
      Adam Simpkins authored
      Summary:
      Switch from `-std=gnu++14` to `-std=gnu++1z`
      
      This is required in order to allow downstream projects that use folly to build
      with `-std=gnu++1z`.  The linkage for how constexpr variables are emitted
      has changed between `gnu++14` and `gnu++1z`.  If folly is compiled with
      `gnu++14` but downstream dependencies try to build with `gnu++1z` they will
      get link errors (multiple definitions) for constexpr variables defined in
      folly header files.
      
      The reverse (compiling folly with `gnu++1z` but downstream projects with
      `gnu++14`) does not seem to cause any problems.  Nonetheless, I have provided
      `CXX_STD` as a CMake option so that users can override this setting if it does
      cause any problems for some reason.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10448691
      
      fbshipit-source-id: c44f568a7ff175c432865badeaaa9b3ebbaf8987
      dacf5bc6
    • HC Zhu's avatar
      more test cases for folly::split with std::ignore · 92d74b9b
      HC Zhu authored
      Summary: Simply the code a little bit.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10609398
      
      fbshipit-source-id: 055f6fd7fb9f5768df7b0b2b28071fa53181a838
      92d74b9b
    • Lewis Baker's avatar
      Declare folly::SpinLock methods as noexcept · a917f122
      Lewis Baker authored
      Summary:
      Declare folly::SpinLock constructor and methods as noexcept so that types that have a compiler-generated default-constructor (like folly::Synchronized) get a noexcept default constructor.
      
      Also declare methods on folly::MicroSpinLock and folly::detail::Sleeper as noexcept.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10518727
      
      fbshipit-source-id: 8582fd8b3893ad25ef736bd7a63465872ebe67af
      a917f122
    • Lewis Baker's avatar
      Refactor folly::coro::Task to eliminate unnecessary synchronisation · 0d49d8d4
      Lewis Baker authored
      Summary:
      This ability to eagerly start a folly::coro::Task by calling .scheduleVia() introduced a potential race between the operation completing concurrently on another thread and the current thread then subsequently co_awaiting the returned folly::coro::Future.
      
      Thus the implementation of coro::Task's promise_type required the use of an atomic variable to decide this race.
      
      This diff eliminates the need for that synchronisation by separating the step of associating the task with an executor from the step of launching the task so that the Task is always lazily started.
      
      The folly::coro::Task<T>::scheduleVia() method has now been replaced with a .scheduleOn() method that returns a folly::coro::TaskWithExecutor<T>. The TaskWithExecutor<T> type is awaitable and will schedule the Task's execution on the bound executor when it is awaited.
      
      Also fixes a cyclic dependency issue between Promise.h and Task.h/Future.h by merging them all into Task.h.
      
      folly/futures/Future.h now defines the `folly::coro::toSemiFuture()` function for wrapping an Awaitable up into a `folly::SemiFuture<T>`. The `folly::coro::Future<T>` type and folly/experimental/coro/Future.h header has been removed.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D9948564
      
      fbshipit-source-id: 21c9ee1ec0e67d56321629b5901c3eb7cddcfe9b
      0d49d8d4
    • Cornel Rat's avatar
      Use F14 for the RequestToken cache · 3020a18c
      Cornel Rat authored
      Summary: Looks like switching to F14 speeds up RequestToken creation by ~25% in some projects.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10518982
      
      fbshipit-source-id: bf924a0a86f940f7ed36526ca6eda4fe1421f5f8
      3020a18c
    • Wez Furlong's avatar
      cmake in a _build subdir to fix macos build · c227ceae
      Wez Furlong authored
      Summary:
      This addresses a hilarious but hard to trace build problem on
      macOS.  The issue is that the build manages to resolve `folly/String.h`
      in place of `string.h` and breaks compilation of `<cstring>` and all
      that include it.
      
      The resolution is to ensure that we generate a subdir for the cmake
      build.
      
      Reviewed By: simpkins
      
      Differential Revision: D10520960
      
      fbshipit-source-id: 9bebeda69c6e28ebca146f9b96ee01bedd2d6ef1
      c227ceae
  9. 23 Oct, 2018 1 commit
    • Nathan Bronson's avatar
      checkedMalloc/free substitutes that performs sized deallocation · 9ae803c7
      Nathan Bronson authored
      Summary:
      Sized deallocation makes it faster for jemalloc to locate an
      allocation's metadata.  Accessing this functionality via ::operator
      delete(void*,size_t) is both portable and a bit more direct than
      calling sdallocx after a dynamic jemalloc check.  This diff adds small
      functions allocateBytes and deallocateBytes that are replacements
      for folly::checkedMalloc and free (and should be paired), to localize
      the #ifdef.
      
      Reviewed By: marksantaniello
      
      Differential Revision: D10496934
      
      fbshipit-source-id: eb193e1c315ca88286126f5eb68c705301ad5177
      9ae803c7
  10. 22 Oct, 2018 5 commits
    • Maged Michael's avatar
      Remove obsolete version of hazard pointers under folly/experimental · aee5ab34
      Maged Michael authored
      Summary:
      Remove obsolete version of hazard pointers under folly/experimental.
      Current version is under folly/synchronization.
      
      Reviewed By: djwatson
      
      Differential Revision: D10441558
      
      fbshipit-source-id: 36ef42f83a857ce4bdfff8b64cf9dcc179e0c804
      aee5ab34
    • Adam Simpkins's avatar
      cmake: always include files from the source directory first · 3bd7d93d
      Adam Simpkins authored
      Summary:
      Add the current source and build directories to the very front of the include
      directory list.  This ensures that folly finds its own local headers first,
      even if the install directory already contains an older version of the folly
      headers.
      
      Even though the install directory was appended to the include list after the
      current source directory in this statement, it could have ended up already in
      the include list if other dependencies (e.g., glog or gmock) were found in
      that directory.
      
      Reviewed By: Orvid
      
      Differential Revision: D10448692
      
      fbshipit-source-id: 539613a055db41d6115f8d04c5f6fa90841a414f
      3bd7d93d
    • Kirk Shoop's avatar
      move pushmi into folly namespace · b5df374b
      Kirk Shoop authored
      Summary:
      put pushmi inside the folly namespace.
      
      NOTE: we discussed in the team and decided that we preferred to have a sub-namespace for pushmi
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10455165
      
      fbshipit-source-id: d0131d96172a14746971e2de7dbac7bb10604229
      b5df374b
    • Jeroen Vaelen's avatar
      fix typo in gen docs · eb20fbbe
      Jeroen Vaelen authored
      Reviewed By: ddrcoder
      
      Differential Revision: D10461414
      
      fbshipit-source-id: 75c6ddc7979ade91917cacb0b58038bbde51172a
      eb20fbbe
    • Jeroen Vaelen's avatar
      fix ifndef error path · c474a2d7
      Jeroen Vaelen authored
      Summary: The error was pointing to a file that does not exist.
      
      Reviewed By: ddrcoder, Orvid
      
      Differential Revision: D10461496
      
      fbshipit-source-id: 4a282db547ad0924da23ea1b7652cf702599acab
      c474a2d7