1. 16 Mar, 2018 8 commits
    • Neel Goyal's avatar
      Add peer identity interface to AsyncTransport · 25702fca
      Neel Goyal authored
      Summary: Add a generic Identity class to AsyncTransport that applications are free to implement to convey identity information for both self and peer.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7177085
      
      fbshipit-source-id: f1dcd9bb2dbf57751fe7ef0608663ddc1d527b92
      25702fca
    • Qinfan Wu's avatar
      Enable tests and fix build · ca53d920
      Qinfan Wu authored
      Summary: [Folly][coro] Enable tests and fix build.
      
      Reviewed By: yfeldblum, modocache
      
      Differential Revision: D7304801
      
      fbshipit-source-id: 0975201a0521cf8275d82ee6aaebfa02986c5b79
      ca53d920
    • Xiao Shi's avatar
      separate out F14_VECTOR_INTRINSICS_AVAILABLE check · 4c12379d
      Xiao Shi authored
      Summary:
      This check is useful for other platforms and in other context where F14 is
      included. For the sake of fast compilation, separate this macro out so that one
      doesn't have to pull in the entire F14Map/Set headers to use this macro.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7300144
      
      fbshipit-source-id: d1aeb7e3c5d2f15703dd356fc54622751e3fa71a
      4c12379d
    • Steve O'Brien's avatar
      folly/String: drop unneeded type_traits header · faed3cec
      Steve O'Brien authored
      Summary: Unneeded header in frequently-used file; drop it
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7165040
      
      fbshipit-source-id: b60a3cdf924ab93961a7ead3ac0653a2339a4faf
      faed3cec
    • Steve O'Brien's avatar
      remove expensive boost header from EventBase · 5e420c8c
      Steve O'Brien authored
      Summary: Removing expensive, unneeded includes (esp. Boost includes) gradually.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7144471
      
      fbshipit-source-id: b568ec75251d360a72e7fa2d656ab9463b5a4728
      5e420c8c
    • Yanan Xin's avatar
      Add getTaskQueueSize() method in CPUThreadPoolExecutor · c3ec0bd2
      Yanan Xin authored
      Summary: Add getTaskQueueSize() method in CPUThreadPoolExecutor
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7294802
      
      fbshipit-source-id: 1f37558a1f14fcc2888c654248d649365c323432
      c3ec0bd2
    • Orvid King's avatar
      Fix the build on Windows due to MTU_DISCOVER · 131cbd22
      Orvid King authored
      Summary: Windows defines `IP_MTU_DISCOVER`, but does it differently from everywhere else, so disable it unless everything required is defined.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7298640
      
      fbshipit-source-id: 8ecc2dfd9ba83f31e9d72e0f42fb4fbf8f3e50b5
      131cbd22
    • Nathan Bronson's avatar
      switch from assert to FOLLY_SAFE_DCHECK · de02e37f
      Nathan Bronson authored
      Summary:
      assert(x) doesn't mark x as used in prod builds, causing problems
      for builds that warn on unused variables and promote warnings to errors.
      This diff changes assert calls to FOLLY_SAFE_DCHECK, which is better in
      this regard.
      
      Reviewed By: phoad, shixiao
      
      Differential Revision: D7291084
      
      fbshipit-source-id: 1ae48a271f30182ac8a1c2cf126af0e6b4fd0a25
      de02e37f
  2. 15 Mar, 2018 6 commits
    • Yedidya Feldblum's avatar
      Alias std::launder on MSVC · 79778122
      Yedidya Feldblum authored
      Summary:
      [Folly] Alias `std::launder` on `MSVC` to avoid ambiguity.
      
      Fixes #802.
      
      Reviewed By: Orvid
      
      Differential Revision: D7286052
      
      fbshipit-source-id: 7cd89c9ad236a433f53fbdb9e2e024b85105827e
      79778122
    • Yedidya Feldblum's avatar
      Fix SingletonThreadLocal use from headers · d4ec31ab
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `SingletonThreadLocal` use from headers included by separate dynamically-loaded modules.
      
      There is no need in `SingletonThreadLocal` specifically to check for double-registration and `SingletonThreadLocal` does not support mocks, so `LeakySingleton` may be bypassed entirely.
      
      Reviewed By: djwatson
      
      Differential Revision: D7283390
      
      fbshipit-source-id: 45295c4dab233b9373ed32a47d4c80832b0f9eff
      d4ec31ab
    • Dave Watson's avatar
      Use EXPEDITED by default · b07974cc
      Dave Watson authored
      Summary:
      MEMBARRIER_CMD_SHARED is too slow, use EXPEDITED (or the mprotect hack if kernel is too old).
      
      hazptr has been using EXPEDITED for a while, the only other users are RCU and read_mostly_shared_ptr
      
      Reviewed By: yfeldblum, osandov
      
      Differential Revision: D7280190
      
      fbshipit-source-id: 2a9aeab035f8996566b557d7f406686c361a37d7
      b07974cc
    • Yang Zhang's avatar
      Add constexpr_add/sub_overflow_clamped in folly/ConstexprMath.h · 4989422c
      Yang Zhang authored
      Summary: Provide UBSAN-clean add/sub function on integral types. Helps to avoid overflow.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7230723
      
      fbshipit-source-id: 10fa54b405f9643dfbbb1940cf100516fd1341e1
      4989422c
    • Alexander Blom's avatar
      Make EventBase extend ScheduledExecutor · a1699e9f
      Alexander Blom authored
      Summary:
      This makes it easier to use EventBase in cases where
      classes require ScheduledExecutor instead of Executor. Previously
      the client would have to implement a wrapper around EventBase.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7179869
      
      fbshipit-source-id: 21730a56ed5b71fd731ffd272f9f3752b70d63ce
      a1699e9f
    • Xiao Shi's avatar
      expose Default{Hasher, KeyEqual, Alloc} to platforms without intrinsics available · 8579ad47
      Xiao Shi authored
      Summary: Expose Default{Hasher, KeyEqual, Alloc} to platforms without intrinsics available
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7277896
      
      fbshipit-source-id: 92f46aef9ab0926c32c85e29e368f7c0b58c2b3e
      8579ad47
  3. 14 Mar, 2018 8 commits
    • Nathan Bronson's avatar
      add __builtin_ctz and __builtin_ctzl · 9cf96558
      Nathan Bronson authored
      Summary: Add missing WIN32 compat builtins
      
      Reviewed By: Orvid
      
      Differential Revision: D7276240
      
      fbshipit-source-id: 094c0861126b3477e9112987f033edacbde4aca4
      9cf96558
    • Tom Jackson's avatar
      eachTryTo, takeWhile · 3c047a7b
      Tom Jackson authored
      Reviewed By: yfeldblum
      
      Differential Revision: D7257019
      
      fbshipit-source-id: 2fe54fe1d42bfe81b2f6f8e43ae0f7e738e93edd
      3c047a7b
    • Dave Watson's avatar
      Fix fork behavior · 608edf73
      Dave Watson authored
      Summary:
      hazptr_priv_list needs to be reinitialized on fork, as well as ODR violations.
      
      This broke stuff when trying to land D7164130
      
      TL;DR the thread_locals need to be in a .cpp file, the templates don't always get merged correctly, especially in the face of dlopen.
      
      You can, however, use a thread_local * pointer cache to the object.  This is basically what folly::SingletonThreadLocal does.
      
      Folly's ThreadLocal runs destructors when forking even too, so nothing special is required.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7256905
      
      fbshipit-source-id: c817167b5c3db27fa929feaa39295fd939c1cb4c
      608edf73
    • Xiao Shi's avatar
      lift Default{Hasher, KeyEqual, Alloc} out of detail namespace · bb5932ed
      Xiao Shi authored
      Summary:
      Expose the default structs in `folly::f14` namespace so that users _could_
      potentially refer to them.
      
      Reviewed By: nbronson
      
      Differential Revision: D7271846
      
      fbshipit-source-id: 81a193209e59ed80260098ed97c99a7b6f2ad151
      bb5932ed
    • Yedidya Feldblum's avatar
      Parameterize AlignedSysAllocator by a policy · d277c610
      Yedidya Feldblum authored
      Summary: [Folly] Parameterize `AlignedSysAllocator` by a policy.
      
      Reviewed By: ot
      
      Differential Revision: D7246946
      
      fbshipit-source-id: 5b6a89707c242e49bdbafba9dec6df4c65ef385c
      d277c610
    • Bennett Magy's avatar
      Added forward declaration of ObserverCreator · 2195ec35
      Bennett Magy authored
      Summary:
      For some reason, compilation of certain Observable code fails in opt mode with the error that Observer::core_ is private.
      
      It seems that ObserverCreator is not recognized as a friend of Observer. This forward declaration of ObserverCreator seems to fix this issue.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7268318
      
      fbshipit-source-id: 1ea76efb0f50cb8a6b28147305ec7547f55338b8
      2195ec35
    • Yedidya Feldblum's avatar
      Enable -Wunused-value · aab80ef3
      Yedidya Feldblum authored
      Summary: [Folly] Enable `-Wunused-value`.
      
      Reviewed By: Orvid
      
      Differential Revision: D7266246
      
      fbshipit-source-id: dc9b85a5f8ce67802cc2fa94746a26529012ec22
      aab80ef3
    • Nathan Bronson's avatar
      fix F14 MSVC build · 7fd46ef5
      Nathan Bronson authored
      Summary:
      F14 was missing the MSVC portability shims, and also needs to
      use an MSVC-specific intrinsic to get the high word of a 64-bit multiply.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7263349
      
      fbshipit-source-id: f47ceb2b2370d9bef1409e4790b236752c9f6ac4
      7fd46ef5
  4. 13 Mar, 2018 9 commits
    • Paul Jewell's avatar
      Allowing folly::dynamics of object/array type to be hashed · c391dc14
      Paul Jewell authored
      Summary:
      Currently, an error is thrown if a user tries to hash an instance of `folly::dynamic` which is of type `object` or `array`. Primitive underlying types are fine.
      
      There doesn't seem to be a strict reason for this, as objects and arrays are just as hashable as primitive types. Additionally, the inability to hash here causes some unnecessary drawbacks (e.g. interacting with `unordered_map`s).
      
      This diff uses the existing dependency on `folly/hash/Hash.h` to start allowing `folly::dynamic` objects/arrays to be hashed as well.
      
      Reviewed By: ot
      
      Differential Revision: D7219760
      
      fbshipit-source-id: 1dff3f99bdacb66f719c614040cbd668ce51a33e
      c391dc14
    • Fengyang Wang's avatar
      Make EventBase subclass IOExecutor (as in docstring) · 3b0fb5d6
      Fengyang Wang authored
      Summary: EventBase meets the definition of IOExecutor (it is an executor that "manages" at least one EventBase) and is already claimed to be one in the docstring.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7064481
      
      fbshipit-source-id: 026e0e4c24d6fb15a32bc4772b35689f830ed944
      3b0fb5d6
    • Lee Howes's avatar
      Add deferError to SemiFuture. · b5fcc4f9
      Lee Howes authored
      Summary: deferError adds an error handling callback to SemiFuture, enqueued on the internal deferred executor, and thus will run on the chained executor or inline with .get() as for defer.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7243193
      
      fbshipit-source-id: 9fe7dab9fbc8b236d717b058c81a303d87fa9253
      b5fcc4f9
    • Nathan Bronson's avatar
      F14 hash table in folly · 93d49bcf
      Nathan Bronson authored
      Summary:
      F14 is a 14-way probing hash table that resolves collisions by double
      hashing.  Up to 14 keys are stored in a chunk at a single hash table
      position.  SSE2 vector instructions are used to filter within a chunk;
      intra-chunk search takes only a handful of instructions.  "F14" refers
      to the fact that the algorithm "F"ilters up to "14" keys at a time.
      This strategy allows the hash table to be operated at a high maximum
      load factor (12/14) while still keeping probe chains very short.
      
      F14 provides compelling replacements for most of the hash tables we use in
      production at Facebook.  Switching to it can improve memory efficiency
      and performance at the same time.  The hash table implementations
      widely deployed in C++ at Facebook exist along a spectrum of space/time
      tradeoffs.  The fastest is the least memory efficient, and the most
      memory efficient is much slower than the rest.  F14 moves the curve,
      simultaneously improving memory efficiency and performance when compared
      to the existing algorithms, especially for complex keys and large maps.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7154343
      
      fbshipit-source-id: 42ebd11b353285855c0fed5dd4b3af4620d39e98
      93d49bcf
    • Lee Howes's avatar
      Separate Try-taking defer and value-taking deferValue in SemiFuture. · bf814b82
      Lee Howes authored
      Summary: This avoids ambiguity with an auto-parameterised lambda and leads on to a consistent use of deferError in a followup diff.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7224490
      
      fbshipit-source-id: df410cd97ca0991db8fcb46267dd6a4236f3f6a3
      bf814b82
    • Asier Gutierrez's avatar
      Missing SequencedExecutor.h · 387fc2ca
      Asier Gutierrez authored
      Summary:
      When compiling using autoconf, automake, make and make install, SequencedExecutor.h is not installed automatically.
      Closes https://github.com/facebook/folly/pull/799
      
      Reviewed By: meyering
      
      Differential Revision: D7241820
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 03c608c8ece2e7870a7bacce399ecc9455691948
      387fc2ca
    • Giuseppe Ottaviano's avatar
      Revert D7164130 · da674dc5
      Giuseppe Ottaviano authored
      Reviewed By: djwatson
      
      Differential Revision: D7251343
      
      fbshipit-source-id: e5ce0c897f0d96c8717d544ac98a1faf12f08c02
      da674dc5
    • Yedidya Feldblum's avatar
      Suppress -Wshadow-compatible-local in folly/test/stl_tests/StlVectorTest.cpp · 2e4740ed
      Yedidya Feldblum authored
      Summary:
      [Folly] Suppress `-Wshadow-compatible-local` in `folly/test/stl_tests/StlVectorTest.cpp`.
      
      That test source file is heavily macro-driven, and using `SCOPED_TRACE` repeatedly in macros can lead to violations of `-Wshadow-compatible-local`.
      
      Reviewed By: meyering
      
      Differential Revision: D7231029
      
      fbshipit-source-id: 122e1d86032cf884a83ef1716fa48b8f4864a363
      2e4740ed
    • Mingtao Yang's avatar
      SSLContext: Report error codes in hexadecimal. · 72eebc56
      Mingtao Yang authored
      Summary: For compatiblity with `openssl errstr`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7246053
      
      fbshipit-source-id: dcf77b67ae3b3dd7b6b85e9b73f2d382e59aa7b9
      72eebc56
  5. 12 Mar, 2018 6 commits
    • Dave Watson's avatar
      Add timed_wait · 5a500c70
      Dave Watson authored
      Summary:
      Add try_wait_for and try_wait_until.
      
      Algorithm -
      
      We could use a doubly-linked list, but this would double the number of contended
      CAS for push/post.  Instead, assume timeouts are infrequent, and just walk the list
      from the head to remove nodes.
      
      A lock bit is added to the head, which is taken only on timeout.  We assume
      timeouts are infrequent.
      
      If a concurrent post() removes the node before the timeout can remove it,
      we must wait for the corresponding post() (but it is likely to arrive soon),
      instead of timing out.
      
      Reviewed By: magedm
      
      Differential Revision: D7167894
      
      fbshipit-source-id: ea5242098d9ccd286a72fade6292223e95c44a81
      5a500c70
    • Dan Melnic's avatar
      Use unbounded queue in NotificationQueue · c9dd3e5e
      Dan Melnic authored
      Summary: Use unbounded queue in NotificationQueue
      
      Reviewed By: djwatson
      
      Differential Revision: D7164130
      
      fbshipit-source-id: d1b445d6730cbb2a68ad78506abe0165e28f5811
      c9dd3e5e
    • Dan Melnic's avatar
      Add folly::Optional<T> UnboundedQueue::try_dequeue() method · 8a14ddfa
      Dan Melnic authored
      Summary: Add folly::Optional<T> UnboundedQueue::try_dequeue() method
      
      Reviewed By: magedm
      
      Differential Revision: D7164049
      
      fbshipit-source-id: 659de2d26067bb1a5bdea50f4cd7711e6955ba61
      8a14ddfa
    • Dan Melnic's avatar
      NotificationQueue benchmark · 9b55b900
      Dan Melnic authored
      Summary: NotificationQueue benchmark
      
      Reviewed By: yfeldblum, djwatson
      
      Differential Revision: D7163944
      
      fbshipit-source-id: f7fe2124b8c61ff3ab39be94d9c50c82a6f8816b
      9b55b900
    • Yedidya Feldblum's avatar
      Fix propagate_const under gcc49 · 5fbd25bb
      Yedidya Feldblum authored
      Summary: [Folly] Fix `propagate_const` under gcc49.
      
      Reviewed By: andrewjcg
      
      Differential Revision: D7230851
      
      fbshipit-source-id: 0cd4df15d5a0f7ae06e26a82ca725b30d479f458
      5fbd25bb
    • Yedidya Feldblum's avatar
      Rewrite allocators for the era of std::allocator_traits · 0085c239
      Yedidya Feldblum authored
      Summary:
      [Folly] Rewrite allocators for the era of `std::allocator_traits`.
      
      Provide minimal interfaces which comply with all required elements of C++ concept `Allocator`. Change all (*) uses to use `std::allocator_traits` consistently, as is required of all allocator-aware library types.
      
      * Rename `SysAlloc`.
      * Replace `StlAllocator` with `CxxAllocatorAdaptor` with stricter semantics.
      * `Arena` is no longer a C++ Allocator because it is not freely copyable. Change code which used it as a C++ Allocator to use `CxxAllocatorAdaptor` instead.
      * `ThreadCachedArena` likewise.
      
      (*) Hopefully.
      
      Reviewed By: nbronson
      
      Differential Revision: D7208794
      
      fbshipit-source-id: 270588c9c3d817f4abd9fb49eed5eb9f03f96da2
      0085c239
  6. 10 Mar, 2018 3 commits