1. 29 May, 2018 5 commits
    • Lee Howes's avatar
      Consistency with folly::SemiFuture continuations 5/n: make deferError use the... · 0b2ff089
      Lee Howes authored
      Consistency with folly::SemiFuture continuations 5/n: make deferError use the same exception unpacking machinery as thenError
      
      Summary:
      Step 5 in adding full set of r-value-qualified unambiguous continuation methods to folly::Future for consistency with folly::SemiFuture.
       * Back point explicit exceptions election to deferError.
      
      Reviewed By: marshallcline
      
      Differential Revision: D8124828
      
      fbshipit-source-id: 123b1cf460d2df4c8f359eff7329d34fbd8e0a9b
      0b2ff089
    • Dave Watson's avatar
      Add cleanup benchmark · e82284a8
      Dave Watson authored
      Summary: Add cleanup benchmark
      
      Reviewed By: magedm
      
      Differential Revision: D8162617
      
      fbshipit-source-id: 5ef729913db889f999c8bb051c4291e748854000
      e82284a8
    • Maged Michael's avatar
      UnboundedQueue: Add support for single consumer try_peek operation. · 05fc2561
      Maged Michael authored
      Summary: Add a try_peek() member function valid only if SingleConsumer==true that returns folly::Optional<const T*> which (if has_value() is true) contains a pointer to the first element in the queue.
      
      Reviewed By: djwatson
      
      Differential Revision: D7969290
      
      fbshipit-source-id: 3e15138f6c6523adce4da4cd99b74e0a83cd24d7
      05fc2561
    • Dave Watson's avatar
      Use Barrier in benchmark · 1d005b45
      Dave Watson authored
      Summary:
      Use folly::test::Barrier in benchmark instead of spin-waiting.  Benchmarks are more consistent now,
      and perf output is useful instead of showing a bunch of spinning.
      
      Also remove the DSched stuff from bench(), we don't want to benchmark DSched.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D8162600
      
      fbshipit-source-id: 52a1218e7fc2b87f0926dbc29c13bf0c9478e804
      1d005b45
    • Dave Watson's avatar
      Split Barrier to separate file · 97027cbe
      Dave Watson authored
      Summary: Split barrier to separate file so it can be used in other tests.
      
      Reviewed By: magedm
      
      Differential Revision: D8162586
      
      fbshipit-source-id: c3a239fe6fdb3f895557e7b93a5a960b9e871f0c
      97027cbe
  2. 28 May, 2018 9 commits
    • Yedidya Feldblum's avatar
      Avoid errnoeous deprecation warning in F14BasicSet · e9715ac6
      Yedidya Feldblum authored
      Summary:
      [Folly] Avoid errnoeous deprecation warning in `F14BasicSet`.
      
      The deprecation warning is emitted for instantiations like `F14FastSet<std::string>`.
      
      The warning is triggered by looking for move-constructibility of the mapped type for maps or `void` for sets, but `void` is not move-constructible. There are a variety of techniques to solve this, and the smallest change is to use `lift_unit_t` in the right place. `Unit` is move-constructible where `void` is not.
      
      Reviewed By: nbronson
      
      Differential Revision: D8178045
      
      fbshipit-source-id: 1ca06e84b4ed7acd415901afcbe80663513063ea
      e9715ac6
    • Yedidya Feldblum's avatar
      Cut extra template instantiations from Unit traits · 6e612d3d
      Yedidya Feldblum authored
      Summary: [Folly] Cut extra template instantiations from `Unit` traits - namely, `std::conditional` and `std::is_same`. The behavior can be done directly, while each extra template instantiations imposes some small compile-time cost.
      
      Reviewed By: Orvid
      
      Differential Revision: D8178033
      
      fbshipit-source-id: 22ba5ae810e2bca616e7db332c1f635e2520f3a7
      6e612d3d
    • Lee Howes's avatar
      Consistency with folly::SemiFuture continuations 4/n: thenError · 95016602
      Lee Howes authored
      Summary:
      Step 4 in adding full set of r-value-qualified unambiguous continuation methods to folly::Future for consistency with folly::SemiFuture.
       * Adds r-value qualified thenError that just call onError internally but in a more type safe obvious way.
       * Makes exception selection explicit to avoid exception_wrapper exception-type ambiguity in continuations.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7971326
      
      fbshipit-source-id: 8aa94161abb629d94ee8da6fb0a4bca991cf24e4
      95016602
    • Lee Howes's avatar
      Consistency with folly::SemiFuture continuations 3/n: correct define scoping · c7fd4b4b
      Lee Howes authored
      Summary:
      Step 3 in adding full set of r-value-qualified unambiguous continuation methods to folly::Future for consistency with folly::SemiFuture.
       * Undefs function-scoped defines to avoid leaking.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7997136
      
      fbshipit-source-id: 4eb188bc55134da8349e984e9eb85466d7b0042c
      c7fd4b4b
    • Orvid King's avatar
      Fix MSVC build · 4e61ea02
      Orvid King authored
      Summary: MSVC was failing to resolve `AllocTraits` within this specific context.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8179354
      
      fbshipit-source-id: 236094f704bc89ec81236e9a67054e2081590cf6
      4e61ea02
    • Orvid King's avatar
      Folly is a C++14 library · a51a28c0
      Orvid King authored
      Summary:
      There are quite a few things in Folly that are not compatible with C++11.
      
      Closes: https://github.com/facebook/folly/issues/851
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8179239
      
      fbshipit-source-id: b4ce23b98311a7c5ac15c3b7c9787f568535c950
      a51a28c0
    • Lee Howes's avatar
      Consistency with folly::SemiFuture continuations 2/n: thenTry · 242ddb11
      Lee Howes authored
      Summary:
      Step 2 in adding full set of r-value-qualified unambiguous continuation methods to folly::Future for consistency with folly::SemiFuture.
       * Adds r-value qualified thenTry which directly forwards to then, but has compile-time restrictions on the continuations that can be passed to avoid ambiguity.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7944820
      
      fbshipit-source-id: 55ee09455703bb73168694175e884b053caff426
      242ddb11
    • Lee Howes's avatar
      Invoke SemiFuture defer-continuations with same cvref as passed · f7e99444
      Lee Howes authored
      Summary:
      [Folly] Invoke SemiFutures defer-continuations with the same cvref as passed.
      for example, if passed as const&&, invoke as const&&, and if passed as volatile&, invoke as volatile&.
      This brings a little more consistency to the library.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8125144
      
      fbshipit-source-id: f2cda643aaae40e0293d5d79608541771642ce06
      f7e99444
    • Lee Howes's avatar
      Consistency with folly::SemiFuture continuations 1/n: Add Future<T>::thenValue. · 2c23497f
      Lee Howes authored
      Summary:
      Step 1 in adding full set of r-value-qualified unambiguous continuation methods to folly::Future for consistency with folly::SemiFuture.
      
       * Add r-value qualified Future<T>::thenValue.
       * Make callableResult structs consistently named so they work for Future and SemiFuture.
       * Correct call behaviour for consistency with invokeCallbackReturningFutureAsRvalue test.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7944603
      
      fbshipit-source-id: 081383a91749310472a8106289671cffa6139691
      2c23497f
  3. 27 May, 2018 1 commit
    • Orvid King's avatar
      Support debug/release distinction in FindZstd · 48eee7b8
      Orvid King authored
      Summary: This gets Folly working with the zstd package provided by vcpkg.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8176531
      
      fbshipit-source-id: 05fdd5915a677a862791cfcc5587f7a396fb4c51
      48eee7b8
  4. 26 May, 2018 4 commits
    • Orvid King's avatar
      Change calls from collectAll to collectAllSemiFuture · f2bdc48d
      Orvid King authored
      Summary: We are changing `folly::collectAll` to return `SemiFuture` rather than `Future` and this is needed as an interim step. After all calls to `collectAll` are changed to `collectAllSemiFuture`, we'll be renaming it back to `collectAll`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8157548
      
      fbshipit-source-id: 27b768ac7ff0d6572bde57f01601045a1fd5d5e5
      f2bdc48d
    • Marshall Cline's avatar
      test cases per discussion in D7923362 · fad32186
      Marshall Cline authored
      Summary:
      Discussion in D7923362 included validity & behavior of `wait()` vs. fulfillment and `wait()` vs. `then()`.
      
      18 test-cases:
      
      8 cases with `.wait(...)` and fulfillment:
      
      - Future vs. SemiFuture
      - wait() vs. wait(dur)
      - fulfilled before wait(...) call vs. during wait(...) call
      
      10 cases with `.wait(...)` and `.then(...)`:
      
      - 4 wait() cases: {Future vs. SemiFuture} that gets fulfilled {prior to, during} the wait() call.
      - 6 wait(dur) cases: {Future vs. SemiFuture} that gets fulfilled {prior to, during, after} the wait(dur) call.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8048426
      
      fbshipit-source-id: c79cc337706f08f8fb9c6057a114723320a90820
      fad32186
    • Nathan Bronson's avatar
      more tests for F14 - stateful functors · c3ffff44
      Nathan Bronson authored
      Summary:
      This diff adds recurring tests of F14's ability to use stateful
      functors with no default constructor.
      
      This is a test-only diff.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8170593
      
      fbshipit-source-id: 6ce8c7751ce32ed69b60c6884b5deb7e6378a5d1
      c3ffff44
    • rdhabalia's avatar
      Allow HHWheelTimer to set default-timeout · 299a38f8
      rdhabalia authored
      Summary:
      We are using facebook::proxygen to build Http-utility on top of it. One of the main server-connector class `Proxygen::HTTPConnector` requires `folly::HHWheelTimer` to perform timer stuff inside it.
      
      Now, `folly::HHWheelTimer` is a very large object and we would like to avoid `folly::HHWheelTimer` creation for every new `Proxygen::HTTPConnector` therefore, we are thinking to reuse `EventBase::timer()` that creates one timer per EventBase (application creates it 1 per io thread).
      
      But `EventBase::timer()` creates timer with default-time and caller can not modify it. Because of that other dependent component can't use it and proxygen gives below error:
      ```
      F0522 23:50:19.629158  7775 WheelTimerInstance.cpp:71] Check failed: defaultTimeoutMS_.count() >= 0 (-1 vs. 0)
      *** Check failure stack trace: ***
          @     0x7f5e6ce26e6d  (unknown)
          @     0x7f5e6ce28ced  (unknown)
          @     0x7f5e6ce26a5c  (unknown)
          @     0x7f5e6ce2963e  (unknown)
          @     0x7f5e6de8c1ad  proxygen::WheelTimerInstance::scheduleTimeout()
          @     0x7f5e6de7c059  proxygen::HTTPTransaction::HTTPTransaction()
          @     0x7f5e6deacff1  ...
          @     0x7f5e6deaa23a  proxygen::HTTPSession::createTransaction()
          @           0x4f7f93  proxygen::HTTPUpstreamSession::newTransaction()
          @           0x4ad9a4  Sherpa::HttpSession::sendRequest()
          @           0x4aee08  Sherpa::HttpSession::connectSuccess()
          @           0x4f5c69  proxygen::HTTPConnector::connectSuccess()
          @     0x7f5e6d47e414  folly::AsyncSocket::handleConnect()
          @     0x7f5e6d48769d  folly::AsyncSocket::handleWrite()
          @     0x7f5e6d47a05c  folly::AsyncSocket::ioReady()
      ```
      
      - add `setDefaultTimeout()` method into timer so, application can configure it.
      
      - No functional change but it facilitates application to configure defaultTimeout after `folly::HHWheelTimer` is created.
      Closes https://github.com/facebook/folly/pull/850
      
      Reviewed By: djwatson
      
      Differential Revision: D8123617
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 4dd9b19506bea380239200b6207ac05a40a0686c
      299a38f8
  5. 25 May, 2018 7 commits
    • Nathan Bronson's avatar
      support for unequal allocators · 4835f0e5
      Nathan Bronson authored
      Summary:
      The move constructor and move assignment operator for
      allocator-aware containers is supposed to allocate new memory and
      move values across when the underlying allocators are not equal.
      Previously F14 just checked that this wasn't the case.  This diff
      implements this feature.  This allows F14 tables to be moved into and
      out of allocator-managed memory segments, such as arenas or shared
      memory extents.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8022286
      
      fbshipit-source-id: ff0b220450bb76822cc68cebad079a7ef43e2429
      4835f0e5
    • Nathan Bronson's avatar
      change F14*Set::eraseInto callback arg from lvalue to rvalue · d1fdba5f
      Nathan Bronson authored
      Summary:
      The value passed to the eraseInto beforeDestroy callback will
      be immediately destroyed, so it makes more sense for it to be an rvalue
      reference than an lvalue reference.
      
      Reviewed By: yfeldblum, shixiao
      
      Differential Revision: D7986157
      
      fbshipit-source-id: 9dcc5371635a860033fe901aaad3a73230d652f6
      d1fdba5f
    • Nathan Bronson's avatar
      tests of F14 in relocatable shared memory · 74d5f333
      Nathan Bronson authored
      Summary:
      F14 maps and sets support fancy pointers and stateful allocators.
      This diff includes tests that verify this functionality and show how
      boost::interprocess's location-relative pointers can be used to construct
      address-independent F14 maps and sets in shared memory segments.
      
      This is a test-only diff.
      
      Reviewed By: shixiao
      
      Differential Revision: D7969966
      
      fbshipit-source-id: 77b3e2705bc7462518246a96b73e0f3f9c542c6a
      74d5f333
    • Yedidya Feldblum's avatar
      Cut Try ctor taking std::exception_ptr · a9ff35f4
      Yedidya Feldblum authored
      Summary:
      [Folly] Cut `Try` ctor taking `std::exception_ptr`.
      
      It is legacy, from a time before `exception_wrapper`.
      
      Reviewed By: marshallcline
      
      Differential Revision: D8110107
      
      fbshipit-source-id: 2d8f4d56fdf1043012d72813a8686a8d02392a0b
      a9ff35f4
    • Yedidya Feldblum's avatar
      Cut Promise::setException overload taking std::exception_ptr · 5556aa3d
      Yedidya Feldblum authored
      Summary:
      [Folly] Cut `Promise::setException` overload taking `std::exception_ptr`.
      
      It is from a time before `exception_wrapper`.
      
      Reviewed By: marshallcline
      
      Differential Revision: D8110117
      
      fbshipit-source-id: f3a3f150267efc8c22a83dc90c7f52a728ef3de7
      5556aa3d
    • Yedidya Feldblum's avatar
      Cut SharedPromise::setException overload taking std::exception_ptr · bf7c9957
      Yedidya Feldblum authored
      Summary:
      [Folly] Cut `SharedPromise::setException` overload taking `std::exception_ptr`.
      
      It is from a time before `exception_wrapper`.
      
      Reviewed By: marshallcline
      
      Differential Revision: D8132039
      
      fbshipit-source-id: eb82f6b766fd5cf82443ef447bbc751e7319f0ab
      bf7c9957
    • Jeffrey Shen's avatar
      Add a way to schedule runs for startDelay modulo interval · 142c1e1a
      Jeffrey Shen authored
      Summary:
      Currently, scheduling only allows specifying an interval, not the next run time. This makes it impossible to schedule for a given startDelay modulo the interval. This refactors things internally to use a customizable NextRunTimeFunc, and exposes a way to run at a consistent startDelay or pass in a NextRunTimeFunc.
      
      A use case: if we have n FunctionSchedulers schedule with different startDelays but the same interval, and they sync up (e.g. they all get blocked on some IO call, which eventually gets fixed), then they won't unsync or will unsync slowly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7651111
      
      fbshipit-source-id: 3c7a49dbfaa073b913107474f039a53a0a03cfa0
      142c1e1a
  6. 24 May, 2018 9 commits
    • Andre Pinto's avatar
      Fix build on 32-bit platforms · aaa4b610
      Andre Pinto authored
      Summary: This fixes a compile error on 32-bit platforms.
      
      Reviewed By: Orvid
      
      Differential Revision: D8147916
      
      fbshipit-source-id: 86b66b684bed5ffb262630a361cf239948b8bb97
      aaa4b610
    • Andrii Grynenko's avatar
      Fix Executor unsetting in waitVia · 9af54d9a
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D8134836
      
      fbshipit-source-id: 0b736bd61aa024574756634358ddc0e45c31944b
      9af54d9a
    • Marshall Cline's avatar
      add contracts to Promise · 87ab4855
      Marshall Cline authored
      Summary: Add contracts to Promise
      
      Reviewed By: LeeHowes
      
      Differential Revision: D7923804
      
      fbshipit-source-id: f7f29646d523ee69f00ac8576e2edf7e003f25e3
      87ab4855
    • Subodh Iyengar's avatar
      Add detachEvb to AsyncUDPSocket · b02ec278
      Subodh Iyengar authored
      Summary:
      Detach evb from asyncudpsocket to be able to
      switch the socket between threads
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8131599
      
      fbshipit-source-id: 5d2a6f9b43b72076da1f6c09ce37b3c0bcd43db2
      b02ec278
    • Maged Michael's avatar
      hazptr: Rename await_zero_bulk_reclaims to wait_for_bulk_reclaim · e2a84628
      Maged Michael authored
      Summary: Change name to reserve the word await for coroutines.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8076750
      
      fbshipit-source-id: 38771dc22c39e194888ac272299ec1ae83df6389
      e2a84628
    • Stepan Palamarchuk's avatar
      Add const versions of begin/end · a6fc9c0a
      Stepan Palamarchuk authored
      Summary:
      `ConcurrentHashMap` provides `cbegin` and `cend`, but they are not suitable for range-based loops.
      This diff adds const versions of `begin` and `end` that are required for range-based loops.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8131142
      
      fbshipit-source-id: b3af164d403c86ddfe4d27aaca293fbc4e2bb9d2
      a6fc9c0a
    • Marshall Cline's avatar
      add class-level descrips to SemiFuture & Future · dfa07dcd
      Marshall Cline authored
      Summary: To expedite, I'm splitting the class-level summary-docs from the method-level docs. This is just the former.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D7956570
      
      fbshipit-source-id: b38539082ac0f6537f20a4f1d5a097407c277adc
      dfa07dcd
    • Saif Hasan's avatar
      fix build · 509b213e
      Saif Hasan authored
      Summary:
      fbthrift generate errorneous code when cpp type IOBuf pointer is used. Let's use
      IOBuf object instead as it is cheap to copy construct and underlying buffer is
      anyway shared when objects are copied.
      
      Reviewed By: plapukhov
      
      Differential Revision: D8130040
      
      fbshipit-source-id: 3c109a85951054fed890707f56170b46cfefc917
      509b213e
    • Matthieu Martin's avatar
      Fix possible deadlock in GILAwareManualExecutor · 6616c8e8
      Matthieu Martin authored
      Summary:
      See code comment
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D8130722
      
      fbshipit-source-id: c2a3e4b0de1fe7d07e28c4a7558e4367a1591ac1
      6616c8e8
  7. 23 May, 2018 5 commits
    • Yedidya Feldblum's avatar
      Give Try constructors pedantic exception specifiers · 72cb9df4
      Yedidya Feldblum authored
      Summary: [Folly] Give Try constructors and assignment operators pedantic exception specifiers deriving from corresponding exception specifiers of element type.
      
      Reviewed By: marshallcline
      
      Differential Revision: D8105158
      
      fbshipit-source-id: 3cc9aae022ddaeef3ef2b742dde8ba084bfca830
      72cb9df4
    • Yedidya Feldblum's avatar
      Make exception_wrapper be noexcept-copyable · be791fd5
      Yedidya Feldblum authored
      Summary:
      [Folly] Make `exception_wrapper` be `noexcept`-copyable.
      
      This works across the storage types:
      * InSitu - only store `noexcept`-copyable objects in-situ.
      * OnHeap - `std::shared_ptr` is `noexcept`-copyable.
      * Thrown - `std::exception_ptr` is in practice `noexcept`-copyable since it is a smart-ptr for thrown objects.
      
      Reviewed By: marshallcline
      
      Differential Revision: D8109991
      
      fbshipit-source-id: e637c72466b22ab3076f52b4654a7538dcb1d30f
      be791fd5
    • Andrii Grynenko's avatar
      Use Executor::KeepAlive to store Executor in Core · b3e7e89c
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D8022229
      
      fbshipit-source-id: 1ba1d777cbbeb1d1ad95dc3f4bae6b3d431b9440
      b3e7e89c
    • Dan Melnic's avatar
      Back out "Iterate only through the threads that have in use entries" · 360d0d32
      Dan Melnic authored
      Summary:
      Original commit changeset: 577063f920fb
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: djwatson
      
      Differential Revision: D8126439
      
      fbshipit-source-id: 30154738262274a688f432465119b0730d395df6
      360d0d32
    • Yedidya Feldblum's avatar
      Invoke Futures then-continuations with the same cvref as passed · 9a4f6fdc
      Yedidya Feldblum authored
      Summary:
      [Folly] Invoke Futures `then`-continuations with the same cvref as passed.
      
      for example, if passed as `const&&`, invoke as `const&&`, and if passed as `volatile&`, invoke as `volatile&`.
      
      This brings a little more consistency to the library.
      
      Reviewed By: LeeHowes, phoad
      
      Differential Revision: D8109784
      
      fbshipit-source-id: 8dd56c6197211091ed53eba94aeec9d604268d15
      9a4f6fdc