1. 28 Aug, 2013 13 commits
    • Tom Jackson's avatar
      dereference · ca7e6f1b
      Tom Jackson authored
      Summary:
      For dealing with sequences of pointers. Works with pointer wrappers,
      and filters out nullptrs, see tests.
      
      Test Plan: Unit tests
      
      Reviewed By: tulloch@fb.com
      
      FB internal diff: D914069
      ca7e6f1b
    • Tom Jackson's avatar
      Fixing Until, Take · 52479853
      Tom Jackson authored
      Summary:
      `apply()` returns false if and only if the handler it was //directly//
      passed returned false. `Take` didn't do this right, and `Until` was just broken.
      
      Test Plan: More thorough unit tests.
      
      Reviewed By: kittipat@fb.com
      
      FB internal diff: D913185
      52479853
    • Philip Pronin's avatar
      make folly/Bits.h clang-compatible · d82103b8
      Philip Pronin authored
      Summary: In clang (as of 3.2) intrinsics aren't `constexpr`.
      
      Test Plan:
      fbconfig folly/test:bits_test && fbmake opt -j32
      fbconfig --clang folly/test:bits_test && fbmake opt -j32
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D910310
      d82103b8
    • Kittipat Virochsiri's avatar
      Batch · 634f30b5
      Kittipat Virochsiri authored
      Summary: Convert stream of elements to stream of fixed-sized vectors.
      
      Test Plan: unit tests
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D912290
      634f30b5
    • Dave Watson's avatar
      Update build for Ubuntu 12.10. 12.04 seems to no longer compile · 5b065dbe
      Dave Watson authored
      Summary: Dave Watson put this in github a few months ago.
      
      Test Plan: None
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D912681
      5b065dbe
    • Tudor Bosman's avatar
      Make ThreadLocalPtr behave sanely around fork() · 88ae9ac7
      Tudor Bosman authored
      Summary:
      Threads and fork still don't mix, but we shouldn't help you shoot yourself in
      the foot if you decide to do it.
      
      Test Plan: test added
      
      Reviewed By: mshneer@fb.com
      
      FB internal diff: D911224
      88ae9ac7
    • Tom Jackson's avatar
      Cycle · 206a0372
      Tom Jackson authored
      Summary: For repeating a generator's values endlessly.
      
      Test Plan: Unit tests
      
      Reviewed By: kittipat@fb.com
      
      FB internal diff: D911178
      206a0372
    • Andrew Tulloch's avatar
      Fix build break for Clang builds. · af705b32
      Andrew Tulloch authored
      Summary:
      Complains about
      
      ```
      In file included from crypto/lib/cpp/CryptoException.cpp:1:
      In file included from crypto/lib/cpp/CryptoException.h:5:
      In file included from ./folly/Conv.h:30:
      ./folly/Range.h:573:19: error: redefinition of default argument
      Comp eq = Comp()) {
      ^    ~~~~~~
      ./folly/Range.h:55:26: note: previous definition is here
      Comp eq = Comp());
      ^    ~~~~~~
      ```
      
      Redefinition of default arguments is not allowed in C++.
      
      Test Plan:
      ```
      fbconfig --clang admarket/adpublisher && fbmake dbg
      ```
      
      contbuild, etc.
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D910800
      af705b32
    • Josh Metzler's avatar
      Use std::equal<> as qfind default comparator · 9ada53a9
      Josh Metzler authored
      Summary:
      qfind(haystack, needle) is templated, but used a non-templated
      default comparator that cast everything to char.  This works find for
      8-bit types, but not for others such as the uint32_t Ranges we are
      using.  Replace the default comparator with std::equal<> to use a
      working comparator for whatever type is being searched.
      
      Test Plan:
      Compiles, unit tests (including a new one that fails with the
      old code) pass.  Not sure how to test other users of this, or measure
      performance impact. :(
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D906311
      9ada53a9
    • Sean Cannella's avatar
      fix folly Range compilation on FreeBSD · b22d95e4
      Sean Cannella authored
      Summary: - memrchr is GNU + Linux specific, it turns out
      
      Test Plan: - compiled on FreeBSD, contbuild
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D900935
      b22d95e4
    • Sean Cannella's avatar
      fix folly compilation on FreeBSD · ea2da05c
      Sean Cannella authored
      Summary:
      - fix folly compilation on FreeBSD
      
      Github Author: Martin Matuska <martin@matuska.org>
      
      Test Plan: - compiled
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D896747
      ea2da05c
    • Tudor Bosman's avatar
      Multi-Producer, Multi-Consumer pipeline · 5f4c6672
      Tudor Bosman authored
      Summary:
      A bunch of MPMCQueues linked together. Stage i produces exactly Ki (default 1)
      outputs for each input. Ordering is preserved, even though stages might
      produce (intermediate or final) results in parallel and in any order; we do
      this by abusing the enqueueing mechanism in MPMCQueue. (Read the code for
      details)
      
      Test Plan: test added, more tests to be written before commit
      
      Reviewed By: ngbronson@fb.com
      
      FB internal diff: D892388
      5f4c6672
    • Nathan Bronson's avatar
      folly/MPMCQueue sizeGuess should return a signed int · ff1046b8
      Nathan Bronson authored
      Summary:
      Like size(), sizeGuess() is allowed to return a negative value,
      so it should be ssize_t instead of uint64_t.
      
      Test Plan: fbmake, wait for contbuild
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D893075
      ff1046b8
  2. 18 Jul, 2013 8 commits
    • Hans Fugal's avatar
      folly/Hash.h add a test to ensure different hashes · 8035fc11
      Hans Fugal authored
      Summary:
      "Wouldn't this test case still pass if the hash function didn't depend on the value?
      
      It would be nice to verify that different tuple values produce different hash values (or maybe there's another test that verifies that), especially since this is a tricky thing to get right."
      
      I think there's not much chance of this failing since it's just leveraging hash_combine and that's already tested. But it's easy to add another sanity check, so here we are.
      
      Test Plan: runtests
      
      Reviewed By: tulloch@fb.com
      
      FB internal diff: D890448
      
      Blame Revision: D888796
      8035fc11
    • Hans Fugal's avatar
      tuple hashing · b71e31a5
      Hans Fugal authored
      Summary:
      Add hash support for std::tuple.
      See also D490478 (where a first attempt was made) and D543586 (where that attempt was deemed broken and removed).
      
      Test Plan: unit test
      
      Reviewed By: chip@fb.com
      
      FB internal diff: D888796
      b71e31a5
    • Sean Cannella's avatar
      OSX compat fixes · 982acaae
      Sean Cannella authored
      Summary:
      fix OSX compat issues
      
      Github Author: Daniel Sloof <goapsychadelic@gmail.com>
      
      Test Plan: - compiled
      
      Reviewed By: pt@fb.com
      
      FB internal diff: D877309
      982acaae
    • Chip Turner's avatar
      Add initializer_list support to folly::join · de064c41
      Chip Turner authored
      Summary:
      Apparently the templates don't like to match the initlializer
      list, so this needed to be added.  This allows for things like:
      
      auto s = join(":", {val1, val2, val3, val4, val4});
      
      Test Plan: run tests
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D878032
      de064c41
    • Tom Jackson's avatar
      guard<Exception>() (redo) · b5a0a9f7
      Tom Jackson authored
      Summary:
      For handling exceptions from downstream operations.
      
      Now with cleaner build.
      
      Test Plan: Unit tests, including those outside `folly`.
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D877795
      
      Blame Revision: https://phabricator.fb.com/D872581
      b5a0a9f7
    • Chip Turner's avatar
      Fix folly/FBString.h build error · acd305a3
      Chip Turner authored
      Summary:
      Looks like D880140 left off this part when it was committed.
      
      This fixes the build.
      
      Test Plan: runtests
      
      Reviewed By: vini@fb.com
      
      FB internal diff: D881445
      acd305a3
    • Andrei Alexandrescu's avatar
      Fix build breakage in hphp · 2302d45a
      Andrei Alexandrescu authored
      Summary:
      This should fix the build breakage in hphp caused by the latest fbstring changes (after being ported to engshare). Note that I'm flying blind here; I couldn't test with the hphp build because I don't have write access to engshare. @agallagher could you please make sure that this works after the fix?
      
      fbconfig -r hphp && fbmake dbg
      
      Test Plan: tested on folly
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D880140
      2302d45a
    • Andrei Alexandrescu's avatar
      fbstring::shrink_to_fit · af1b0a8b
      Andrei Alexandrescu authored
      Summary: Adds the eponymous C++11 capability to fbstring.
      
      Test Plan: fbstring runtests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D867995
      af1b0a8b
  3. 09 Jul, 2013 5 commits
    • Tom Jackson's avatar
      Allowing trailing comma in folly::parseJson · ea72b037
      Tom Jackson authored
      Summary:
      Introduced a new serialization option, `allow_trailing_comma`, which allows trailing commas to be included in strings when they are parsed. This isn't strictly allowed by RFC 4627, but we're allowing more than that anyway.
      
      I've run into this dozens of times, especially while using SMC.
      
      Test Plan: Unit tests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D872581
      ea72b037
    • Chip Turner's avatar
      Revert D874344 (it broke the build) · f13297ee
      Chip Turner authored
      Summary:
      Clean revert.  Please be more careful; phabricator warned you
      these would break the build.
      
      Test Plan: build something that wasn't working
      
      Reviewed By: myang@fb.com
      
      FB internal diff: D877526
      f13297ee
    • Tom Jackson's avatar
      guard<Exception>() · 96c76d55
      Tom Jackson authored
      Summary: For handling exceptions from downstream operations.
      
      Test Plan: Unit tests
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D874344
      96c76d55
    • Philip Pronin's avatar
      move assignment operators for folly::Synchronized · ca5621fa
      Philip Pronin authored
      Summary:
      * added move assignment operators,
      * fixed `operator=(const Synchronized& rhs)` (it had a typo),
      * fixed deadlock on self-assignment,
      * changed `swap` to call `swap(lhs.datum_, rhs.datum_)` instead of `lhs.datum_.swap(rhs.datum_)`.
      
      Test Plan: fbconfig -r folly/test && fbmake opt -j32 && fbmake runtests_opt
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D875977
      ca5621fa
    • Sean Cannella's avatar
      memrchr and *timed_mutex are platform-specific · b1463f8f
      Sean Cannella authored
      Summary:
      - conditionally compile rfind overrides
      - conditionally add support for timed_mutex/recursive_timed_mutex
      
      Test Plan:
      - compiled on OSX
      - unit tests
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D872272
      b1463f8f
  4. 01 Jul, 2013 5 commits
    • Sean Cannella's avatar
      strerror_r is XSI compliant on Apple/FreeBSD · bd4c2f96
      Sean Cannella authored
      Summary:
      - Noticed this due to an -fpermissive compiler warning while compiling
      HHVM for OSX (complaint of trying to cast int to char*)
      
      Test Plan:
      - Compiled
      - Confirmed the build warning is fixed by this on the Mac OS X build
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D865169
      bd4c2f96
    • Tom Jackson's avatar
      toDynamic(T) · 04c09cf0
      Tom Jackson authored
      Summary: It only makes sense to be able to go the other direction, too.
      
      Test Plan: Unit tests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D785282
      04c09cf0
    • Tom Jackson's avatar
      Range<T>::rfind() · 1408e9d5
      Tom Jackson authored
      Test Plan: Unit tests
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D865951
      1408e9d5
    • Nathan Bronson's avatar
      Multi-producer multi-consumer queue with optional blocking · 8b260639
      Nathan Bronson authored
      Summary:
      MPMCQueue<T> is a high-performance bounded concurrent queue that
      supports multiple producers, multiple consumers, and optional blocking.
      The queue has a fixed capacity, for which all memory will be allocated
      up front.  The bulk of the work of enqueuing and dequeuing can be
      performed in parallel.
      
      To make an MPMCQueue<T>, T must satisfy either of two conditions:
      - it has been tagged FOLLY_ASSUME_FBVECTOR_COMPATIBLE; or
      - both the constructor used during enqueue and the move operator are
      marked noexcept.
      
      This diff extracts the generic component from tao/queues/ConcurrentQueue
      and renames identifiers to match those of existing folly queues.
      It also includes an extraction of Futex, which wraps the futex syscall,
      and DeterministicScheduler, which allows for deterministic exploration
      of thread interleavings for components built from std::atomic and Futex.
      
      Test Plan: new unit tests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D866566
      8b260639
    • Tom Jackson's avatar
      const'ing sorted_vector_map::count() · 78f3142f
      Tom Jackson authored
      Test Plan: Use it
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D865211
      78f3142f
  5. 26 Jun, 2013 9 commits
    • Louis Brandy's avatar
      fix tautological comparisons in Conv.h · 423eed2d
      Louis Brandy authored
      Summary:
      We have an off-by-one in our enable_if/sfinae logic here. We do not want to actually do the comparison in `less_than` when the rhs is exactly the minimum possible lhs. This results in a tautological comparison.
      
      I added a unit test for these traits that test all the various sfinae cases.
      
      Test Plan: See the clang tautological warnings go away. Under gcc, rerun all tests. All pass.
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D856869
      423eed2d
    • Tudor Bosman's avatar
      Speed up EventCount, now 64-bit only · 8949d553
      Tudor Bosman authored
      Summary:
      Don't use two atomic variables when only one will suffice (otherwise, the
      increments in doNotify() and prepareWait() would require memory_model_seq_cst,
      because they need to globally order a store before a load, and no weaker
      model allows you to do that)
      
      Of course, this makes this 64-bit only, but I don't care.
      
      Test Plan: eventcount_test, tests outside of folly
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D858963
      8949d553
    • Tudor Bosman's avatar
      StringPiece comparisons are broken · a664fa91
      Tudor Bosman authored
      Summary:
      8-bit StringPiece comparisons are broken.
      The reason is char_traits is magic for 'char', but not 'const char'.
      
      Test Plan: test added
      
      Reviewed By: chip@fb.com
      
      FB internal diff: D861521
      a664fa91
    • Tudor Bosman's avatar
      add Chrono.h to patch around a gcc 4.6 issue · 753903f3
      Tudor Bosman authored
      Test Plan: used it
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D859244
      753903f3
    • Tudor Bosman's avatar
      Use libunwind instead of the heavyweight thing from libgcc · b78098f7
      Tudor Bosman authored
      Test Plan: exception_tracer_test
      
      Reviewed By: bmaurer@fb.com
      
      FB internal diff: D858195
      b78098f7
    • Stephen Chen's avatar
      Add MultiLevelTimeSeries to folly. · 0600259d
      Stephen Chen authored
      Summary:
      Add MultiLevelTimeSeries class which represents a timeseries which keeps several
      levels of data granularity (similar in principle to the loads reported by the
      UNIX 'uptime' command).  It uses several instances (one per level) of
      BucketedTimeSeries as the underlying storage.
      
      This can easily be used to track sums (and thus rates or averages) over several
      predetermined time periods, as well as all-time sums.  For example, you would
      use to it to track query rate or response speed over the last 5, 15, 30, and 60
      minutes.
      
      Test Plan: unittest included.
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D851444
      0600259d
    • Louis Brandy's avatar
      rename template parameters in folly::greater_than · cdf9c435
      Louis Brandy authored
      Summary: This template is only used in folly::Conv (to avoid tautological comparisons) and as best as I can tell, the rhs/lhs names are not correct as it's currently used (and not consistent with `less_than`). Just swap rhs/lhs variable names.
      
      Test Plan:
      Test Results Summary:
      Passed: 471
      100% successful
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D856785
      cdf9c435
    • Jim Meyering's avatar
      folly: accommodate use of -Wshadow in other projects · 46de7098
      Jim Meyering authored
      Summary:
      Without this change, any folly-using project that attempts to enable
      gcc's -Wshadow option will be overwhelmed by warnings about violations
      in folly's class definitions.  Violations are often due to local
      variable or parameter names shadowed by a member function.
      
      Bracket offending content with directives like this:
      
      #pragma GCC diagnostic push
      #pragma GCC diagnostic ignored "-Wshadow"
      ...
      #pragma GCC diagnostic pop
      
      This set of modified files is the minimal set to allow tao
      to use -Wshadow with no folly-related warning.
      
      Test Plan:
      fbmake folly/test && fbmake opt
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D848455
      46de7098
    • Adam Simpkins's avatar
      rework the Subprocess::communicate() API · 76ade918
      Adam Simpkins authored
      Summary:
      This eliminates the CommunicateFlags argument to communicate().  It now
      always reads from both stdout and stderr if they were set up a pipes.
      If a non-empty input buffer was supplied, it always writes that to
      stdin.
      
      This mimics the communicate() behavior of python's subprocess.py module.
      This also makes it impossible to have buffering deadlocks by forgetting
      to call communicate() with readStderr().
      
      Test Plan:
      Ran the existing subprocess tests, and also added a more complicated
      duplex test that requires communication on stdin, stdout, and stderr all
      at the same time.
      
      Also grepped for all existing users of Subprocess::communicate(), and
      made sure they will work correctly with the new behavior.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D814405
      76ade918