Skip to content
Commits on Apr 22, 2016
  1. @fugalh

    update futures README

    fugalh committed with Facebook Github Bot 0 Apr 22, 2016
    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
  2. @spacedentist

    Subprocess: allow non-copyable callbacks

    spacedentist committed with Facebook Github Bot 6 Apr 22, 2016
    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
  3. @yfeldblum

    get_default and get_ref_default variants taking functions

    yfeldblum committed with Facebook Github Bot 4 Apr 21, 2016
    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
  4. Updates the internal representation of signals in NotificationQueue

    Tobias Ritzau committed with Facebook Github Bot 1 Apr 21, 2016
    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
Commits on Apr 21, 2016
  1. fix cancelAllFunctions

    Taiyuan Zhang committed with Facebook Github Bot 2 Apr 21, 2016
    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
  2. @chenkan1994

    fix: readvNoInt use wrong read function

    chenkan1994 committed with Facebook Github Bot 4 Apr 21, 2016
    Summary: Closes #401
    
    Reviewed By: yfeldblum
    
    Differential Revision: D3207682
    
    Pulled By: snarkmaster
    
    fb-gh-sync-id: 617aeec0e6fe1f46d2464df4b72a3e91c953dc12
    fbshipit-source-id: 617aeec0e6fe1f46d2464df4b72a3e91c953dc12
Commits on Apr 20, 2016
  1. @mzlee

    Define more pieces of portability/GFlags

    mzlee committed with Facebook Github Bot 1 Apr 20, 2016
    Summary: Add more compatibility for missing gflags
    
    Reviewed By: yfeldblum
    
    Differential Revision: D3202560
    
    fb-gh-sync-id: d25e4abfe8ceee9fb329c9ba12d259d1d03d4974
    fbshipit-source-id: d25e4abfe8ceee9fb329c9ba12d259d1d03d4974
  2. @juchem

    Added FOLLY_IGNORE and FOLLY_SEMICOLON helper macros

    juchem committed with Facebook Github Bot 9 Apr 20, 2016
    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
  3. @mzlee

    Clean up deprecation warnings

    mzlee committed with Facebook Github Bot 3 Apr 20, 2016
    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
  4. @mzlee

    Fix use of dynamic {} initialization in JSONSchemaTest

    mzlee committed with Facebook Github Bot 3 Apr 20, 2016
    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
  5. @myreg

    Reverted commit D3156698

    myreg committed with Facebook Github Bot 5 Apr 20, 2016
    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
  6. Throw on errors in read callback

    Alexey Spiridonov committed with Facebook Github Bot 0 Apr 20, 2016
    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
  7. @mzlee

    Backward compatibility for older versions of clang.

    mzlee committed with Facebook Github Bot 7 Apr 19, 2016
    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
Commits on Apr 19, 2016
  1. @mzlee

    `detail::Futex` wants 4 bytes but MicroLock only gives you one

    mzlee committed with Facebook Github Bot 6 Apr 19, 2016
    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
  2. @markisaa

    Add make_array to folly

    markisaa committed with Facebook Github Bot 1 Apr 19, 2016
    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
Commits on Apr 18, 2016
  1. @myreg

    API to set folly::RequestContext for current scope

    myreg committed with Facebook Github Bot 6 Apr 18, 2016
    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
  2. NotificationQueue Logging for Android bug

    Brian Walker committed with Facebook Github Bot 4 Apr 18, 2016
    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
  3. @spacedentist

    remove superfluous include directive

    spacedentist committed with Facebook Github Bot 4 Apr 17, 2016
    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
Commits on Apr 16, 2016
  1. @spacedentist

    remove MoveWrapper from io/async/AsyncUDPServerSocket.h

    spacedentist committed with Facebook Github Bot 8 Apr 15, 2016
    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
  2. @andriigrynenko

    Non-intrusive AtomicLinkedList

    andriigrynenko committed with Facebook Github Bot 6 Apr 15, 2016
    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
Commits on Apr 15, 2016
  1. @mzlee

    Forgot to fix the guard for String.cpp

    mzlee committed with Facebook Github Bot 2 Apr 15, 2016
    Summary:9ab69bc 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
  2. @Orvid

    Remove the strings.h portability header

    Orvid committed with Facebook Github Bot 6 Apr 15, 2016
    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
  3. @davidtgoldblatt

    Correctly deduce RNG type in folly::Random

    davidtgoldblatt committed with Facebook Github Bot 9 Apr 15, 2016
    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
  4. @mzlee

    Fix build for no FOLLY_TLD_USE_FOLLY_TLS

    mzlee committed with Facebook Github Bot 5 Apr 14, 2016
    Summary: unique_ptr doesn't cast to void*
    
    Reviewed By: andriigrynenko
    
    Differential Revision: D3181346
    
    fb-gh-sync-id: 5b912d2b5d46f3c9953b44d5ced7a8e1b4320678
    fbshipit-source-id: 5b912d2b5d46f3c9953b44d5ced7a8e1b4320678
Commits on Apr 14, 2016
  1. @andriigrynenko

    Improve folly::ThreadLocal perf

    andriigrynenko committed with Facebook Github Bot 8 Apr 14, 2016
    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
  2. @andriigrynenko

    Fix GuardPageAllocator to do mprotect lazily

    andriigrynenko committed with Facebook Github Bot 1 Apr 13, 2016
    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
  3. @evilmucedin

    remove duplicate licence prolog

    evilmucedin committed with Facebook Github Bot 5 Apr 13, 2016
    Reviewed By: yfeldblum
    
    Differential Revision: D3174112
    
    fb-gh-sync-id: 00a01f64fb43d2333818097bb2212e26e4dd5775
    fbshipit-source-id: 00a01f64fb43d2333818097bb2212e26e4dd5775
Commits on Apr 13, 2016
  1. @Orvid

    Fix the includes in portability/Malloc.h

    Orvid committed with Facebook Github Bot 4 Apr 13, 2016
    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
  2. @ngoyal

    Add method to get the connect timeout used for an AsyncSocket

    ngoyal committed with Facebook Github Bot 0 Apr 13, 2016
    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
Commits on Apr 12, 2016
  1. @mzlee

    Sorry, forgot to add portability/Memory.cpp

    mzlee committed with Facebook Github Bot 5 Apr 12, 2016
    Summary: Add it to the Makefile.am
    
    Reviewed By: Orvid
    
    Differential Revision: D3168833
    
    fb-gh-sync-id: 7184acc565ffebde0f93bc8bdce4d38ba1a79923
    fbshipit-source-id: 7184acc565ffebde0f93bc8bdce4d38ba1a79923
Commits on Apr 11, 2016
  1. @alexshap

    Fix the order of EXPECT_EQ parameters

    alexshap committed with Facebook Github Bot 0 Apr 11, 2016
    Summary:Change the order of EXPECT_EQ parameters to
    EXPECT_EQ(expected, actual). It will make gtest print
    the correct error message if a test fails.
    
    Reviewed By: yfeldblum
    
    Differential Revision: D3161878
    
    fb-gh-sync-id: 69e4536c6f396858d189a9d25904ef4df639ad49
    fbshipit-source-id: 69e4536c6f396858d189a9d25904ef4df639ad49
Commits on Apr 10, 2016
  1. @yfeldblum

    Some cleanups to folly::EventBase after converting to folly::Function

    yfeldblum committed with Facebook Github Bot 2 Apr 10, 2016
    Summary:[Folly] Some cleanups to `folly::EventBase` after converting to `folly::Function`.
    
    * Fix up some comments referring to `std::function`.
    * Remove the `SmallFunctor` bits - `folly::Function` takes over for that.
    * Remove `runFunctionPtr` - it's unused.
    
    Reviewed By: spacedentist
    
    Differential Revision: D3155511
    
    fb-gh-sync-id: 38c75d1254993f59c8eaa7826dc8d9facb50a3a1
    fbshipit-source-id: 38c75d1254993f59c8eaa7826dc8d9facb50a3a1
Commits on Apr 9, 2016
  1. Add <new> header for placement new

    Adam Norton committed with Facebook Github Bot 0 Apr 8, 2016
    Summary: This header is necessary for the placement new operator used in the construct method (line 265)
    
    Reviewed By: yfeldblum
    
    Differential Revision: D3156741
    
    fb-gh-sync-id: 84a64821553b42d46fb70b5ee267a401028c94f2
    fbshipit-source-id: 84a64821553b42d46fb70b5ee267a401028c94f2
Commits on Apr 7, 2016
  1. Extensibility for folly::to<> through ADL

    Tom Jackson committed with Facebook Github Bot 9 Apr 7, 2016
    Summary: Primarily to support slightly more flexible implementations of `split()`;
    
    Reviewed By: ot
    
    Differential Revision: D3116763
    
    fb-gh-sync-id: 69023c0f26058516f25b9c1f9824055efc7021f9
    fbshipit-source-id: 69023c0f26058516f25b9c1f9824055efc7021f9
  2. DynamicParser to reliably and reversibly convert JSON to structs

    Alexey Spiridonov committed with Facebook Github Bot 1 Apr 7, 2016
    Summary:We have a bunch of code that manually parses `folly::dynamic`s into program structures. I can be quite hard to get this parsing to be good, user-friendly, and concise. This diff was primarily motivated by the mass of JSON-parsing done by Bistro, but this pattern recurs in other pieces of internal code that parse dynamics.
    
    This diff **not** meant to replace using Thrift structs with Thrift's JSON serialization / deserialization. When all you have to deal with is correct, structured plain-old-data objects produced by another program -- **not** manually entered user input -- Thrift + JSON is perfect. Go use that.
    
    However, sometimes you need to parse human-edited configuration. The input JSON might have complex semantics, and require validation beyond type-checking. The UI for editing your configs can easily enforce correct JSON syntax. Perhaps, you can use `folly/experimental/JSONSchema.h` to have your edit UI provide type correctness. Despite all this, people can still make semantic errors, and those can be impossible to detect until you interpret the config at runtime. Also, as your system evolves, sometimes you need to break semantic backwards-compatibility for the sake of moving forward ? thus making previously valid configurations invalid, and requiring them to be fixed up manually.
    
    So, people end up needing to write manual parsers for `dynamic`s. These all have very similar recurring issues:
    
     - Verbose: to get an int field out of an object, typical code: (i) tests if the field is present, (ii) checks if the field is an integer, (iii) extracts the integer. Sometimes, you also want to handle exceptions, and compose helpful error messages. This makes the code far longer than its intent, and encourages people to write bad parsers.
    
     - Unsystematic: sometimes, we use `if (const auto* p = dyn_obj.get_ptr("key")) { ... }`, other times we use `dyn_obj.getDefault()` or `if (dyn_obj.count())`, and so on. The patterns differ subtly in meaning. Exceptions sometimes get thrown, leading to error messages that cannot be understood by the user.
    
     - Imperative parses: a typical parse proceeds step by step, and throws at the earliest error. This is bad because (i) errors have to be fixed one-by-one, instead of getting a full list upfront, (ii) even if 99% of the config is parseable, the imperative code has no way of recording the information it would have parsed after the first error.
    
     `DynamicParser` fixes all of the above, and makes your parsing so clean that you might not even bother with `JSONSchema` as your first line of defense -- type-coercing, type-enforcing, friendly-error-generating C++ ends up being more concise. Besides all the sweet syntax sugar, `DynamicParser` lets you parse **all** the valid data in your config, while recording  *all* the errors in a way that does not lose the original, buggy config. This means your code can parse a config that has errors, and still be able to meaningfully export it back to JSON. As a result, stateless clients (think REST APIs) can provide a far better user experience than just discarding the user?s input, and returning a cryptic error message.
    
    For the details, read the docs (and see the example) in `DynamicParser.h`. Here are the principles of `DynamicParser::RECORD` mode in a nutshell:
     - Pre-populate your program struct with meaningful defaults **before** you parse.
     - Any config part that fails to parse will keep the default.
     - Any config part that parses successfully will get to update the program struct.
     - Any errors will be recorded with a helpful error message, the portion of the dynamic that caused the error, and the path through the dynamic to that portion.
    
     I ported Bistro to use this in D3136954. I looked at using this for JSONSchema's parsing of schemas, but it seemed like too much trouble for the gain, since it would require major surgery on the code.
    
    Reviewed By: yfeldblum
    
    Differential Revision: D2906819
    
    fb-gh-sync-id: aa997b0399b17725f38712111715191ffe7f27aa
    fbshipit-source-id: aa997b0399b17725f38712111715191ffe7f27aa
Something went wrong with that request. Please try again.