1. 19 Oct, 2017 11 commits
    • Yedidya Feldblum's avatar
      Add InlineExecutor.cpp to Makefile.am · c7813369
      Yedidya Feldblum authored
      Summary: [Folly] Add `InlineExecutor.cpp` to `Makefile.am`.
      
      Reviewed By: Orvid
      
      Differential Revision: D6101859
      
      fbshipit-source-id: 4cd0f875dedb548189722fd719f4424d485e1b02
      c7813369
    • Yedidya Feldblum's avatar
      Fix fibers build on older boost · 70d3004b
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `folly/fibers/` build on older boost.
      
      Where `jump_fcontext` takes `intptr_t` rather than an actual pointer, and we warn about implicit conversions from pointers to integral types.
      
      Reviewed By: Orvid
      
      Differential Revision: D6098230
      
      fbshipit-source-id: 61bd7bdff5de728d3febe8b35c97d024ab6f236a
      70d3004b
    • Christopher Dykes's avatar
      Ensure curly-braces around control-flow · 7ebe7c2a
      Christopher Dykes authored
      Summary: The style guidelines say control flow should always have curly braces, and we follow that, mostly. This just uses clang-tidy to clean up everywhere that we weren't.
      
      Reviewed By: markisaa, luciang
      
      Differential Revision: D6097377
      
      fbshipit-source-id: bfe6766c37bd863ecf68851ef93265a200d4259d
      7ebe7c2a
    • James Sedgwick's avatar
      move ApplyTuple to functional/ · bfa61031
      James Sedgwick authored
      Summary: as above
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6086563
      
      fbshipit-source-id: ab7f50ba46ebd1dbef6438f956258b2fbb13cb5c
      bfa61031
    • Peter Alexander's avatar
      Add ProducerConsumerQueue::capacity() · 7111b632
      Peter Alexander authored
      Summary: Simple addition. Easy to track externally, but might as well provide it in the class if it is readily available.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6093826
      
      fbshipit-source-id: 9d8c02891b2cea9ce0d3f6ea78e1e0055b536eb8
      7111b632
    • Yedidya Feldblum's avatar
      Revert D6050464: [Folly] Move folly/Hash.h to folly/hash/ · dce47b8a
      Yedidya Feldblum authored
      Summary:
      This reverts commit 64eb65aac8e3e7cd0126e65ca3998bfe167e2d73
      
      bypass-lint
      
      Differential Revision: D6050464
      
      fbshipit-source-id: 1ed63f30837dc11ae57b316f1f7cb233a210894a
      dce47b8a
    • Walker Mills's avatar
      Add window overload that takes an executor to prevent stack overflow · ebded22a
      Walker Mills authored
      Summary:
      AIUI, if there is no executor available, then callbacks are executed inline. `folly::window` uses a recursive helper function (`spawn`) to handle chaining callbacks. So if `window` is used on a large enough collection of `Future`s without executors (e.g., created by `makeFuture`, or have otherwise already completed), you get a stack overflow. A minimal repro looks like:
      ```
      
      int main(int argc, char** argv) {
        std::vector<int> v(100000);
        for(int i=0; i < v.size(); i++) {
          v[i] = i;
        }
      
        std::vector<folly::Future<folly::Unit>> f =
            folly::window(
                std::move(v),
                [](int /* unused */) { return folly::makeFuture(); },
                1);
        folly::collectAll(f).get();
      }
      ```
      
      This diff resolves the issue by adding an overload of `folly::window` which takes an executor as its first parameter. The executor-less `window` overload calls through to the new function using an `InlineExecutor` as the default executor.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6038733
      
      fbshipit-source-id: 5dcab575592650efa2e106f12632ec06817a0009
      ebded22a
    • Yedidya Feldblum's avatar
      Move folly/Hash.h to folly/hash/ · 34a2f64f
      Yedidya Feldblum authored
      Summary: [Folly] Move `folly/Hash.h` to `folly/hash/`.
      
      Reviewed By: jsedgwick
      
      Differential Revision: D6050464
      
      fbshipit-source-id: 64eb65aac8e3e7cd0126e65ca3998bfe167e2d73
      34a2f64f
    • Arkady Shapkin's avatar
      Enable bug workaround also for MSVC 2017.4 · af6ddfa2
      Arkady Shapkin authored
      Summary:
      Workaround a bug in template instantiation in MSVC 2017 U3/4 with /permissive-
      
      https://developercommunity.visualstudio.com/content/problem/81223/incorrect-error-c5037-with-permissive.html
      
      /cc Orvid
      Closes https://github.com/facebook/folly/pull/691
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6085652
      
      Pulled By: Orvid
      
      fbshipit-source-id: f068dc3f8e474163815fc497b05410fe76834a52
      af6ddfa2
    • Boliu Xu's avatar
      Fix incorrect example usage in stop_watch · 5b7fc789
      Boliu Xu authored
      Summary: As titled.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6087099
      
      fbshipit-source-id: 1c346fa6f65b5ea58e728759905560ae5ad9cc9d
      5b7fc789
    • Richard Fillman's avatar
      Move small fields to avoid padding in AsyncSocket.h and AsyncSSLSocket.h · e5b4d8b8
      Richard Fillman authored
      Summary: Compiled mcrouter with the 'Wpadded' flag to try to find any wasted space. Mcrouter itself did not have anything, but there was a lot in AsyncSocket.h and AsyncSSLSocket.h so looked into those and removed a bit of wasted space
      
      Reviewed By: yfeldblum, brianwatling
      
      Differential Revision: D6033977
      
      fbshipit-source-id: 2dc127208e09980be6a5db576b45d30ac6e044ff
      e5b4d8b8
  2. 18 Oct, 2017 10 commits
    • James Sedgwick's avatar
      move futures/QueuedImmediateExecutor to executors/QueuedImmediateExecutor · fe34da59
      James Sedgwick authored
      Summary: as above
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6076779
      
      fbshipit-source-id: 4c223ab9fce3be8544f6f807781c3d0a99b61dad
      fe34da59
    • Andrew Krieger's avatar
      Workaround MSVC bug with referencing template constructors before definition · ca0e432d
      Andrew Krieger authored
      Summary:
      MSVC has a bug where it is unable to match an out-of-line constructor (and
      possibly other kind of member) to the definition if it is implicitly referenced
      before the definition is processed. The guilty method is
      SemiFuture<Unit> makeSemiFuture(). Moving it after the constructor definitions
      resolves the issue.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6042277
      
      fbshipit-source-id: 97fe97c0edf3df3d9e3b808968b450c73959b600
      ca0e432d
    • James Sedgwick's avatar
      move futures/ScheduledExecutor to executors/ScheduledExecutor · dbf0c410
      James Sedgwick authored
      Summary: see title
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6062601
      
      fbshipit-source-id: edd9a5e85f4ebecd1a6f1004a4d3b8b43b935c2b
      dbf0c410
    • Yedidya Feldblum's avatar
      Move folly/MallctlHelper.h to folly/memory/ · a936fbd8
      Yedidya Feldblum authored
      Summary: [Folly] Move `folly/MallctlHelper.h` to `folly/memory/`.
      
      Reviewed By: aary
      
      Differential Revision: D6087216
      
      fbshipit-source-id: 4e0fa4aea976e2578127d3c340e0e9b559a224ca
      a936fbd8
    • James Sedgwick's avatar
      move Partial to functional/ · e372e3d3
      James Sedgwick authored
      Summary: as above
      
      Reviewed By: ngoyal
      
      Differential Revision: D6087941
      
      fbshipit-source-id: 948ff4f2faa87dd34f87d14ea01c83335f850a27
      e372e3d3
    • Christopher Dykes's avatar
      Use nullptr rather than 0 when initializing pointers · d7ea6b71
      Christopher Dykes authored
      Summary:
      Because we do this in a few places, and `nullptr` makes it far clearer what the intention is.
      Note that with `-Wzero-as-null-pointer-constant` under GCC, doing `std::function<void()> f = {}` initializes `f` with a `0` rather than `nullptr`, triggering the warning, so I've enabled it there as well.
      It is not currently possible to actually enable `-Wzero-as-null-pointer-constant`, because GCC 5 reports conversions resulting from a default value as occuring at the call-site rather than at the location where the parameter is defined, and the default allocator in libstdc++ is not clean for this particular warning -_-...
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6046746
      
      fbshipit-source-id: 6135bb20a503c861838575cf973324d74d75ca69
      d7ea6b71
    • James Sedgwick's avatar
      move futures/DrivableExecutor to executors/DrivableExecutor · dca6f3ea
      James Sedgwick authored
      Summary: as title
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6062437
      
      fbshipit-source-id: 4f99e779e280fdb0b1f035013caff18764e86ab5
      dca6f3ea
    • Yedidya Feldblum's avatar
      Lift the invoke helper in Function.h · 86617507
      Yedidya Feldblum authored
      Summary: [Folly] Lift the `invoke` helper in `Function.h`.
      
      Reviewed By: aary
      
      Differential Revision: D6050569
      
      fbshipit-source-id: da07901b8d058b0199d23db675c0fb9082fdf67d
      86617507
    • James Sedgwick's avatar
      move python/NotificationQueueExecutor to futures/ · 11b73c8f
      James Sedgwick authored
      Summary: as above
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6076757
      
      fbshipit-source-id: afe144129e8a0242ba6baee96a84a9084e6e2571
      11b73c8f
    • Yedidya Feldblum's avatar
      Simplify impl of setThreadName · bf58d50a
      Yedidya Feldblum authored
      Summary: [Folly] Simplify impl of `setThreadName`.
      
      Reviewed By: Orvid, ot
      
      Differential Revision: D6075179
      
      fbshipit-source-id: 720f29cc688f97b936813898238b8eb26b8a6141
      bf58d50a
  3. 17 Oct, 2017 7 commits
    • Dan Melnic's avatar
      Do not set WriteFlags::WRITE_MSG_ZEROCOPY if the buffer ! isManaged() · 68d54bdd
      Dan Melnic authored
      Summary: Do not set WriteFlags::WRITE_MSG_ZEROCOPY if the buffer isShared()
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6068711
      
      fbshipit-source-id: fff14dcd4fcb20c9dbb60794420845042518922c
      68d54bdd
    • Yedidya Feldblum's avatar
      Un-templatize Range::str · 899d83f0
      Yedidya Feldblum authored
      Summary: [Folly] Un-templatize `Range::str`.
      
      Reviewed By: ot
      
      Differential Revision: D6075642
      
      fbshipit-source-id: 08fc399c43750d34463de7634be4fe386b5db97c
      899d83f0
    • Yedidya Feldblum's avatar
      Refactor ShutdownSocketSet atomic state machine · a25c5a91
      Yedidya Feldblum authored
      Summary:
      [Folly] Refactor `ShutdownSocketSet` atomic state machine.
      
      * Format.
      * Use `while` over `goto`.
      * Avoid `memory_order_acq_rel` as the single-argument memory order; some platforms fail to build that.
      * Use `memory_order_relaxed` for all atomic operations because stronger memory orders are not actually required: the atomic state never serves as a barrier for synchronizing loads and stores of associated data because there is no associated data.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D6058292
      
      fbshipit-source-id: d45d7fcfa472e6e393a5f980e75ad9ea3358bab3
      a25c5a91
    • Yedidya Feldblum's avatar
      An InlineExecutor singleton · 9917cdab
      Yedidya Feldblum authored
      Summary:
      [Folly] An `InlineExecutor` singleton.
      
      Using the Leaky Meyers Singleton pattern, so that it is always available whenever required.
      
      Differential Revision: D6074534
      
      fbshipit-source-id: bd4c9cd6a1e60c80de5d2eef1cb6a1e7f16b4e50
      9917cdab
    • Andrew Krieger's avatar
      Don't make copies of std::string or fbstring when converting. · f82f2b0d
      Andrew Krieger authored
      Summary:
      This overload of estimateSpaceNeeded was taking a Src by
      value, but Src is constrained by IsSomeString which only returns
      true for std::string or fbstring, so this was inducing a copy
      in any situation where folly::to<> is used with varargs which
      contain fb/string arguments.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6059517
      
      fbshipit-source-id: adc239f9049e161fc4b750bae0e3de5dbdcd1bfc
      f82f2b0d
    • Yedidya Feldblum's avatar
      Make Range.h and FBString.h mutually independent · 1d4de585
      Yedidya Feldblum authored
      Summary:
      [Folly] Make `Range.h` and `FBString.h` mutually independent.
      
      This means that `Range` cannot directly know about `fbstring`, so any interactions between the two types must be indirected through templates.
      
      Motivation: `FBString.h` is a relatively heaviweight `#include` for things that need `Range.h` but which do not use `fbstring`.
      
      Reviewed By: ericniebler
      
      Differential Revision: D6062434
      
      fbshipit-source-id: e2f21c33f482eadffd0a8679eff4ece59bab53e9
      1d4de585
    • Yedidya Feldblum's avatar
      Shrink integral hasher specialization implementations · d201571c
      Yedidya Feldblum authored
      Summary:
      [Folly] Shrink integral `hasher` specialization implementations.
      
      Instead of giving them bodies, just use inheritance.
      
      Reviewed By: luciang
      
      Differential Revision: D6067757
      
      fbshipit-source-id: f71bd36132e1b66002493474825894b03754b34f
      d201571c
  4. 16 Oct, 2017 5 commits
    • Chad Austin's avatar
      fix typo in invalid log level error message · b83985c4
      Chad Austin authored
      Reviewed By: simpkins
      
      Differential Revision: D6068742
      
      fbshipit-source-id: a3b3b7fe4a6da8f250e5b9593f66b9f8a9345136
      b83985c4
    • qiao hai-jun's avatar
      fix typo · 0918ae11
      qiao hai-jun authored
      Summary: Closes https://github.com/facebook/folly/pull/692
      
      Differential Revision: D6066294
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: a533527058b8b5bc71fb6f40bad31a50e8c3f585
      0918ae11
    • Yedidya Feldblum's avatar
      4-way overloads for SemiFuture::value · 943408f5
      Yedidya Feldblum authored
      Summary:
      [Folly] 4-way overloads for `SemiFuture::value`.
      
      Overload on the receiver reference category and `const`-qualification, deriving the return type reference category and `const`-qualification. Like `Optional`, `Try`, etc.
      
      Differential Revision: D6062006
      
      fbshipit-source-id: d7396cd4d4bb62e99445d5f61cb360898fa1c3f3
      943408f5
    • Ognjen Dragoljevic's avatar
      Fix hash overloads for integral types · 4e2b0bb9
      Ognjen Dragoljevic authored
      Summary:
      `folly/Hash.h:379:12: error: implicit instantiation of undefined template 'folly::hasher<unsigned long, void>'`
      So, folly is unable to hash the very type it returns: `size_t`. Namely, folly has overloads for `uint32_t` and `uint64_t` which on my Mac map to `int` and `long long` respectively. `size_t` on the other hand maps to `long` which is neither.
      Rather than overloading library types (which are just typedefs), we should overload all the built-in types: `char`, `short`, `int`, `long`, `long long`, `signed` and `unsigned` variants (with special treatment of `char`).
      
      Reviewed By: yfeldblum, luciang
      
      Differential Revision: D6051600
      
      fbshipit-source-id: d59569dab963cbe0329aa589ff321cfb22308193
      4e2b0bb9
    • Andrew Krieger's avatar
      constexpr estimateSpaceNeeded for string literals. · b02d4348
      Andrew Krieger authored
      Summary:
      Partially inspired by WillerZ's investigation into faster compiling
      StringPiece work, I thought this would be an easy drop in that short
      circuits some compilation logic (or possibly is strictly better, since the
      StringPiece conversion method isn't constexpr).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6059537
      
      fbshipit-source-id: 072f56e58aa47db10b54825cac8a05dc035b295c
      b02d4348
  5. 15 Oct, 2017 1 commit
    • Marc Celani's avatar
      Move retrying method to separate header in folly/futures · 24a9e5fd
      Marc Celani authored
      Summary: folly/futures depends on folly/Random.h, which in turn depends on <random>, which is a fairly large header. Most users of folly::futures do not use retrying, so separate it into a separate header.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6028468
      
      fbshipit-source-id: d8155fe2ddff1a65c265a18f040ee6f1be3f3f0a
      24a9e5fd
  6. 13 Oct, 2017 5 commits
    • Yedidya Feldblum's avatar
      Style fixes for folly/experimental/gdb/README.md · 371636e9
      Yedidya Feldblum authored
      Summary:
      [Folly] Style fixes for `folly/experimental/gdb/README.md`.
      
      Should have no effect on Github rendering, but should affect PHabricator rendering.
      
      Reviewed By: Orvid, kennyyu
      
      Differential Revision: D6055017
      
      fbshipit-source-id: 54204a2b77beeb884cdc486207809f78ac80afe2
      371636e9
    • Neel Goyal's avatar
      Add AsyncSocketException.cpp to build sources · 80acc620
      Neel Goyal authored
      Summary: Add AsyncSocketException.cpp to the list of files to build in Makefile.am
      
      Reviewed By: knekritz
      
      Differential Revision: D6051989
      
      fbshipit-source-id: 72083a609fc994770eca078bfef5a0ed04322bfc
      80acc620
    • Vitaly Berov's avatar
      Replace ShutdownSocketSet to singleton · 4abb5a3a
      Vitaly Berov authored
      Summary:
      We recently found out that ShutdownSocketSet consumes 150+MB for our service, which uses duplex channels. The problem is that we create ~1000 of ThriftServers, and each of the creates its own ShutdownSocketSet.
      In reality, ShutdownSocketSet is only needed to kill all socket's FD in emergency before crash dump is taken, so they don't hand around waiting for crash dump to complete. There is no need to keep a SSS per ThriftServer, singleton should work just fine.
      There is a problem here, though. Currently a ThriftServer has 'immediateShutdown' method, which kills all sockets from SSS. So, if SSS becomes a singleton, and we have more than one ThriftServer, calling 'immediateShutdown' on one will kill sockets from the other one. First, it's a quite surprising behavior, and second, it complicates unit tests, which emulate thrift servers running in different processes.
      
      As a result,
      1. ShutdownSocketSet is created as a singleton, but each ThriftServer still keeps weak ptr to it (mostly for unit tests support).
      2. replaceShutdownSocketSet method is added to ThriftServer.h, so unit tests could set different SSS for different ThriftServers.
      3. method immediateShutdown is removed from ThriftServer, because its behavior would be 'surprising'.
      
      There still may be unexpected consequences of this change for the tests because of Singleton, but let's see.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6015576
      
      fbshipit-source-id: dab70dbf82d01bcc71bbe063f983e862911ceb24
      4abb5a3a
    • Lucian Grijincu's avatar
      folly: AsyncSocketException: move implementation to .cpp, refactor · 69d97159
      Lucian Grijincu authored
      Reviewed By: yfeldblum
      
      Differential Revision: D6042832
      
      fbshipit-source-id: c716ee672c4acfa39cab9f10f3b3f88ca770cd20
      69d97159
    • Yedidya Feldblum's avatar
      Move folly/Checksum.h into folly/hash/ · d31633e6
      Yedidya Feldblum authored
      Summary: [Folly] Move `folly/Checksum.h` into `folly/hash/`.
      
      Reviewed By: Orvid
      
      Differential Revision: D6045825
      
      fbshipit-source-id: 02d3e6a49e2c0fc115cfee09e1186be7a13525ba
      d31633e6
  7. 11 Oct, 2017 1 commit
    • Miroslav Crnic's avatar
      Add support for clang intrinsic constexpr · 42a989fa
      Miroslav Crnic authored
      Summary: Newer versions of clang >=3.4 support intrinsic constexpr
      
      Reviewed By: Orvid
      
      Differential Revision: D6008856
      
      fbshipit-source-id: 4e40a7032464216d181d76a854cafb2ab4be1be0
      42a989fa