- 26 May, 2016 6 commits
-
-
Adam Simpkins authored
Summary: The two function definitions in this file are both normal function definitions, not template functions. Therefore this should be just a normal .cpp file, and not a -defs.h header file. Reviewed By: igorsugak Differential Revision: D3348439 fbshipit-source-id: 3ebe49c84493f5aab06c568d9df15a37c2c48836
-
Adam Simpkins authored
Summary: The default constructor creates the Subprocess in an uninitialized state. This makes it possible to default-construct a Subprocess, but only initialize it later using the move assignment operator. Even before this diff, it was possible to have Subprocess objects in uninitialized states after using the move assignment operator to move the data out of a Subprocess object. Reviewed By: yfeldblum Differential Revision: D3348490 fbshipit-source-id: aa6acef9be770de8f0ee118da294cb134f04a466
-
Christopher Dykes authored
Summary: There is no equivalent functionality for Windows, so disable it completely. Reviewed By: andriigrynenko Differential Revision: D3348481 fbshipit-source-id: 52a104f5a8013113f54d5b10c2f0f9b720eeb4f6
-
Christopher Dykes authored
Summary: Because, as MSVC rightly tells us, it's not actually defined anywhere. Reviewed By: yfeldblum Differential Revision: D3347654 fbshipit-source-id: 2162bc745136ee0129caa4de78f38e1361083cd1
-
Christopher Dykes authored
Summary: Because apparently I didn't actually add the `Windows.h` include when I added support for MSVC. This is safe for all platforms because the portability header only includes `Windows.h` when compiling on Windows. Reviewed By: yfeldblum Differential Revision: D3347785 fbshipit-source-id: 4f3e4e6c11953e2588b6fed287324a92e3ef8873
-
Christopher Dykes authored
Summary: Apparently I failed to accurately transfer this particular change to fbcode, which meant it didn't actually compile on Windows. Reviewed By: yfeldblum Differential Revision: D3347976 fbshipit-source-id: 775682f10ab68672f6463ccc69a222ae0a52a097
-
- 25 May, 2016 1 commit
-
-
Adam Simpkins authored
Summary: The existing Cursor::peek() method pre-dates the existence of folly::ByteRange, and so it returns a std::pair containing a pointer and length. This is usually more awkward to use than ByteRange. This adds a peekBytes() method that returns a ByteRange object, and updates all users of peek() in folly to use peekBytes() instead. Eventually I think we should add a FOLLY_DEPRECATED attribute to peek(). I will wait to add this tag until after converting a few other projects to use peekBytes(), though. Reviewed By: alandau Differential Revision: D3337302 fbshipit-source-id: 14220a059d915bf5adc66b8b283f7228b796a4dc
-
- 24 May, 2016 5 commits
-
-
Jon Maltiel Swenson authored
Summary: We should use folly::make_unique instead of std::make_unique in order to support compilers without support for C++14. Reviewed By: pavlo-fb Differential Revision: D3343288 fbshipit-source-id: 9150af752e57988962a7580851ffa32086c669d7
-
Christopher Dykes authored
Summary: MSVC is a massive pain in this respect, and, after testing many workarounds, and only ending up with it just emitting a dynamic initializer for them, it's easier to just generate the table as a `uint64_t` and load it explicitly. Reviewed By: yfeldblum Differential Revision: D3270226 fbshipit-source-id: 77bc84e58d393373de05a28a30dcb80b66c09c9f
-
Joseph Griego authored
Summary: If a TemporaryDirectory with scope DELETE_ON_DESTRUCTION gets moved and then goes out of scope, the directory will be deleted while the moved object still holds that path; we just clear the path from the old object to prevent this Reviewed By: yfeldblum Differential Revision: D3331079 fbshipit-source-id: 9c99413661e2436ccec937d3fa652da810133b34
-
Chad Parry authored
Summary: As part of my campaign to get `HHWheelTimer` away from intrusive ref-counting semantics, (cf. D3237530), I am redefining `HHWheelTimer::SharedPtr`. It is now a true `std::shared_ptr`. This will break clients that attempt the following: HHWheelTimer::UniquePtr timer1{HHWheelTimer::newTimer()}; HHWheelTimer::SharedPtr timer2{timer1}; In the past, that code would compile, because `timer2` could use the intrusive ref-counting, and `timer1` would still be valid. After this change, the second timer would need to be initialized with `std::move(timer1)` instead. The `UniquePtr` is starting to actually be unique. There is only one place in the code that actually tries to do such a copy. It's in a test, which I have changed. Any other instances of that behavior would create a compilation error, so it's impossible for one to be overlooked. Reviewed By: djwatson Differential Revision: D3337038 fbshipit-source-id: 085e4da41c9a142d253a1ac0b1dd0fc508dff704
-
Christopher Dykes authored
Summary: Actually __assume when we assume. Reviewed By: meyering Differential Revision: D3336033 fbshipit-source-id: 6c931e9f832dd1d861d03e3ad8e308f612522401
-
- 23 May, 2016 1 commit
-
-
Yedidya Feldblum authored
Summary: [Folly] Avoid `std::initializer_list` ctor in `folly::dynamic::array`. This will help deprecate the dangerous initializer-list constructor. The init-list construction is dangerous because its semantics vary by compiler and by compiler version. Reviewed By: ot Differential Revision: D3333148 fbshipit-source-id: 031e7593b7e28b299d5eeeb5ce7aed9216dd3a5c
-
- 20 May, 2016 3 commits
-
-
Andrii Grynenko authored
Summary: LoopKeepAlive handle can be grabbed to signal that some external event will later be scheduled on the EventBase via runInEventBaseThread. Usually the code which will be calling runInEventBaseThread only has a raw pointer to an EventBase, so it doesn't have any way to know it was destroyed. This change ensures that EventBase destructor will keep running the event loop until all such LoopKeepAlive handles are released. Reviewed By: yfeldblum Differential Revision: D3323835 fbshipit-source-id: 4071dae691a61dfebe2f1759cf99f661b161fa4a
-
Christopher Dykes authored
Summary: The configure script doesn't define `FOLLY_HAVE_PREADV` if `preadv` isn't supported, so these checks were wrong. Undefined defines expand to `0`, so this is safe. Fixes https://github.com/facebook/folly/issues/412 Reviewed By: mzlee, yfeldblum Differential Revision: D3329405 fbshipit-source-id: faee8951c68d4c67e06e7720dfc142e63a9dbd9f
-
Shubhanshu Agrawal authored
Summary: This diff templates folly::fibers::await by Baton. This would be helpful in passing in custom BatonType's, which is needed for D3007734 Depends on: D3314891 Reviewed By: andriigrynenko Differential Revision: D3314925 fbshipit-source-id: 9052dc503b9509f16cd41b5e3ede0479a98067aa
-
- 19 May, 2016 8 commits
-
-
Alejandro authored
Summary: The current use case of `std::memory_order_consume` in this project was intended to provide the appropriate synchronization in cases where a consumer spins on `while( spsc_queue.empty() ) {} `, and then attempts to use an element of the queue since the loop was broken out of, according to comments [here](https://reviews.facebook.net/D48141). Consume semantics do not provide this guarantee according to the standard since there is no data dependency from the producer that can be carried to the consumer by doing a load-consume from the corresponding functions. What is needed is a load-acquire. Current compilers promote `memory_order_consume` to `memory_order_acquire`. Thus, this example appears to work simply due to the promotion from consume to acquire, but would fail to generate the right synchronization instructions on weaker architectures once `memory_order_consume` is implemented as intended. Therefore, the `memory_order` should be tightened to `memory_order_acquire` to guarantee visibility to the consumer Closes https://github.com/facebook/folly/pull/381 Reviewed By: djwatson Differential Revision: D3173574 Pulled By: nbronson fbshipit-source-id: b109be2e74f016750a3fe1f848e3fc66e609b9d2
-
Yedidya Feldblum authored
Summary: [Folly] Extract `Try` to top-level. It was in `folly/futures/`, but this diff moves it to `folly/`. It is needed for futures, but it is are more general than futures and can be used separately. Use `folly/Try.h` instead of `folly/futures/Try.h`. Also fixes up all `#include` sites: hg grep -lw folly/futures/Try | xargs perl -pi -e 's,\bfolly/futures/Try\b,folly/Try,g' Reviewed By: markisaa Differential Revision: D3309908 fbshipit-source-id: cdf13f0ac0b0e36aa07e0f1d04870d06500c5874
-
Lucian Grijincu authored
Summary: ``` buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:365:7: runtime error: null pointer passed as argument 2, which is declared to never be null third-party-buck/build/glibc/include/string.h:70:33: note: nonnull attribute specified here #0 0x433a39 in _ZZN5folly13fbstring_coreIcEC1EPKcmbENKUlvE_clEv ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:365:7 #1 0x4335a9 in _ZN5folly14ScopeGuardImplIZNS_13fbstring_coreIcEC1EPKcmbEUlvE_E7executeEv ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/ScopeGuard.h:153:29 #2 0x4335a9 in _ZN5folly14ScopeGuardImplIZNS_13fbstring_coreIcEC1EPKcmbEUlvE_ED2Ev ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/ScopeGuard.h:130 #3 0x4335a9 in folly::fbstring_core<char>::fbstring_core(char const*, unsigned long, bool) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:427 #4 0x4353fa in folly::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, folly::fbstring_core<char> >::basic_fbstring(char const*, unsigned long, std::allocator<char> const&) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:1038:9 ``` Reviewed By: Gownta Differential Revision: D3321266 fbshipit-source-id: 28d5aef16e91a98066a1de6bab95403fbc63eaab
-
Andrii Grynenko authored
Summary: folly::fibers have been used by mcrouter for more than 2 years, so not really experimental. Reviewed By: pavlo-fb Differential Revision: D3320595 fbshipit-source-id: 68188f92b71a4206d57222993848521ca5437ef5
-
Shubhanshu Agrawal authored
Summary: This diff adds a static await method to Promise. Also after this, folly::fibers::await is just a wrapper around Promise::await. This also removes the friend relationship between Promise and await. This would be helpful in making the folly::fibers::await templated by Baton changes easier to make. Reviewed By: andriigrynenko Differential Revision: D3314891 fbshipit-source-id: 361546c078caafd067734d2f474c617d7fb888b0
-
Yedidya Feldblum authored
Summary: [Folly] Make `Try` independent of `Future`. `Try` is useful for futures, but it can be used independently from futures as well. Reviewed By: djwatson Differential Revision: D3319130 fbshipit-source-id: badfcaa482dee6e7bdef14a501b4efc91634fa51
-
Andrii Grynenko authored
Reviewed By: yfeldblum Differential Revision: D3317666 fbshipit-source-id: f5558b117c8da74789ee444cdaa00231e75dc31e
-
iivlev authored
Summary: Closes https://github.com/facebook/folly/pull/403 Reviewed By: yfeldblum Differential Revision: D3320043 Pulled By: elliottneilclark fbshipit-source-id: 5d21421216180fb601015a40a3de79e3dd2a162e
-
- 18 May, 2016 5 commits
-
-
Yedidya Feldblum authored
Summary: [Folly] Flesh out the comments about `Unit`. * Remove mention of `Future`. * Compare `unit` to `void`. Reviewed By: djwatson Differential Revision: D3316114 fbshipit-source-id: d30cf36cc029025734bb16c5bdbd640a289cad79
-
Yedidya Feldblum authored
Summary: [Folly] Extract `Unit` to top-level. It was in `folly/futures/`, but this diff moves it to `folly/`. It is needed for futures, but it is more general than futures and can be used separately. Users must replace `folly/futures/Unit.h` with `folly/Unit.h`. Also codemods existing usage sites: ``` hg grep -lw folly/futures/Unit.h | xargs perl -pi -e 's,\bfolly/futures/Unit\.h\b,folly/Unit.h,g' ``` Reviewed By: igorsugak Differential Revision: D3314280 fbshipit-source-id: 16279b76b1d24529bec49077ccb36cd7d39f23b8
-
Ilya Maykov authored
Summary: Added a version of IOBuf::wrapBuffer() which returns the new IOBuf by value rather than heap-allocating it. Motivation: we have a lot of places in the crypto code that do something like this: // take a string or vector parameter auto buf = folly::IOBuf::wrapBuffer( /* string or vector goes here */); // do something with buf // return In these cases, a stack-allocated IOBuf would save us from an unnecessary heap allocation. But calling `folly::IOBuf(folly::IOBuf::WrapBufferOp::WRAP_BUFFER, ...)` is gross and in practice people just call the much more readable `wrapBuffer()` function. Hypothesis: readability trumps performance, but if we had a readable version that returned a stack-allocated IOBuf, it might see usage. Reviewed By: yfeldblum Differential Revision: D3314037 fbshipit-source-id: 4d4b5ec1d067762a27de1d7d6f7cac406388bfa3
-
Andrii Grynenko authored
Summary: Baton::post has to be the last step of Promise::setTry. If Promise is not owned by the posting thread, it may be destroyed right after Baton::post is called. Reviewed By: pavlo-fb Differential Revision: D3312506 fbshipit-source-id: 6d5c3f0925c3bb9cd3f981e7550f888d5ed76189
-
Yedidya Feldblum authored
Summary: [Folly] Keep the `Unit` test suite free of `Promise` and `Future`. Move the `Promise`-related tests to the `Promise` test suite and the `Future`-related tests to the `Future` test suite. Reviewed By: djwatson Differential Revision: D3313635 fbshipit-source-id: 05c82c8719719d7709063ad58a4806036ca10fb3
-
- 17 May, 2016 3 commits
-
-
Yedidya Feldblum authored
Summary: [Folly] Simplify `Unit`. Specifically: * Make `Unit::Lift` and `Unit::Drop` simply be aliases to `std::conditional<...>`. No need for anything more complicated. * Remove `is_void_or_unit`, which is unused and unnecessary. Reviewed By: djwatson Differential Revision: D3312481 fbshipit-source-id: 280d40aa8ef91c52f96a51b03e0a109d76c939ec
-
Marcus Holland-Moritz authored
Reviewed By: meyering, luciang Differential Revision: D3310683 fbshipit-source-id: c86471d54062b2f3455f15fb73340fac486d9e44
-
Yedidya Feldblum authored
Summary: [Folly] `IPAddress::validate`. Reviewed By: igorsugak Differential Revision: D3308683 fbshipit-source-id: 48af18d6930f16718372021a4cc08062bf17327e
-
- 16 May, 2016 2 commits
-
-
Andrii Grynenko authored
Summary: This fixes a race which can only be exposed if Promise is owned by the same thread which was calling await and Promise is fulfilled from a different thread. What could happen then was: 1. Thread 2 fulfills the promise and thus saves the value and posts Baton. 2. Thread 1 wakes up, await returns and then Thread 1 destroys the Promise. 3. Promise destructor checks value_, which is still not null, so it tries to fulfil it with exception. Reviewed By: spalamarchuk Differential Revision: D3306969 fbshipit-source-id: adf799cfd7b75b0201fa675a9e44ac7c7c42ac95
-
Andrii Grynenko authored
Summary: This fixes fibers::await to correctly handle exception thrown by user-passed lambda. Await still always waits for the promise to be fulfilled (if the promise was not moved out, it will be destroyed and thus auto-fulfilled with "promise not fulfilled" exception). However if user-passed lambda throws, promise result is ignored (even if exception) and exception thrown by lambda is re-thrown. Reviewed By: pavlo-fb Differential Revision: D3303393 fbshipit-source-id: c4ba01fde0e156cc88e5d07aaf763e3abe121d11
-
- 14 May, 2016 5 commits
-
-
Yedidya Feldblum authored
Summary: [Folly] Prefer `constexpr` to preprocessor conditionals when checking endianness. Using `if (folly::kIsLittleEndian) {` v.s. `#if __BYTE_ORDER__ == __LITTLE_ENDIAN__`. Reviewed By: meyering Differential Revision: D3296770 fbshipit-source-id: b26df83fdd42a50663746fc7c9d5fbe67e6671eb
-
Yedidya Feldblum authored
Summary: [Wangle] A thread-per-task executor. Moved from Folly into Wangle and fleshed out. * Starts task threads from a control thread, rather than starting task threads from the submitter thread. Because starting task threads is likely to be more expensive than moving a functor. * Joins task threads as they finish, rather than joining all task threads in the executor's destructor. Suitable for running tasks which spend most of their time sleeping. Such as blocking IO, blocking fork-exec-wait, etc., when it is inconvenient to use the nonblocking variants with an IO executor. Reviewed By: simpkins Differential Revision: D3286988 fbshipit-source-id: 4b91133a7d55332ebbae020c1515c60e816906b3
-
Lucian Grijincu authored
folly: fbstring: ubsan: memcpy/memmove are marked as nonnull - avoid calling them when size == 0 and (likely) source is nullptr Summary: Also see {D3295811} Differential Revision: D3302564 fbshipit-source-id: 3f2dbf5a6cfa8199682cb4af90aac372d501919a
-
Lucian Grijincu authored
Reviewed By: ot Differential Revision: D3300437 fbshipit-source-id: 7e0add5dab6dc1c891b742b4bcedea656c8284a9
-
Lucian Grijincu authored
Reviewed By: meyering Differential Revision: D3283226 fbshipit-source-id: 7ae2ec7741ca53c494e8325e30f2995a241674c0
-
- 13 May, 2016 1 commit
-
-
Mirek Klimos authored
Summary: ^, as discussed on D3279644 Reviewed By: andriigrynenko Differential Revision: D3299473 fbshipit-source-id: dc302132db64399f768d69c641f848d0da1075c4
-