1. 27 Apr, 2016 2 commits
    • Pavlo Kushnir's avatar
      Cheaper bumpHandlingTime · 15c9b35a
      Pavlo Kushnir authored
      Summary: no need in virtual call from EventHandler.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3226960
      
      fb-gh-sync-id: eb9c191630e1a1ac022666201100e3778eb7b611
      fbshipit-source-id: eb9c191630e1a1ac022666201100e3778eb7b611
      15c9b35a
    • Jon Maltiel Swenson's avatar
      Optimize away IOBuf clones on hot path · 4aa901d0
      Jon Maltiel Swenson authored
      Summary:
      'get' is the most frequent memcached operation. On a get reply, we should go to heap
      as little as possible.  This diff optimizes for this scenario, where replies
      have only one IOBuf field.
      
      Reviewed By: pavlo-fb
      
      Differential Revision: D3226592
      
      fb-gh-sync-id: 92e1a1fac5735bd268691cf11990a96ae6fa8309
      fbshipit-source-id: 92e1a1fac5735bd268691cf11990a96ae6fa8309
      4aa901d0
  2. 26 Apr, 2016 6 commits
    • Aditya Muttur's avatar
      Adding a constructor to UTF8Range that uses std::string · 545134d1
      Aditya Muttur authored
      Summary:
      Currently UTF8Range has a constructor that allows you construct an object of type UTF8Range using only an object of type folly::Range. Adding a constructor so that we can construct an UTF8Range object using a std::string.
      
      Currently,
        void sampleMethod(UTF8StringPiece sp) {...}
        /*
        ...
        */
        std::string str = "example";
        folly::UTF8Range utf8Range(str);
        folly::StringPiece sp(str);
        sampleMethod(utf8Range); // works
        sampleMethod(sp); // works
        sampleMethod(str); // doesn't work
      
      This diff hopes to fix this issue.
      
      Reviewed By: ddrcoder
      
      Differential Revision: D3221144
      
      fb-gh-sync-id: dd6ec4d7790d4602dccb3b63a4861d358aed3608
      fbshipit-source-id: dd6ec4d7790d4602dccb3b63a4861d358aed3608
      545134d1
    • Mirek Klimos's avatar
      API to set folly::RequestContext for current scope, try 2 · 0be0a8cd
      Mirek Klimos authored
      Summary: same as D3156698, without changes in Cpp2Connection (which was the only real change in the diff)
      
      Reviewed By: haijunz
      
      Differential Revision: D3222792
      
      fb-gh-sync-id: 245c7add837c0fc6d0bc84aa7d80b929ba2ce386
      fbshipit-source-id: 245c7add837c0fc6d0bc84aa7d80b929ba2ce386
      0be0a8cd
    • Christopher Dykes's avatar
      Define DECLARE_VARIABLE in portability/GFlags.h · 4cace13a
      Christopher Dykes authored
      Summary: If we don't, then anywhere we include `glog/logging.h` after the portability header will get the `DECLARE_*` and `DEFINE_*` macros undefined -_-....
      
      Reviewed By: mzlee
      
      Differential Revision: D3220797
      
      fb-gh-sync-id: 52907ddcd6b222fb1c6423034ea999eac5ce09ab
      fbshipit-source-id: 52907ddcd6b222fb1c6423034ea999eac5ce09ab
      4cace13a
    • Michael Lee's avatar
      Remove extra dependency on Portability.h · e16f91ff
      Michael Lee authored
      Summary: This dependency is in the wrong order.
      
      Reviewed By: knekritz
      
      Differential Revision: D3224312
      
      fb-gh-sync-id: 98d2c58b75cf5f16892d462ae1b877d06bce3faa
      fbshipit-source-id: 98d2c58b75cf5f16892d462ae1b877d06bce3faa
      e16f91ff
    • Pavlo Kushnir's avatar
      Use std::string in folly::dynamic · 7dbf6903
      Pavlo Kushnir authored
      Summary: Why not kill fbstring entirely? There are some legitimate use cases. For example, `folly::IOBuf` supports `moveToFbstring()` method which is impossible to implement with `std::string`.
      
      Reviewed By: joeg, snarkmaster
      
      Differential Revision: D3189410
      
      fb-gh-sync-id: 9bb9090ca6012ac32ba9fb79041b26ec4888781f
      fbshipit-source-id: 9bb9090ca6012ac32ba9fb79041b26ec4888781f
      7dbf6903
    • Yedidya Feldblum's avatar
      Retire BOOST_STATIC_ASSERT in favor of static_assert · 43d56a22
      Yedidya Feldblum authored
      Summary:
      Retire `BOOST_STATIC_ASSERT` in favor of `static_assert`.
      
      `static_assert` is part of C++ now, so we don't need workarounds like `BOOST_STATIC_ASSERT` anymore.
      
      Partially automated:
      
          hg grep -lw BOOST_STATIC_ASSERT | xargs perl -pi -e 's~\bBOOST_STATIC_ASSERT\(([^;]*)\);~static_assert(\1, "");~g'
          hg grep -lw 'boost/static_assert.hpp' | xargs perl -pi -e 's,^#include <boost/static_assert\.hpp>\n,,gm'
      
      Caught most instances. Formatting and remaining instances addressed manually.
      
      Reviewed By: meyering
      
      Differential Revision: D3215944
      
      fb-gh-sync-id: f4552d5d9bfc416ce283923abe880437a4d0cba5
      fbshipit-source-id: f4552d5d9bfc416ce283923abe880437a4d0cba5
      43d56a22
  3. 25 Apr, 2016 2 commits
    • Stepan Palamarchuk's avatar
      Remove unnecessary construction of IOBuf in Cursor · 57e517a5
      Stepan Palamarchuk authored
      Summary: This assignment is unnecessary, because in `for` loop we **always** call `cloneOneInto` that would assign another IOBuf to that IOBuf.
      
      Reviewed By: alikhtarov
      
      Differential Revision: D3215861
      
      fb-gh-sync-id: ad87b99848aaae79f0870d49e0474f1abf0f28e5
      fbshipit-source-id: ad87b99848aaae79f0870d49e0474f1abf0f28e5
      57e517a5
    • Andrew Cox's avatar
      UndelayedDestruction virtual=>override · dcac5e8d
      Andrew Cox authored
      Summary:
      Had this in another diff, but it caused too much test noise. So I've separated
      it out on it's own.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3213605
      
      fb-gh-sync-id: 9ebfcf8430da7c66a31868032a0cef1e616ffc58
      fbshipit-source-id: 9ebfcf8430da7c66a31868032a0cef1e616ffc58
      dcac5e8d
  4. 23 Apr, 2016 1 commit
    • Sven Over's avatar
      use forward instead of move for universal references · d7842974
      Sven Over authored
      Summary:When dealing with universal references, std::move will move from
      objects that are passed as lvalue references. Instead std::forward
      should be used, which only moves from an object if it's passed
      as rvalue reference.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3200402
      
      fb-gh-sync-id: 14be071e8498dd64cb8b2583c0cc2dd383bfebb8
      fbshipit-source-id: 14be071e8498dd64cb8b2583c0cc2dd383bfebb8
      d7842974
  5. 22 Apr, 2016 4 commits
    • Hans Fugal's avatar
      update futures README · 056ba743
      Hans Fugal authored
      Summary:It's been awhile.
      
      Still has intern URLs (#10943549) but I'll fix that separately.
      
      Reviewed By: jsedgwick
      
      Differential Revision: D3213245
      
      fb-gh-sync-id: ff60193ff368deaac8ca233d4289f30d8f6bb223
      fbshipit-source-id: ff60193ff368deaac8ca233d4289f30d8f6bb223
      056ba743
    • Sven Over's avatar
      Subprocess: allow non-copyable callbacks · 0a9f3bc0
      Sven Over authored
      Summary:Instead of std::function<bool(int, int)>, use folly::Function to
      pass callbacks to Subprocess::communicate. This makes it possible
      to pass non-copyable callables, which is especially interesting
      because Subprocess::readLinesCallback returns a non-copyable
      object.
      
      This diff also fixes the forwarding of the callback passed to
      readLinesCallback in case you pass an lvalue reference.
      
      Reviewed By: snarkmaster
      
      Differential Revision: D3169956
      
      fb-gh-sync-id: 7a906f9a3ab50502fc04e0d83a23ca5e0201bb3e
      fbshipit-source-id: 7a906f9a3ab50502fc04e0d83a23ca5e0201bb3e
      0a9f3bc0
    • Yedidya Feldblum's avatar
      get_default and get_ref_default variants taking functions · 12244d01
      Yedidya Feldblum authored
      Summary:[Folly] `get_default` and `get_ref_default` variants taking functions.
      
      Useful if the default value is computationally expensive to construct or requires IO.
      
      Reviewed By: andriigrynenko, spacedentist
      
      Differential Revision: D3189247
      
      fb-gh-sync-id: 51c64293f8712d7590348d53cbfd892a5efd9e82
      fbshipit-source-id: 51c64293f8712d7590348d53cbfd892a5efd9e82
      12244d01
    • Tobias Ritzau's avatar
      Updates the internal representation of signals in NotificationQueue · 7c516d1c
      Tobias Ritzau authored
      Summary: The signals were represented using bytes in a pipe or using a count on an event fd (when available). This count was ever growing and caused the pipe to overflow, and in both cases you would get signals on empty queues. This diff only writes to the fd if it there are no bytes to read. Due to races there can still be multiple bytes in the pipe, but overflowing should not be possible. Instead of blindly signaling when there could be messages in the queue, the signals are now synchronized with the state of the queue so that the signals are drained when the queue is empty. This also made it possible to skip the semaphore behavior of the event fd which should improve perf.
      
      Reviewed By: dcolascione
      
      Differential Revision: D3198252
      
      fb-gh-sync-id: 39e620b10c254ffcacabc4c5ac36950a215d4803
      fbshipit-source-id: 39e620b10c254ffcacabc4c5ac36950a215d4803
      7c516d1c
  6. 21 Apr, 2016 2 commits
    • Taiyuan Zhang's avatar
      fix cancelAllFunctions · ba7c9b40
      Taiyuan Zhang authored
      Summary: as titled. When I tried re-adding all functions after cancelAllFunctions, it throws error. This is because it doesn't reset currentFunction to null.
      
      Reviewed By: jjs0
      
      Differential Revision: D3209237
      
      fb-gh-sync-id: 5b6e2d967fc3c0986320d23b8d61eb1bfbff8940
      fbshipit-source-id: 5b6e2d967fc3c0986320d23b8d61eb1bfbff8940
      ba7c9b40
    • chenkan's avatar
      fix: readvNoInt use wrong read function · e9a22fbd
      chenkan authored
      Summary: Closes https://github.com/facebook/folly/pull/401
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3207682
      
      Pulled By: snarkmaster
      
      fb-gh-sync-id: 617aeec0e6fe1f46d2464df4b72a3e91c953dc12
      fbshipit-source-id: 617aeec0e6fe1f46d2464df4b72a3e91c953dc12
      e9a22fbd
  7. 20 Apr, 2016 7 commits
    • Michael Lee's avatar
      Define more pieces of portability/GFlags · 0ed00b64
      Michael Lee authored
      Summary: Add more compatibility for missing gflags
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3202560
      
      fb-gh-sync-id: d25e4abfe8ceee9fb329c9ba12d259d1d03d4974
      fbshipit-source-id: d25e4abfe8ceee9fb329c9ba12d259d1d03d4974
      0ed00b64
    • Marcelo Juchem's avatar
      Added FOLLY_IGNORE and FOLLY_SEMICOLON helper macros · 8df3c4ab
      Marcelo Juchem authored
      Summary: these macros are generally useful for other higher-order macros
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3194777
      
      fb-gh-sync-id: 667fc51c681786ad422309ee463881dc22c972f7
      fbshipit-source-id: 667fc51c681786ad422309ee463881dc22c972f7
      8df3c4ab
    • Michael Lee's avatar
      Clean up deprecation warnings · 6086ec0c
      Michael Lee authored
      Summary:Clean up a deprecation warning for JSONSchema's use of
      Singleton. This is in experimental, so the interface change should be
      reasonable..
      
      Reviewed By: agoder
      
      Differential Revision: D3203348
      
      fb-gh-sync-id: 3283c7d9c507a545f3217eb5afc3734eb047b833
      fbshipit-source-id: 3283c7d9c507a545f3217eb5afc3734eb047b833
      6086ec0c
    • Michael Lee's avatar
      Fix use of dynamic {} initialization in JSONSchemaTest · 7ea1d04a
      Michael Lee authored
      Summary: find replace 's/{([0-9, a-z"-]+)}/dynamic::array(\1)/g'
      
      Reviewed By: agoder
      
      Differential Revision: D3203454
      
      fb-gh-sync-id: 064bb2bdd0e19a80da32e8f4eb730fc4268d7cad
      fbshipit-source-id: 064bb2bdd0e19a80da32e8f4eb730fc4268d7cad
      7ea1d04a
    • Mirek Klimos's avatar
      Reverted commit D3156698 · bc9d9e8c
      Mirek Klimos authored
      Summary:There're currently two ways to set RequestContext
      - RequestContext::create() - creates new context and sets it
      - RequestContext::setContext(context) - sets context previously captured by saveContext
      In most cases, the RequestContext is set back after the request is processed but sometimes it's not (especially with RequestContext::create). We want to measure cpu time for a request by measuring the total cpu time when a RequestContext is set, so we need to make sure that it's properly reset after the thread is done with the request. Scope guards can help us with that.
      
      Reviewed By: haijunz
      
      Differential Revision: D3156698
      
      fb-gh-sync-id: 7c3eb06c1cc27849071625011bf64c5ad36c0612
      fbshipit-source-id: 7c3eb06c1cc27849071625011bf64c5ad36c0612
      bc9d9e8c
    • Alexey Spiridonov's avatar
      Throw on errors in read callback · aa088ebe
      Alexey Spiridonov authored
      Summary: Before this fix, the callback would silently ignore `ret == -1` if the error isn't `EAGAIN`.
      
      Reviewed By: spacedentist
      
      Differential Revision: D3193845
      
      fb-gh-sync-id: e4a7aa37de7dab8ebe0633dd9888d8adc11dd1c2
      fbshipit-source-id: e4a7aa37de7dab8ebe0633dd9888d8adc11dd1c2
      aa088ebe
    • Michael Lee's avatar
      Backward compatibility for older versions of clang. · 007d2a6b
      Michael Lee authored
      Summary: `__attribute__((no_sanitize("address")))` is not valid in clang 3.6 and earlier
      
      Reviewed By: skotchvail
      
      Differential Revision: D3197412
      
      fb-gh-sync-id: bd555b030fe48268988299dd88b9b7aea54c1a73
      fbshipit-source-id: bd555b030fe48268988299dd88b9b7aea54c1a73
      007d2a6b
  8. 19 Apr, 2016 2 commits
    • Michael Lee's avatar
      `detail::Futex` wants 4 bytes but MicroLock only gives you one · 9b139cb4
      Michael Lee authored
      Summary: ^^^ this is a stack overflow in the test, and a possible stack or heap overflow.
      
      Reviewed By: dcolascione
      
      Differential Revision: D3151717
      
      fb-gh-sync-id: b4f0660ebbb89139dff003870e132c312068d9a8
      fbshipit-source-id: b4f0660ebbb89139dff003870e132c312068d9a8
      9b139cb4
    • Mark Isaacson's avatar
      Add make_array to folly · 1fb83fbc
      Mark Isaacson authored
      Summary: This function is being proposed in WG21, the C++ standards body for inclusion in the STL via the Library Fundamentals v2 TS. Using the normal constructor for a std::array with an initializer list introduces a source of coupling between the # of elements you put in the initializer list and the size of the array you specify as a template argument. Worse still, if you put less things in the initializer list than the template argument specifies, it doesn't warn you that you've probably made a pretty devious and subtle error. With this function your array size will always be the same as the # of things you actually put in it. What's more, in some cases this can deduce the type of the elements as well.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3164432
      
      fb-gh-sync-id: beceaae2ee01cd5f93dec86cf36efdb78a28b4a3
      fbshipit-source-id: beceaae2ee01cd5f93dec86cf36efdb78a28b4a3
      1fb83fbc
  9. 18 Apr, 2016 3 commits
    • Mirek Klimos's avatar
      API to set folly::RequestContext for current scope · 35a8cc20
      Mirek Klimos authored
      Summary:There're currently two ways to set RequestContext
      - RequestContext::create() - creates new context and sets it
      - RequestContext::setContext(context) - sets context previously captured by saveContext
      In most cases, the RequestContext is set back after the request is processed but sometimes it's not (especially with RequestContext::create). We want to measure cpu time for a request by measuring the total cpu time when a RequestContext is set, so we need to make sure that it's properly reset after the thread is done with the request. Scope guards can help us with that.
      
      Reviewed By: haijunz
      
      Differential Revision: D3156698
      
      fb-gh-sync-id: cfb678531810e8be5faaf02cb7803bd247557e42
      fbshipit-source-id: cfb678531810e8be5faaf02cb7803bd247557e42
      35a8cc20
    • Brian Walker's avatar
      NotificationQueue Logging for Android bug · 9ef64521
      Brian Walker authored
      Summary: Add some logging to figure out the state of the Qeueu when the write error happens.
      
      Differential Revision: D3190882
      
      fb-gh-sync-id: 6515d77df8aa3086922cb4053f2e437f3e527a36
      fbshipit-source-id: 6515d77df8aa3086922cb4053f2e437f3e527a36
      9ef64521
    • Sven Over's avatar
      remove superfluous include directive · 5e5884fc
      Sven Over authored
      Summary:folly::fibers does not use folly::MoveWrapper anymore, so no need to
      include that header file.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3169374
      
      fb-gh-sync-id: 2409b46156843fb0a1454b560c42186f1c412988
      fbshipit-source-id: 2409b46156843fb0a1454b560c42186f1c412988
      5e5884fc
  10. 16 Apr, 2016 2 commits
    • Sven Over's avatar
      remove MoveWrapper from io/async/AsyncUDPServerSocket.h · 9da32d8e
      Sven Over authored
      Summary:This is the last place in folly that uses MoveWrapper (other than
      the MoveWrapper implementation itself and its tests, of course).
      
      Instead of using a MoveWrapper, the object in question is moved
      into the lambda using C++14 syntax, and the lambda is moved in a
      call to EventBase::runInEventBaseThread which is possible now
      that the EventBase methods accept non-copyable callbacks.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3169316
      
      fb-gh-sync-id: 2dcb1a523ac417f4619c607898e58b572648e3da
      fbshipit-source-id: 2dcb1a523ac417f4619c607898e58b572648e3da
      9da32d8e
    • Andrii Grynenko's avatar
      Non-intrusive AtomicLinkedList · 71f01fb8
      Andrii Grynenko authored
      Summary:Renamed AtomicLinkedList to AtomicIntrusiveLinkedList.
      AtomicLinkedList is a simple AtomicIntrusiveLinkedList wrapper, which handles intrusive list hook.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3188171
      
      fb-gh-sync-id: 0823b04a48336d65e0a6a8cd412c75f52afe02b9
      fbshipit-source-id: 0823b04a48336d65e0a6a8cd412c75f52afe02b9
      71f01fb8
  11. 15 Apr, 2016 4 commits
    • Michael Lee's avatar
      Forgot to fix the guard for String.cpp · 61aa1f46
      Michael Lee authored
      Summary:9ab69bc7 removed `__APPLE__` around the strndup definition
      because it is defined on modern OSX.  But there was another reference
      in String.cpp. Fixing that.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3186360
      
      fb-gh-sync-id: 709c3b93cd22945e2237412637929df1979526c1
      fbshipit-source-id: 709c3b93cd22945e2237412637929df1979526c1
      61aa1f46
    • Christopher Dykes's avatar
      Remove the strings.h portability header · 8d5c32ba
      Christopher Dykes authored
      Summary:Although, according to the manpage, these functions are defined in `strings.h`, but they are also defined in `string.h`. We never actually use these functions via `strings.h`, and instead only ever reference them via `string.h`.
      To keep things sane, lets just move the functions into `string.h` and kill `strings.h`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3181596
      
      fb-gh-sync-id: 8a474df510ddafc4c595b08b809a7c33e3256177
      fbshipit-source-id: 8a474df510ddafc4c595b08b809a7c33e3256177
      8d5c32ba
    • David Goldblatt's avatar
      Correctly deduce RNG type in folly::Random · 015f5dc5
      David Goldblatt authored
      Summary:Fix a bug in folly where it can't infer any RNG type except the
      default-supplied parameter.
      
      Differential Revision: D3163421
      
      fb-gh-sync-id: 23d3963ba19dac93fa3407f3a2dfd1d9aa39ea44
      fbshipit-source-id: 23d3963ba19dac93fa3407f3a2dfd1d9aa39ea44
      015f5dc5
    • Michael Lee's avatar
      Fix build for no FOLLY_TLD_USE_FOLLY_TLS · caba7148
      Michael Lee authored
      Summary: unique_ptr doesn't cast to void*
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D3181346
      
      fb-gh-sync-id: 5b912d2b5d46f3c9953b44d5ced7a8e1b4320678
      fbshipit-source-id: 5b912d2b5d46f3c9953b44d5ced7a8e1b4320678
      caba7148
  12. 14 Apr, 2016 3 commits
    • Andrii Grynenko's avatar
      Improve folly::ThreadLocal perf · b25183f6
      Andrii Grynenko authored
      Summary: This fixes folly::ThreadLocal perf after several refactorings which touched the code.
      
      Reviewed By: ericniebler
      
      Differential Revision: D3170761
      
      fb-gh-sync-id: d44198f19aebc9f9f2588a65950efba0694e2a11
      fbshipit-source-id: d44198f19aebc9f9f2588a65950efba0694e2a11
      b25183f6
    • Andrii Grynenko's avatar
      Fix GuardPageAllocator to do mprotect lazily · a6692f12
      Andrii Grynenko authored
      Summary:Currently GuargPageAllocator mmap's a memory block enough for 100 fiber stacks and then protects a bottom page for each stack. If FiberManager is used to process a single task, protecting 100 stacks doesn't make much sense, but is costly.
      
      This change makes sure we protect a bottom page of every stack the first time given stack is requested.
      
      Reviewed By: alikhtarov
      
      Differential Revision: D3139944
      
      fb-gh-sync-id: d9d724eaa0e65a227eac1d09a33018e6cb098aae
      fbshipit-source-id: d9d724eaa0e65a227eac1d09a33018e6cb098aae
      a6692f12
    • Den Raskovalov's avatar
      remove duplicate licence prolog · 7c17b38a
      Den Raskovalov authored
      Reviewed By: yfeldblum
      
      Differential Revision: D3174112
      
      fb-gh-sync-id: 00a01f64fb43d2333818097bb2212e26e4dd5775
      fbshipit-source-id: 00a01f64fb43d2333818097bb2212e26e4dd5775
      7c17b38a
  13. 13 Apr, 2016 2 commits
    • Christopher Dykes's avatar
      Fix the includes in portability/Malloc.h · 0e657178
      Christopher Dykes authored
      Summary:We use `size_t` but didn't include `<stdlib.h>`.
      Fix #385
      
      Reviewed By: markisaa
      
      Differential Revision: D3171643
      
      fb-gh-sync-id: 1f915f9602c4be59a21cdf77b31fe18816f35f81
      fbshipit-source-id: 1f915f9602c4be59a21cdf77b31fe18816f35f81
      0e657178
    • Neel Goyal's avatar
      Add method to get the connect timeout used for an AsyncSocket · e6fd088b
      Neel Goyal authored
      Summary: Have the AsyncSocket keep track of the timeout used for connecting and add a getter to retrieve it.
      
      Reviewed By: hiteshk
      
      Differential Revision: D3170625
      
      fb-gh-sync-id: 61d0ecd8d975c49978a1cf222671aa16a2160499
      fbshipit-source-id: 61d0ecd8d975c49978a1cf222671aa16a2160499
      e6fd088b