1. 19 May, 2018 5 commits
  2. 18 May, 2018 8 commits
    • Dave Watson's avatar
      Make erase() return an iterator · 1fe37d89
      Dave Watson authored
      Summary: Make erase(iterator) return an iterator, like std containers.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8047159
      
      fbshipit-source-id: 3cc94782a7afca0bf9fedefdc7296b9395ca9859
      1fe37d89
    • Maged Michael's avatar
      hazptr: Fix cleanup to wait for the concurrent reclamation of objects · bcdd651c
      Maged Michael authored
      Summary:
      This fix aims to prevent cases (pointed out by David Goldblatt) where cleanup returns while a concurrent slower bulk_reclaim has not completely reclaimed objects that are supposed to be reclaimed before the return from reclaim.
      
      This fix uses an atomic count of the number of ongoing  bulk_reclaim-s. Cleanup returns only if it observes that that count is zero.
      
      Reviewed By: djwatson
      
      Differential Revision: D7586325
      
      fbshipit-source-id: 341af641d20a7a07206c7238ea0356a9eabdbab5
      bcdd651c
    • Marshall Cline's avatar
      simplify Core state-space · 7026dbde
      Marshall Cline authored
      Summary:
      Remove Armed: it added an avoidable extra state transition, plus avoidable semantic complexity in the behavior/contract of setResult() & setCallback(), i.e., if either of those transitioned to Armed, that thread may or may not be the one that made the transition to Done with the possibly-synchronous call to the callback.
      
      After this change there is only one transition after Only* - to Done, and the new contract/behavior of setResult/setCallback is still asynchronous (the caller cannot know which thread will call the callback) but at least has only one asynchrony instead of two (the thread that transitions to Done is always the thread that calls doCallback()).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8049396
      
      fbshipit-source-id: 89a1e40ab8c09db4c8ab0ac3a1fd2cc5e092830d
      7026dbde
    • Maged Michael's avatar
      CoreCachedSharedPtr: Use synchronization/hazptr instead of experimental/hazptr · 140a17aa
      Maged Michael authored
      Summary: Use synchronization/hazptr instead of experimental/hazptr
      
      Reviewed By: djwatson
      
      Differential Revision: D7565384
      
      fbshipit-source-id: 26790eec80f344cb4b227672e6d51d97c9170dee
      140a17aa
    • Andre Pinto's avatar
      Fix typo · cf18e2d4
      Andre Pinto authored
      Reviewed By: Orvid
      
      Differential Revision: D8053447
      
      fbshipit-source-id: 4550e4fabffb7e6be7d7927292aed2b33c10dee5
      cf18e2d4
    • Orvid King's avatar
      Add a kerberos portability header · 99366f98
      Orvid King authored
      Summary: Kerberos has issues with include order on Windows, so give it it's own portability header to force the correct include order and undefine the mess it `#define`'s.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8050238
      
      fbshipit-source-id: 6c718f8f0db9f039734bead5f90cd289ea1dfd78
      99366f98
    • Andrii Grynenko's avatar
      Unit test fixes to enable use of Executor::KeepAlive<> in Futures (2/?) · 82b1f7c5
      Andrii Grynenko authored
      Summary:
      This is blocking D8022229
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8038878
      
      fbshipit-source-id: 4b5f085b86f065df0612a132ec26c3d4980edbd1
      82b1f7c5
    • Orvid King's avatar
      Include the Windows portability header in the fcntl portability header · 5a87e8ad
      Orvid King authored
      Summary:
      Because it defines `HANDLE_FLAG_INHERIT`
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8050035
      
      fbshipit-source-id: a67d19aa7882f312273e0761123d6827fe07bd81
      5a87e8ad
  3. 17 May, 2018 3 commits
    • Marshall Cline's avatar
      faster(sometimes) interrupt-handler for Promise/Future · ee33c57f
      Marshall Cline authored
      Summary: Avoid overhead of std::function (virtual fn, possible malloc) when the interrupt msg reaches the core before the interrupt handler (the former in future.raise(), the latter in promise.setInterruptHandler()).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7994756
      
      fbshipit-source-id: 58827e7ac320b6585f1a1c3df08932bbe38f91ee
      ee33c57f
    • Dave Watson's avatar
      Make BlockingQueue::add() return a result struct · 126f7ac8
      Dave Watson authored
      Summary: For greater clarity, return a BlockingQueueResult struct from add instead of a raw bool
      
      Reviewed By: yfeldblum, magedm
      
      Differential Revision: D7709300
      
      fbshipit-source-id: 36fce6b1006ccf29985f431515c1c61deb84b6d3
      126f7ac8
    • Maged Michael's avatar
      Rewrite from experimental, use of deterministic schedule, improvements · d42832d2
      Maged Michael authored
      Summary:
      For history of the experimental version see folly/experimental/hazptr
      
      Added:
      - Support for deterministic schedule testing.
      
      Fixes:
      - Eliminates performance pathological cases for hazptr_array and hazptr_local construction when a thread cache can only partially satisfy the needed number of hazptr_holder-s.
      - try_protect sets ptr to the value read from src on success. Otherwise, ptr may be used by the client code when it is invalid.
      
      Code improvements including:
      - Using separate files for different components.
      - Eliminated all macro definitions except one.
      - Simplified thread local structures.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D7565357
      
      fbshipit-source-id: fb00fad7395148e66d6231a374b5b717574ed270
      d42832d2
  4. 16 May, 2018 8 commits
    • Marshall Cline's avatar
      'noexcept' on the 'detach' fns called from Future/Promise dtors · 0e066dda
      Marshall Cline authored
      Summary: Core::detachFuture() & detachPromise() are called from dtors; make them 'noexcept'
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7995163
      
      fbshipit-source-id: 5c15e0516be2559a2ce1d283dc6fa75c2f506cd8
      0e066dda
    • Phil Willoughby's avatar
      tidy a rogue include · 63079c9b
      Phil Willoughby authored
      Summary:
      Duplicate of line 22. Since the included header contains #pragma once it was doing nothing.
      
      If it hadn't been a duplicate it would have been a problem because it was included within either a `namespace folly` or `namespace std...` block.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8031245
      
      fbshipit-source-id: 4486859a11939a61d634c5603243785e6ec5a36c
      63079c9b
    • Chip Turner's avatar
      Add vivify method to folly::Singleton · 5eb853a0
      Chip Turner authored
      Summary:
      This method ensures the singleton exists with less overhead than
      calling `try_get` or `try_get_fast`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8020292
      
      fbshipit-source-id: 470ebea9fdb07e46a469c820f9149d6fc5af5d2f
      5eb853a0
    • Dave Watson's avatar
      Fix stop() race · a574e130
      Dave Watson authored
      Summary:
      There is a race with stop() and timeouts.  stop() may race with a thread timeout, and then block indefinitely on
      joinStoppedThreads(), waiting to join the already joined timed-out thread.
      
      To fix, just put everything behind a write lock, simplifying the code at the same time.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D7971779
      
      fbshipit-source-id: eb4a898ca266ddda0f95033950ac041d1cc812ba
      a574e130
    • Yang Chi's avatar
      Add API to AsyncUDPSocket to check if socket has bound · c0a9ed05
      Yang Chi authored
      Summary:
      A lot of functions in AsyncUDPSocket just use a CHECK for fd_ and fail
      hard if ths socket hasn't bound to a fd. This adds an API for user to actually
      find out if socket has bound without crash.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: siyengar
      
      Differential Revision: D8026035
      
      fbshipit-source-id: fc7bf9c1d6d7f045cd4dba94e3278d20d80de887
      c0a9ed05
    • Adam Simpkins's avatar
      remove duplicate definition of dynamic::print_as_pseudo_json · 5313ad0d
      Adam Simpkins authored
      Summary:
      `folly/test/DynamicTest.cpp` contained a duplicate definition of
      `dynamic::print_as_pseudo_json()`.  This caused link errors due if this test
      was linked against `json.cpp`.
      
      Part of the problem here is that the `//folly:dynamic` library is somewhat of
      a lie: the `dynamic::print_as_pseudo_json()` method is provided by the
      `//folly:json` library rather than by `//folly:dynamic`.  This violates
      assumptions made by autodeps.  Ultimately the right thing to do might be to
      combine `//folly:json` and `//folly:dynamic` into a single rule.
      
      Reviewed By: yangchi
      
      Differential Revision: D8020841
      
      fbshipit-source-id: e563611309c122680a5fc69c3f0da1ad5d4337b0
      5313ad0d
    • Dan Melnic's avatar
      Fix "multiple definition of... · 99661f09
      Dan Melnic authored
      Fix "multiple definition of 'folly::dynamic::print_as_pseudo_json(std::ostream&) const'" linker error
      
      Summary: Fix "multiple definition of 'folly::dynamic::print_as_pseudo_json(std::ostream&) const'" linker error
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8016705
      
      fbshipit-source-id: 7ef8306852afd8e765f22e657f44fbe67c66f6f5
      99661f09
    • Yang Zhang's avatar
      Add constexpr_clamp_cast<> in folly/ConstexprMath.h · c382ca4e
      Yang Zhang authored
      Summary:
      constexpr_clamp_cast<> provides sane numeric conversions from float point numbers to
      integral numbers, and between different types of integral numbers.
      
      When doing clamp_cast<DstT>(value), if `value` is in valid range of DstT, it will give correct result in DstT, equal to `value`.
      
      If `value` is outside the representable range of DstT, it will be clamped to MAX or MIN in DstT.
      
      Float NaNs are converted to 0 in integral type.
      
      For comparison, static_cast<> will return garbage results when SrcT is float point number and it's outside DstT valid range. This is because float-cast-overflow is undefined behavior.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7716736
      
      fbshipit-source-id: 5899e4b20cdd997d0c7b121ddaababbc8c748301
      c382ca4e
  5. 15 May, 2018 7 commits
    • Orvid King's avatar
      Fix typo in error message in small_vector test · 70ea8045
      Orvid King authored
      Summary: As per title.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8014022
      
      fbshipit-source-id: df24a839804e9bb6c063994adbbde3544535b66c
      70ea8045
    • Yedidya Feldblum's avatar
      Use throw_exception in folly/futures/ · 2e60986c
      Yedidya Feldblum authored
      Summary: [Folly] Use `throw_exception` in `folly/futures/`, replacing the one-off throw functions.
      
      Reviewed By: Orvid
      
      Differential Revision: D7965947
      
      fbshipit-source-id: ed5855aaccf4aa07ecb40489db9fa92090df9016
      2e60986c
    • Yedidya Feldblum's avatar
      Let Future handle throwing FutureNotReady · 407e4380
      Yedidya Feldblum authored
      Summary: [Folly] Let `Future` handle throwing `FutureNotReady`, since it is logically the thing that knows about specific exceptions in its contract.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D7964855
      
      fbshipit-source-id: 49f3220a6a41ebe87f577814c0940e00497092c0
      407e4380
    • Adam Simpkins's avatar
      update folly::Init to call folly::initLogging() · 61a56337
      Adam Simpkins authored
      Summary:
      Update the folly::Init code to define a `--logging` command line flag, and call
      `folly::initLoggingOrDie()` with the value of this command line during
      initialization.
      
      This is similar to the existing code that initializes the glog library.
      (Programs can use both glog and folly logging together in the same program, and
      I expect that many programs will do so as parts get converted to folly::logging
      and parts remain using glog.)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7827344
      
      fbshipit-source-id: 8aa239fbad43bc0b551cbe40cad7b92fa97fcdde
      61a56337
    • Teng Qin's avatar
      Call onSet and onUnset when adding and and deleting RequestData · f4f7645b
      Teng Qin authored
      Summary: Currently, when we add or delete a `RequestData` instance to `RequestContext` for the first time, we do not call the `RequestData`'s `onSet` or `onUnset` callback. This means if the `RequestData` is doing tracking-related work, it may miss the beginning or the request until the first switch of `RequestContext` has happend, and in the end as well. This Diff fixes the issue by calling `onSet` and `onUnset` when adding or deleting.
      
      Reviewed By: anakryiko
      
      Differential Revision: D7978623
      
      fbshipit-source-id: a524286371f890598bc773e957ef609e90086cea
      f4f7645b
    • Simon_CQK's avatar
      Replace std::unique_lock with std::lock_guard. · 2e29c471
      Simon_CQK authored
      Summary:
      std::lock_guard has a better performance than std::unique_lock in scoped-lock.
      Closes https://github.com/facebook/folly/pull/840
      
      Reviewed By: djwatson
      
      Differential Revision: D7888672
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 391082aa79ada67a3906e828d68f8cc2a29bf22c
      2e29c471
    • Adam Simpkins's avatar
      logging: update AsyncFileWriter to interoperate with fork() · d586aab9
      Adam Simpkins authored
      Summary:
      Update AsyncFileWriter to use pthread_atfork() to stop the I/O thread around a
      fork() operation.  Both the parent and child restart the I/O thread after the
      fork.  Messages that were queued up at the time of the fork are logged in the
      parent process after the fork occurs.
      
      Previously after a fork() the child process would not have an I/O thread
      running at all, so any messages sent to this handler would not actually be
      written.  This also triggered some ASAN warnings which I did not fully track
      down.  In the child process ASAN claimed that the exit handlers were run twice:
      from both the main thread and the I/O thread, which is surprising since the I/O
      thread should not run in the child process at all.
      
      Reviewed By: mnv104
      
      Differential Revision: D7946725
      
      fbshipit-source-id: e4ad398f7bb334882c5c0b2afacc30c27bf3f6e4
      d586aab9
  6. 14 May, 2018 4 commits
    • supei's avatar
      include gflag explicitly · 347f4867
      supei authored
      Summary:
      fix #839
      Closes https://github.com/facebook/folly/pull/846
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7987128
      
      Pulled By: Orvid
      
      fbshipit-source-id: 626ed1724f3df5fecc83413574cfd72f1f0b1fa1
      347f4867
    • Marc Celani's avatar
      Performance improvements for BufferedStat and DigestBuilder · aeaa6cf9
      Marc Celani authored
      Summary:
      * Relax some loads in BufferedStat
      * Cache which cpu local buffer to use, similar to SharedMutex
      
      Reviewed By: djwatson
      
      Differential Revision: D7986764
      
      fbshipit-source-id: 581266abc60e3f23f24181264da163baee9fce3f
      aeaa6cf9
    • Yedidya Feldblum's avatar
      Use throw_exception in Expected · 7b7397fe
      Yedidya Feldblum authored
      Summary: [Folly] Use `throw_exception` in `Expected`, replacing the one-off throwing functions and outlining `throw` statements.
      
      Reviewed By: Orvid
      
      Differential Revision: D7985812
      
      fbshipit-source-id: 396b92d1ec40c909c9c37dd7f7d9ed94b2bcf709
      7b7397fe
    • Yedidya Feldblum's avatar
      Use throw_exception in Try · 29fd73db
      Yedidya Feldblum authored
      Summary: [Folly] Use `throw_exception` in `Try`, replacing the one-off throwing functions.
      
      Reviewed By: Orvid
      
      Differential Revision: D7984674
      
      fbshipit-source-id: 3996e09fd8a7446fbb53760f1ce30a66cb7c13e9
      29fd73db
  7. 13 May, 2018 4 commits
    • Yedidya Feldblum's avatar
      Let Pomise handle setting BrokenPromise · c1a2ae85
      Yedidya Feldblum authored
      Summary:
      [Folly] Let `Pomise` handle setting `BrokenPromise` in its dtor, since it is logically always the thing that invokes `setResult`, rather than having `Core` do it.
      
      This splits up the various responsibilities a little better.
      
      Reviewed By: marshallcline
      
      Differential Revision: D7964264
      
      fbshipit-source-id: a4871fd1a83a0a54d4a6c91fcb74c6df5aa592ba
      c1a2ae85
    • Steve O'Brien's avatar
      folly/Range: drop include of boost/operators · ae57e3b7
      Steve O'Brien authored
      Summary: Drop this expensive include and just implement the operators.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7803316
      
      fbshipit-source-id: 969fef54204cf3caa09d67e05be61c3c9a14b67e
      ae57e3b7
    • Orvid King's avatar
      Fix the final issue on MSVC 2017 Update 7 · 97705d14
      Orvid King authored
      Summary: MSVC 2017 Update 7 has issues with expanding empty parameter packs in certain situations.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7983735
      
      fbshipit-source-id: d90c01a36885b94269b3dbc260142abd6556102d
      97705d14
    • Orvid King's avatar
      Workaround MSVC 15.7 bug · 8521e599
      Orvid King authored
      Summary:
      MSVC 15.7 (VS 2017 Update 7) was released a couple days ago, and includes a bug that's breaking Folly. Temporarily work around it.
      A point release should be out soon(ish) to resolve the issue: https://developercommunity.visualstudio.com/content/problem/246602/157-fails-with-folly.html
      There is still another issue in 15.7 that needs to be worked around, which will happen in a separate diff.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7937972
      
      fbshipit-source-id: 4a2bc4ae0ea7165c45d100ad0a29409b60a0287a
      8521e599
  8. 12 May, 2018 1 commit
    • Nathan Bronson's avatar
      tests for F14 exception safety plus a fix for a rare constructor · 56a0d739
      Nathan Bronson authored
      Summary:
      This diff fixes the move constructor form that takes an explicit
      allocator for F14VectorMap and F14VectorSet (which may also include
      F14FastMap and F14FastSet depending on the value_type).  It also includes
      test coverage for exception safety, which did not reveal any problems.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7981324
      
      fbshipit-source-id: f4ca39aa2654d75289b554a9081621b2a3a6c136
      56a0d739