Yedidya Feldblum [Fri, 5 Jan 2018 03:44:07 +0000 (19:44 -0800)]
Move folly/BitIterator.h to folly/container/
Summary: [Folly] Move `folly/BitIterator.h` to `folly/container/`.
Reviewed By: djwatson
Differential Revision:
D6648357
fbshipit-source-id:
5617e3210f58435fcbf3ef07fa745da47dbce475
Yedidya Feldblum [Fri, 5 Jan 2018 03:29:27 +0000 (19:29 -0800)]
Move InPlaceConstruction test in folly/test/SynchronizedTest.cpp
Summary: [Folly] Move `InPlaceConstruction` test in `folly/test/SynchronizedTest.cpp`.
Differential Revision:
D6653481
fbshipit-source-id:
f0eadfd6c2f41e9f597a666d01e40d5553447c70
Yedidya Feldblum [Fri, 5 Jan 2018 03:29:25 +0000 (19:29 -0800)]
Fix copyright lines for folly/Synchronized.h
Summary: [Folly] Fix copyright lines for `folly/Synchronized.h`.
Reviewed By: meyering
Differential Revision:
D6664326
fbshipit-source-id:
71a0fc17358e41dfc751b8bcb0736c288975a4a0
Neel Goyal [Fri, 5 Jan 2018 01:56:20 +0000 (17:56 -0800)]
Add utility to create stores
Summary: Add methods to create a X509StoreUniquePtr from a ca file or buffer.
Reviewed By: yfeldblum
Differential Revision:
D6662538
fbshipit-source-id:
646f61596f2787756b2fa5998a43f36d75a91d90
Keith Daigle [Thu, 4 Jan 2018 14:37:27 +0000 (06:37 -0800)]
Make FOLLY_HAS_COROUTINES dependent on header
Summary:
This breaks while building on aarch64 each time because the headers aren't
in the repo. I did a quick grep and I don't see anything in folly that
uses OptionalAwaitable or OptionalPromise so perhaps it's possible to
remove instead, can do that if preferred. Depends on
D6611609 to complete
build of tests cleanly.
Reviewed By: yfeldblum
Differential Revision:
D6643759
fbshipit-source-id:
f480d50383f85fbe905daaad74198b6557609347
Yedidya Feldblum [Wed, 3 Jan 2018 21:41:22 +0000 (13:41 -0800)]
Avoid allocs in dtors in futures collect
Summary:
[Folly] Avoid allocs in dtors in futures `collect`.
`CollectContext`, a detail helper type, allocates storage for a results vector in its dtor. This is an awkward situation and should be avoided.
Reviewed By: ericniebler
Differential Revision:
D6649299
fbshipit-source-id:
87746fcc78fa080f63505d7bb864aca6c4a3d7cb
Keith Daigle [Wed, 3 Jan 2018 14:58:45 +0000 (06:58 -0800)]
Fix to build SharedMutexTest on aarch64
Summary:
While trying to build folly on aarch64 found that the SharedMutexTest
wouldn't build because it uses RWTicketSpinLock which was only available
on x86 platforms. Updated to allow build on aarch64 after suggestion by Orvid
Reviewed By: yfeldblum
Differential Revision:
D6611609
fbshipit-source-id:
8ec477cdedac0f0a705608bbac42dd63b3efb919
Lee Howes [Wed, 3 Jan 2018 04:29:49 +0000 (20:29 -0800)]
Make consistent set of get and getTry methods on SemiFuture.
Summary: Complete set of get and getVia methods including addition of a result operation on FutureBase that provides functionality of the old getTry on Future by returning a Try by reference.
Reviewed By: yfeldblum
Differential Revision:
D6640056
fbshipit-source-id:
3ac01f7bc4b128e641f08d9a99280a18ffce82f9
Yedidya Feldblum [Tue, 2 Jan 2018 03:08:45 +0000 (19:08 -0800)]
Remove SingletonVault C bindings
Summary: [Folly] Remove `SingletonVault` C bindings. They are not generally needed.
Reviewed By: spalamarchuk
Differential Revision:
D6632104
fbshipit-source-id:
3aecb35277bc76a2171487404d6994a5ea296afc
Yedidya Feldblum [Tue, 2 Jan 2018 01:05:02 +0000 (17:05 -0800)]
Use member-invoke traits in LockTraits
Summary:
[Folly] Use member-invoke traits in `LockTraits`.
V.s. spelling out the SFINAE manually.
Reviewed By: Orvid
Differential Revision:
D6637380
fbshipit-source-id:
212e0cc5e54503b31e458b6bda93b2a3b24e6c59
Yedidya Feldblum [Tue, 2 Jan 2018 01:05:00 +0000 (17:05 -0800)]
invoke and member-invoke tweaks
Summary:
[Folly] `invoke` and member-`invoke` tweaks.
* Direct `static_cast` v.s. `std::forward` is okay.
* Implement member-`invoke` in terms of `invoke` and extract most of it to a helper type, minimizing the code directly generated by the preprocessor.
Reviewed By: spalamarchuk
Differential Revision:
D6644119
fbshipit-source-id:
e58a83d7ff2dd71b0377d864ef089c34e0239c8d
Yedidya Feldblum [Tue, 2 Jan 2018 00:54:27 +0000 (16:54 -0800)]
Add ColdClassTest.cpp to oss builds
Summary: [Folly] Add `ColdClassTest.cpp` to oss builds.
Reviewed By: spalamarchuk
Differential Revision:
D6648831
fbshipit-source-id:
f8d8a727d63e4e8b83391db454de990027f1bad4
Yedidya Feldblum [Tue, 2 Jan 2018 00:46:40 +0000 (16:46 -0800)]
Fix copyright lines for Bits.h and move BitsBenchmark.cpp
Summary: [Folly] Fix copyright lines for `Bits.h` and move `BitsBenchmark.cpp`.
Reviewed By: spalamarchuk
Differential Revision:
D6648828
fbshipit-source-id:
5eed558ac2d47a1497d64173bc84a4ca27d79764
Yedidya Feldblum [Mon, 1 Jan 2018 07:56:43 +0000 (23:56 -0800)]
Fix some copyright lines in folly/
Summary:
[Folly] Fix some copyright lines in `folly/`.
(Note: this ignores all push blocking failures!)
Reviewed By: Orvid
Differential Revision:
D6648215
fbshipit-source-id:
6fc446028ff79aa44116424e86ad454077717f8e
Yedidya Feldblum [Mon, 1 Jan 2018 07:56:41 +0000 (23:56 -0800)]
Fix some copyright lines in folly/lang/
Summary:
[Folly] Fix some copyright lines in `folly/lang/`.
(Note: this ignores all push blocking failures!)
Reviewed By: Orvid
Differential Revision:
D6648214
fbshipit-source-id:
fa2afdb8369252b74b914622ad39f7f27261d2c1
Yedidya Feldblum [Mon, 1 Jan 2018 07:56:39 +0000 (23:56 -0800)]
Fix some copyright lines in folly/experimental/symbolizer/
Summary:
[Folly] Fix some copyright lines in `folly/experimental/symbolizer/`.
(Note: this ignores all push blocking failures!)
Reviewed By: Orvid
Differential Revision:
D6648183
fbshipit-source-id:
36f9df5af91400a37dfa5ee2b209ffd47d5069df
Yedidya Feldblum [Sun, 31 Dec 2017 00:08:32 +0000 (16:08 -0800)]
constexpr_pow
Summary:
[Folly] `constexpr_pow`.
The power function. Initially, supports nonnegative integers only.
Reviewed By: spalamarchuk
Differential Revision:
D6646376
fbshipit-source-id:
33a5a45f496b6f3be52d0cd7e3a5f2cd7edb3026
Yedidya Feldblum [Sun, 31 Dec 2017 00:08:31 +0000 (16:08 -0800)]
Give detail functions in ConstexprMath.h decorated names
Summary:
[Folly] Give detail functions in `ConstexprMath.h` decorated names.
So that other code also in `namespace folly::detail` which invokes the non-detail functions will result in ambiguity.
Reviewed By: spalamarchuk
Differential Revision:
D6646313
fbshipit-source-id:
679e4cfe1c90f494acacef8b2a38a453db4d79d5
Yedidya Feldblum [Sat, 30 Dec 2017 22:26:38 +0000 (14:26 -0800)]
Shift monotonic_coarse_clock into Chrono.h and rename it to coarse_steady_clock
Summary: The rename is to bring it closer in line with the naming conventions in the standard library, and the move is because it doesn't make sense to have clocks defined in stop_watch.
Reviewed By: Orvid
Differential Revision:
D6329551
fbshipit-source-id:
09d9a48eb47b8fd3761a1bd4350d9ca748fe1f96
Yedidya Feldblum [Sat, 30 Dec 2017 08:43:53 +0000 (00:43 -0800)]
Include synchronization/SaturatingSemaphore.h in the makefile
Summary:
It was missing, so it wasn't being installed.
Fixes https://github.com/facebook/folly/issues/727
Reviewed By: Orvid
Differential Revision:
D6642322
fbshipit-source-id:
70c10e1265410f73b6c0cd759ce51a5176bfef83
Yedidya Feldblum [Sat, 30 Dec 2017 03:55:06 +0000 (19:55 -0800)]
Tweaks to folly::call_once and folly::once_flag
Summary:
[Folly] Tweaks to `folly::call_once` and `folly::once_flag`.
In particular:
* Move the template class out of `detail`.
* Add parameterization by the atomic type.
* Expand the comments.
Reviewed By: Orvid
Differential Revision:
D6637250
fbshipit-source-id:
3806580ca0badf8464f637750c4873b2aba9f916
Aaryaman Sagar [Thu, 28 Dec 2017 16:53:54 +0000 (08:53 -0800)]
Added remove_cvref
Summary:
std::remove_cvref is like std::decay, but without the function to
pointer and array to pointer decays
Backport of http://en.cppreference.com/w/cpp/types/remove_cvref
Reviewed By: yfeldblum
Differential Revision:
D6639513
fbshipit-source-id:
2a5e252678aacc09acf6ce4565872e7efb9b48f3
Aaryaman Sagar [Thu, 28 Dec 2017 16:53:05 +0000 (08:53 -0800)]
folly::Indestructible interface improvement
Summary:
As it stands the user cannot use initializer list constructors in the
underlying type, this fixes that and provides a good interface change.
This allows them to use list initialization, which works with initializer
lists
Reviewed By: yfeldblum
Differential Revision:
D6620994
fbshipit-source-id:
c29199f97b434d84dd8d4cee2f00c5eccb316166
Dave Watson [Thu, 28 Dec 2017 15:46:10 +0000 (07:46 -0800)]
synchronization/ParkingLot
Summary:
A ParkingLot API inspired by linux futex syscall, and WebKit's parkingLot.
Extends the futex interface with lambdas, such that many different sleeping abstractions
can be built.
Reviewed By: yfeldblum, aary
Differential Revision:
D6581826
fbshipit-source-id:
dba741fe4ed34f27bfad5f5747adce85741441e0
Lee Howes [Wed, 27 Dec 2017 21:10:51 +0000 (13:10 -0800)]
Add getVia and getTryVia to SemiFuture.
Summary: Add getVia and getTryVia to SemiFuture to allow driving chains of work conveniently in the current thread.
Reviewed By: yfeldblum
Differential Revision:
D6631898
fbshipit-source-id:
324ef342a44d4ef502188b3cffde17103f0e6cb2
Lee Howes [Wed, 27 Dec 2017 20:54:44 +0000 (12:54 -0800)]
Move getTry to subclasses.
Summary:
Move getTry from FutureBase to Future and SemiFuture.
Make SemiFuture version move the result out for consistency with get.
Reviewed By: yfeldblum
Differential Revision:
D6638561
fbshipit-source-id:
551c0f06ed52ef6d8976a5971a5e90b3ab793da0
Lee Howes [Wed, 27 Dec 2017 18:07:40 +0000 (10:07 -0800)]
Add continuation to semifuture return test.
Summary: Add more detail to testing return of SemiFuture from a continuation to ensure correct behaviour.
Reviewed By: yfeldblum
Differential Revision:
D6637565
fbshipit-source-id:
096a7ca140e6bdef7baab6725e86d25cf79742d8
Lee Howes [Wed, 27 Dec 2017 04:31:33 +0000 (20:31 -0800)]
Add deprecation comments to folly::makeFuture.
Summary:
To ensure that we do not end up with continuable futures without attached executors we should deprecate folly::makeFuture. In most cases folly::makeSemiFuture is adequate here.
This diff only adds comments to dissuade future use.
Reviewed By: yfeldblum
Differential Revision:
D6628800
fbshipit-source-id:
c2b91df351cc5980c1bfb752f7536d320ef8168a
Lee Howes [Wed, 27 Dec 2017 04:11:48 +0000 (20:11 -0800)]
Add getSemiFuture to folly::SharedPromise
Summary: Adds getSemiFuture functionality to folly::SharedPromise. Implements getFuture in terms of this, using folly::InlineExecutor to ensure that there is no change of behaviour.
Reviewed By: yfeldblum
Differential Revision:
D6628723
fbshipit-source-id:
0ce7c7773b9290998ce87f84fa5d82ba957f0313
Yedidya Feldblum [Wed, 27 Dec 2017 01:17:08 +0000 (17:17 -0800)]
Namespacing and comments in folly/Likely.h
Summary:
[Folly] Namespacing and comments in `folly/Likely.h`.
This adds `FOLLY_LIKELY` and `FOLLY_UNLIKELY`.
Reviewed By: Orvid
Differential Revision:
D6636136
fbshipit-source-id:
da93220201cabca91b4477ab98269a0febb735db
Yedidya Feldblum [Tue, 26 Dec 2017 21:37:51 +0000 (13:37 -0800)]
Tweaks to AtomicStruct
Summary: [Folly] Tweaks to `AtomicStruct`.
Reviewed By: Orvid
Differential Revision:
D6636432
fbshipit-source-id:
274c118a732287219c569d7d3f4e170f275518f1
Lee Howes [Tue, 26 Dec 2017 21:34:26 +0000 (13:34 -0800)]
Ensure that returning a semifuture from a continuation works correctly.
Summary: Returning a SemiFuture from a continuation should work by correctly checking the types and returning a folly::Future on the same executor as the original future that .then was applied to.
Reviewed By: yfeldblum
Differential Revision:
D6597273
fbshipit-source-id:
cf2016a344d4b29f1d31c1da20c89df5b4cfe64e
Yedidya Feldblum [Tue, 26 Dec 2017 21:34:14 +0000 (13:34 -0800)]
Remove folly/detail/UncaughtExceptionCounter.h
Summary:
[Folly] Remove `folly/detail/UncaughtExceptionCounter.h`.
It's a thin and unnecessary shell around `folly/UncaughtExceptions.h`.
Reviewed By: Orvid
Differential Revision:
D6636260
fbshipit-source-id:
cdf6fa5fefc9fd69586c1c4c1a8443c5e8543b1c
Yedidya Feldblum [Tue, 26 Dec 2017 18:59:25 +0000 (10:59 -0800)]
constexpr_log2_ceil
Summary: [Folly] `constexpr_log2_ceil`, like `constexpr_log2` but rounding up.
Reviewed By: Orvid
Differential Revision:
D6636433
fbshipit-source-id:
a10f031cc9c91cfeba7b74bbf143895a311ca772
Yedidya Feldblum [Tue, 26 Dec 2017 18:57:54 +0000 (10:57 -0800)]
Move folly/detail/Sleeper.h to folly/synchronization/detail/
Summary: [Folly] Move `folly/detail/Sleeper.h` to `folly/synchronization/detail/`.
Reviewed By: Orvid
Differential Revision:
D6636459
fbshipit-source-id:
e0b37459fe721c96837b653e652c1bc6bfeb5dce
Gabriel Wicke [Tue, 26 Dec 2017 05:53:42 +0000 (21:53 -0800)]
Fix link to window tests in folly/future/README.md
Summary:
Window tests were moved to a separate file. Update the README to the
new location.
Reviewed By: yfeldblum
Differential Revision:
D6636178
fbshipit-source-id:
0313dfe80de7686e1e530ed9eb4bbcefb459633c
Yedidya Feldblum [Tue, 26 Dec 2017 02:32:30 +0000 (18:32 -0800)]
Format digits10
Summary: [Folly] Format `digits10`.
Reviewed By: Orvid
Differential Revision:
D6636190
fbshipit-source-id:
6e6b834f6c9070d58f8e2b085b09df8b857fe878
Yedidya Feldblum [Tue, 26 Dec 2017 01:07:39 +0000 (17:07 -0800)]
Move folly/AtomicStruct.h to folly/synchronization/
Summary: [Folly] Move `folly/AtomicStruct.h` to `folly/synchronization/`.
Reviewed By: Orvid
Differential Revision:
D6636072
fbshipit-source-id:
87098e25fc40d0d60b4a657ba395418388e170fc
Yedidya Feldblum [Mon, 25 Dec 2017 23:35:53 +0000 (15:35 -0800)]
Remove unused boost dep from Conv.h
Summary: [Folly] Remove unused `boost` dep from `Conv.h`.
Reviewed By: Orvid
Differential Revision:
D6636040
fbshipit-source-id:
77dbfcf95f68c05346bce52d1a965e465c2efe3b
Yedidya Feldblum [Sun, 24 Dec 2017 02:15:37 +0000 (18:15 -0800)]
Update homebrew script to use gtest 1.8.0
Summary:
[Folly] Update homebrew script to use gtest 1.8.0, to be consistent with the docs.
Closes #722.
Reviewed By: Orvid
Differential Revision:
D6633606
fbshipit-source-id:
5e9a5790100fe7a408be7a9a77c847bece91d405
Yedidya Feldblum [Sat, 23 Dec 2017 08:09:39 +0000 (00:09 -0800)]
Move expensive Singleton code to .cpp
Summary:
[Folly] Move expensive `Singleton` code to `.cpp`.
Including string manipulation, `ostream::operator<<` operations, `throw` statements, etc,
Reviewed By: ot
Differential Revision:
D6632052
fbshipit-source-id:
82e0033d5042b02951cf3b05c55cf62c97cc2b6d
Lee Howes [Sat, 23 Dec 2017 03:29:14 +0000 (19:29 -0800)]
Add getSemiFuture to folly::Promise
Summary: Also deprecates folly::getFuture function.
Reviewed By: yfeldblum
Differential Revision:
D6594299
fbshipit-source-id:
67435f35dca660da049cd8c505ee9a21424c0d2b
Yedidya Feldblum [Sat, 23 Dec 2017 03:02:54 +0000 (19:02 -0800)]
Namespace portability symbols better in Singleton.cpp
Summary: [Folly] Namespace portability symbols better in `Singleton.cpp`.
Reviewed By: Orvid
Differential Revision:
D6631290
fbshipit-source-id:
eb802ace6a9bf704e011eb44710922c997a9cd8e
Yedidya Feldblum [Fri, 22 Dec 2017 04:31:44 +0000 (20:31 -0800)]
Fix the assumption in the propagate_const test about local layout
Summary: [Folly] Fix the assumption in the `propagate_const` test about local layout.
Reviewed By: aary
Differential Revision:
D6624962
fbshipit-source-id:
6871dc20f2b5ec2d1a86f520030c7cda8a225958
Aaryaman Sagar [Fri, 22 Dec 2017 03:06:56 +0000 (19:06 -0800)]
Returning reference to *this from propagate_const
Summary: As title
Reviewed By: yfeldblum
Differential Revision:
D6620395
fbshipit-source-id:
477aae84b2bbde2e79d46ae93c285909b56f575e
Andrii Nakryiko [Thu, 21 Dec 2017 20:47:30 +0000 (12:47 -0800)]
Fix crashing on corrupted ELF binaries with invalid offsets in ELF header.
Summary:
There are cases where ELF binaries are running fine, but have slightly
corrupted ELF headers, e.g., with section headers offset pointing beyond boundaries
of file. I'm guessing this is due to running strip or objdump with either some
particular combination of flags or some due to buggy version of those tools. This
change prevents from crashing on such files.
Reviewed By: yfeldblum
Differential Revision:
D6616027
fbshipit-source-id:
8cb3ac4475a51d1f1045c395977a6a77fbefffb2
Chad Austin [Wed, 20 Dec 2017 21:37:15 +0000 (13:37 -0800)]
test that the value remains alive even if the .then callback takes no arguments
Summary:
It was not clear to me, if a callback takes no arguments, the
underlying value is guaranteed to be alive during the execution of the
callback, so I wrote these tests.
Reviewed By: yfeldblum
Differential Revision:
D6594921
fbshipit-source-id:
6a658afc1bf4d29eaa9c62269ddc21c7f897ad01
Yedidya Feldblum [Wed, 20 Dec 2017 19:41:29 +0000 (11:41 -0800)]
Kill FOLLY_ALIGNED etc
Summary:
[Folly] Kill `FOLLY_ALIGNED` etc.
`alignas` is standardized as of C++11. Let us just use that.
Replace:
* `FOLLY_ALIGNED` with `alignas`
* `FOLLY_ALIGNED_MAX` with `alignas(folly::max_align_v)`
* `FOLLY_ALIGN_TO_AVOID_FALSE_SHARING` with `alignas(folly::hardware_destructive_interference_size)`
Because where `alignas` may be placed is more restrictive than where attributes may be placed, we also need to move these directives in some cases on top of doing the replacement.
Reviewed By: Orvid
Differential Revision:
D6555167
fbshipit-source-id:
4b05b570bace3f8c0fe810b6dd58781dd45757f4
Yedidya Feldblum [Wed, 20 Dec 2017 06:31:53 +0000 (22:31 -0800)]
Fix Build: propagate_const under GCC
Summary: [Folly] Fix Build: `propagate_const` under GCC.
Reviewed By: aary
Differential Revision:
D6609722
fbshipit-source-id:
47d8b0f2d54e0e5834383ea64c93af30927c921d
Zheng Yan [Wed, 20 Dec 2017 03:40:14 +0000 (19:40 -0800)]
Add readWithPriority to PriorityMPMCQueue
Summary: Add readWithPriority to PriorityMPMCQueue
Reviewed By: yfeldblum
Differential Revision:
D6606604
fbshipit-source-id:
07382e3c6d0f53a8727c059410c0577cf0aac82c
Yedidya Feldblum [Wed, 20 Dec 2017 03:02:51 +0000 (19:02 -0800)]
Add hardware_destructive_interference_size
Summary:
[Folly] Add `hardware_destructive_interference_size` and `hardware_constructive_interference_size` to `folly/lang/Align.h`.
As backports from C++17. Which may require keeping, depending on how stanard libraries choose to implement these.
And replace `CacheLocality::kFalseSharingRange` with `hardware_destructive_interference_size`.
Reviewed By: ot
Differential Revision:
D6554817
fbshipit-source-id:
bff49f5ca8b01d38fa806076f99201355df76cd9
Yedidya Feldblum [Wed, 20 Dec 2017 02:57:03 +0000 (18:57 -0800)]
propagate_const
Summary: [Folly] `propagate_const`, backported from C++ Library Fundamentals TS v2.
Reviewed By: ericniebler
Differential Revision:
D6589681
fbshipit-source-id:
cdc8981d17938b99afe60e2baefff7deb5316612
Dave Watson [Tue, 19 Dec 2017 22:30:19 +0000 (14:30 -0800)]
Fix erase in Iterate (2)
Summary:
Previously
D6579707.
Correctly advance to next item if we erase the current element. Corner cases were slightly off if we were at the end of a hash chain.
Reviewed By: yfeldblum
Differential Revision:
D6603518
fbshipit-source-id:
acb959e5bcd5da1c3df642b75985d464fdd3b23d
Dave Watson [Tue, 19 Dec 2017 21:17:28 +0000 (13:17 -0800)]
Fix ThreadLocal races
Summary:
I misread the ThreadLocal docs, thread destruction functions do *not* grab the accessAllTHreads_ lock
unless you use *strict* mode, and even then, it is only a read lock.
Easy enough to make the thread-destruction global bits to be atomic / use folly::Synchronized.
Reviewed By: yfeldblum
Differential Revision:
D6592905
fbshipit-source-id:
4ae600dff4c8c04751483a452ca7c07ef3f26380
Yedidya Feldblum [Tue, 19 Dec 2017 19:24:17 +0000 (11:24 -0800)]
Switch the Baton template params
Summary: [Folly] Switch the `Baton` template params for consistency with `SaturatingSemaphore`.
Reviewed By: davidtgoldblatt
Differential Revision:
D6591060
fbshipit-source-id:
44d6243d3185d95364a27e497216cc02fb3bc2e8
Dustin Pho [Tue, 19 Dec 2017 14:51:29 +0000 (06:51 -0800)]
Secure RNG utilities
Summary: Adding secure RNG utility functions (rand32, rand64, oneIn, randDouble01, randDouble).
Reviewed By: yfeldblum
Differential Revision:
D6551975
fbshipit-source-id:
720d138de1329669b1a15eb3e9cb3fe91ce982a4
Yedidya Feldblum [Tue, 19 Dec 2017 01:13:12 +0000 (17:13 -0800)]
Baton::ready, a const variant of try_wait
Summary: [Folly] `Baton::ready`, a `const` variant of `try_wait`.
Reviewed By: djwatson
Differential Revision:
D6508064
fbshipit-source-id:
ba458577574ba58165408a93238da7eb09adf1e6
Giuseppe Ottaviano [Mon, 18 Dec 2017 16:40:40 +0000 (08:40 -0800)]
Make global executors shutdown-safe
Summary:
The `get*Executor()` APIs don't check whether the singletons
haven't been destroyed already. Add a check and allow to return
`nullptr` during shutdown.
Also do a general clean up of the code, there was no reason to use
three independent singletons (non-atomically destroyed) for each
executor.
Reviewed By: philippv, luciang
Differential Revision:
D6589486
fbshipit-source-id:
20fb835db7e446bd811bbd6d5ddbc41db9e98b54
Christopher Dykes [Mon, 18 Dec 2017 04:56:49 +0000 (20:56 -0800)]
Remove the folly/Assume.h shim
Summary: The shim existed so that hhvm-third-party could be updated, and it has been, so it's time to remove the shim.
Reviewed By: yfeldblum
Differential Revision:
D6590439
fbshipit-source-id:
3e1b039c1df6cf1e74102f7b7b26aa90fae31ec0
Maged Michael [Sun, 17 Dec 2017 01:20:04 +0000 (17:20 -0800)]
Test UnboundedBlockingQueue in ThreadPoolExecutorTest
Summary: Test UnboundedBlockingQueue for the case in
D3527722
Reviewed By: ot
Differential Revision:
D6587163
fbshipit-source-id:
1465991018187c5f841e6e3e7a11676390e2f8f2
Maged Michael [Sat, 16 Dec 2017 22:13:47 +0000 (14:13 -0800)]
UnboundedQueue: Change try_dequeue variants to fail only if the queue is empty
Summary:
The current semantics of try_dequeue variants can cause problems in cases where based on external dependencies the consumer is guaranteed that the queue is not empty and depends on the success of try_dequeue. See https://github.com/facebook/wangle/commit/
abd07a06cae09efcd4347a9a019d59ae8a013c3f
This diff changes the semantics so that try_dequeue operations fail only if the queue is empty.
Reviewed By: yfeldblum
Differential Revision:
D6586156
fbshipit-source-id:
25d6085e28d3e24034ecf6a8bafab51c95464b01
Maged Michael [Sat, 16 Dec 2017 17:48:36 +0000 (09:48 -0800)]
UnboundedQueue: Fix advanceHead
Summary:
Without the fix multiple consumers may update head concurrently and cause it to lag. If this persists until the destruction time of the queue, some segments may be incorrectly retired twice.
The fix is to wait for head to advance to the current segment first before advancing head to the next segment.
Reviewed By: djwatson
Differential Revision:
D6588135
fbshipit-source-id:
3e916441bff5ad3f27de418601990c59a0b89bc2
Yedidya Feldblum [Sat, 16 Dec 2017 02:52:25 +0000 (18:52 -0800)]
Group the fields of UnboundedQueue
Summary:
[Folly] Group the fields of `UnboundedQueue`.
Into helper structures which are organized by, and aligned by, access.
This is all compiled away and has no runtime cost.
Reviewed By: magedm
Differential Revision:
D6555031
fbshipit-source-id:
94424747bf76a0a9a2bd59b6a94749efb391d6a7
Maged Michael [Sat, 16 Dec 2017 02:18:07 +0000 (18:18 -0800)]
Fix comments in UnboundedQueue and DynamicBoundedQueue
Summary: Fix typos and wording in comments.
Reviewed By: yfeldblum
Differential Revision:
D6584559
fbshipit-source-id:
b4b72f6c25c9f9e6fb3f2fbee69eea4a39b5c004
Yanbo Xu [Sat, 16 Dec 2017 01:10:05 +0000 (17:10 -0800)]
Revert
D6579707: [folly/ConcurrentHashMap] Fix erase in Iterate
Summary:
This reverts commit
a45f47a53e106d22daa9cf57be6c40c4f6a430d9
bypass-lint
Differential Revision:
D6579707
fbshipit-source-id:
6f6c35de5e05f8cf37491471e1ae1272290fe61b
Keith Daigle [Fri, 15 Dec 2017 22:17:36 +0000 (14:17 -0800)]
Fix PicoSpinLock on aarch64
Summary:
Found that building folly on aarch64 gave errors with
picospinlock. Looked and found that MSVC used casts
so I figured I'd try that
Reviewed By: yfeldblum
Differential Revision:
D6504689
fbshipit-source-id:
9565bae5ffab485da407b8609be92ef7db10ab72
Yanbo Xu [Fri, 15 Dec 2017 21:43:53 +0000 (13:43 -0800)]
Fix erase in Iterate
Summary:
The iterator returned from erase api could skip nodes. The fix is to
initialize the returned iterator with right value.
Reviewed By: djwatson
Differential Revision:
D6579707
fbshipit-source-id:
a45f47a53e106d22daa9cf57be6c40c4f6a430d9
Yedidya Feldblum [Fri, 15 Dec 2017 07:26:47 +0000 (23:26 -0800)]
Fix folly::max_align_v for Clang on ARMv7
Summary:
[Folly] Fix `folly::max_align_v` for Clang on ARMv7.
There is some problem with computing the correct result of `alignof` for a compound `union` POD type, because why wouldn't there be. The result *should* just be the max of the `alignof` of the type of each field if each field is default aligned - but not on some platforms! So we must compute the max directly.
Reviewed By: mzlee, Orvid
Differential Revision:
D6573548
fbshipit-source-id:
512a255fda64795104d71fde14372befa3bf41e4
Yedidya Feldblum [Fri, 15 Dec 2017 04:59:51 +0000 (20:59 -0800)]
Let Baton methods be noexcept
Summary: [Folly] Let `Baton` methods be `noexcept`.
Reviewed By: djwatson
Differential Revision:
D6508057
fbshipit-source-id:
2138a228d8291e79e9368cb77b0f63f4412524dc
Dan Melnic [Fri, 15 Dec 2017 03:59:27 +0000 (19:59 -0800)]
Fix zerocopy AsyncSocket memory leaks
Summary:
We currently leak ptr entries due to a missing map erase call in AsyncSocket::releaseZeroCopyBuf.
Also addZeroCopyBuf called when the bytesWritten == 0 will cause and extra id to be allocated. This will delay the deletion of the last IOBuf sent via zerocopy. The number of buffers can accumulate over time if the same bytesWritten == 0 situation is encountered.
Found when running the nbd-server zero downtime upgrade during heavy fio traffic.
Add an AsyncSocket::processZeroCopyWriteInProgress so we can drain the zerocopy msg error queue even after we set the ReadCallback to nullptr.
Reviewed By: djwatson
Differential Revision:
D6552982
fbshipit-source-id:
3d2fdca84ec3b5fc46c3bed06c0c9ede66ed565a
Chen Shen [Thu, 14 Dec 2017 23:26:53 +0000 (15:26 -0800)]
Fix xlog docs
Summary: When I was investigating the difference between glog/xlog I encountered this.
Reviewed By: yfeldblum
Differential Revision:
D6572117
fbshipit-source-id:
4130deb6cfed7cfb7d2433cdab292481beb2469f
Yedidya Feldblum [Thu, 14 Dec 2017 23:07:18 +0000 (15:07 -0800)]
Use explicit memory order in Baton::post
Summary: [Folly] Use explicit memory order in `Baton::post`.
Reviewed By: djwatson
Differential Revision:
D6502268
fbshipit-source-id:
a379ea711f165e3645ac2127a49824f46225b80a
Kyle Nekritz [Thu, 14 Dec 2017 19:32:57 +0000 (11:32 -0800)]
Move security protocol and application protocol APIs to AsyncTransport.
Summary: They belong here rather than AsyncTransportWrapper.
Reviewed By: siyengar
Differential Revision:
D6568209
fbshipit-source-id:
0856dba0b2d527ae68d33942b28e2c485a5b1f46
Maged Michael [Thu, 14 Dec 2017 18:33:06 +0000 (10:33 -0800)]
Dynamic Bounded Queue
Summary:
DynamicBoundedQueue supports:
- Dynamic memory usage that grows and shrink in proportion to the number of elements in the queue.
- Adjustable capacity that helps throttle pathological cases of producer-consumer imbalance that may lead to excessive memory usage.
- The adjustable capacity can also help prevent deadlock by allowing users to temporarily increase capacity substantially to guarantee accommodating producer requests that cannot wait.
- SPSC, SPMC, MPSC, MPMC variants.
- Blocking and spinning-only variants.
- Inter-operable non-waiting, timed until, timed for, and waiting variants of producer and consumer operations.
- Optional variable element weights.
Reviewed By: djwatson
Differential Revision:
D6462123
fbshipit-source-id:
5c7a7d88c3fa273211702af9ff78f6302afd2276
Maged Michael [Thu, 14 Dec 2017 02:54:26 +0000 (18:54 -0800)]
UnboundedQueue: Use alignas instead of FOLLY_ALIGNED
Summary: Use alignas instead of FOLLY_ALIGNED
Reviewed By: Orvid
Differential Revision:
D6554984
fbshipit-source-id:
5b11ac387faa137aa8dd0c35b6e9bb999cf0bf2d
Yedidya Feldblum [Thu, 14 Dec 2017 02:00:55 +0000 (18:00 -0800)]
Fix AsyncSocketTest.WriteErrorCallbackBytesWritten
Summary:
[Folly] Fix `AsyncSocketTest.WriteErrorCallbackBytesWritten`.
Thanks to congestion, especially when the tests are run concurrently, the expectations in the test were too restrictive.
If only 20KB are read, it is possible that only 20KB are acknowledged. The expectation was that if 20KB are read and the recv buffer and send buffer are both 8KB and 24KB are written then all 24KB are acknowledged, but congestion control disagrees.
It is possible that any number of bytes are written to the send buffer, from 28KB up to 40KB. And we have to explicitly wait for 28KB to be written even to know that (otherwise we only know that 20KB are written).
Differential Revision:
D6550804
fbshipit-source-id:
100d086972c1526b909da0dbb6e609c144d7b17b
Yedidya Feldblum [Thu, 14 Dec 2017 01:08:39 +0000 (17:08 -0800)]
constexpr_ceil
Summary: [Folly] `constexpr_ceil`, an integral rounding-up util.
Reviewed By: Orvid
Differential Revision:
D6558042
fbshipit-source-id:
6b42add9bf2e3605baf71391130c2a2c88cc4385
Yedidya Feldblum [Thu, 14 Dec 2017 00:29:37 +0000 (16:29 -0800)]
Move max_align_v and max_align_t to folly/lang/Align.h
Summary:
[Folly] Move `max_align_v` and `max_align_t` to `folly/lang/Align.h`.
And drop the macro `FOLLY_ALIGNED_MAX` - just use `alignas(max_align_v)` instead.
Reviewed By: Orvid
Differential Revision:
D6554677
fbshipit-source-id:
cacb335b141623506a41e95e0740613374279c6f
Yedidya Feldblum [Wed, 13 Dec 2017 22:53:49 +0000 (14:53 -0800)]
Remove unused #include <string.h> from folly/Portability.h
Summary: [Folly] Remove unused `#include <string.h>` from `folly/Portability.h`.
Reviewed By: Orvid
Differential Revision:
D6557374
fbshipit-source-id:
369ef0b622dc057e882ed0f4ad25b47fa3f05100
Christopher Dykes [Wed, 13 Dec 2017 20:49:43 +0000 (12:49 -0800)]
Explicitly refer to the std::chrono namespace to avoid conflicts with the folly::chrono namespace
Summary:
This is a hard requirement due to an upcoming change in Folly.
The codemod was only run on files that referenced the `std::chrono` namespace with an unqualified `chrono` and also used both the `std` and `folly` namespaces.
```
fbgr -sl "[^:]chrono::" | xargs grep -l "using namespace std;" | xargs grep -l "using namespace folly;" | xargs sed -r -i 's/([^:])chrono::([a-z])/\1std::chrono::\2/g'
```
Reviewed By: yfeldblum
Differential Revision:
D6547864
fbshipit-source-id:
4a8230d311edbaa173722a09b2773e8d053fae7e
RcRonco [Wed, 13 Dec 2017 19:26:12 +0000 (11:26 -0800)]
typo in io/Cursor.h
Summary: Closes https://github.com/facebook/folly/pull/721
Differential Revision:
D6558163
Pulled By: yfeldblum
fbshipit-source-id:
ed03aa92b54c61f9980a4759da29910aa77d5db6
Dave Watson [Wed, 13 Dec 2017 16:13:20 +0000 (08:13 -0800)]
RCU
Summary: This adds an RCU implementation, matching http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0461r1.pdf as closely as pratical. This implementation does not require thread registration or quiescence.
Reviewed By: magedm
Differential Revision:
D6330631
fbshipit-source-id:
2c729f3a4c0f151cde5d9a599ecd2a2c20c7da55
Adam Simpkins [Wed, 13 Dec 2017 00:30:16 +0000 (16:30 -0800)]
logging: minor clean up in Logger.h
Summary:
Update the comment describing the Logger class, and remove a `clang-format off`
since recent versions of `clang-format` appear to do a good job formatting this
macro.
Reviewed By: yfeldblum
Differential Revision:
D6525996
fbshipit-source-id:
6abbb3740afb53feb2418ca890cd78af1eb5f7a2
Adam Simpkins [Wed, 13 Dec 2017 00:30:13 +0000 (16:30 -0800)]
logging: add more documentation
Summary: Add several new documents describing the behavior of the folly logging library.
Reviewed By: yfeldblum
Differential Revision:
D6525997
fbshipit-source-id:
8ba2ff99c70c7566987b3da321526a16755e72bf
Yedidya Feldblum [Tue, 12 Dec 2017 06:10:59 +0000 (22:10 -0800)]
Switch to the try_wait_for and try_wait_until Baton APIs
Summary: Switch to the `try_wait_for` and `try_wait_until` `Baton` APIs.
Reviewed By: davidtgoldblatt
Differential Revision:
D6532103
fbshipit-source-id:
aa3ce64152d167bb9c9cb1f266be0f9f8bd498f5
Andrii Nakryiko [Tue, 12 Dec 2017 06:05:33 +0000 (22:05 -0800)]
Store filename and provide detailed message on data access assertion failure.
Summary:
It looks like not having offset/size/filename information is way more
harmful, than storing filename just for the sake of this error message.
Reviewed By: yfeldblum
Differential Revision:
D6536616
fbshipit-source-id:
469fbdf1deedd76ebd79cf98716c2c269cb10e4d
Yedidya Feldblum [Tue, 12 Dec 2017 04:19:06 +0000 (20:19 -0800)]
Assorted tweaks to folly/String.h
Summary:
[Folly] Assorted tweaks to `folly/String.h`.
* Use `void_t` in the definition of `IsConvertible`.
* Remove `AllConvertible`. Callers can use `StrictConjunction` instead.
* Move the `static_assert`s from the header to the source file.
Reviewed By: andrewjcg, ot
Differential Revision:
D6501515
fbshipit-source-id:
472ecf23bf7f06be211480b0aceea95f7e60dc21
Neel Goyal [Tue, 12 Dec 2017 02:48:49 +0000 (18:48 -0800)]
Fix case where ssl cert does not match key
Summary: In some cases, SSLContextManager seg faults if a cert and key do not match. This guards against that case when strictSSL = false, and throws a more useful error in the cases when SSL is required.
Reviewed By: xybu
Differential Revision:
D6513964
fbshipit-source-id:
8e63a22b346fd3f2a30d558a3659ab6794c7a105
Yedidya Feldblum [Tue, 12 Dec 2017 00:26:17 +0000 (16:26 -0800)]
folly::fibers::Baton API consistency with folly::Baton
Summary:
[Folly] `folly::fibers::Baton` API consistency with `folly::Baton`.
Specifically, the suite of `wait`, `try_wait`, `try_wait_for`, and `try_wait_until` members and member templates.
Hold onto the `timed_wait` members for now, but mark them deprecated.
Additionally, for consistency, offer main-context function params consistently for all `try_wait_for`, `try_wait_until`, and both variants of `timed_wait`.
Reviewed By: andriigrynenko
Differential Revision:
D6531145
fbshipit-source-id:
960fba48716b12b0ef53262786eacab88d8b2375
Nick Terrell [Tue, 12 Dec 2017 00:21:29 +0000 (16:21 -0800)]
Pass ZSTD_CONTENTSIZE_UNKNOWN
Summary:
Content size 0 as unknown is deprecated.
See code comments for details.
Reviewed By: felixhandte
Differential Revision:
D6521582
fbshipit-source-id:
876b94cc0123c1020b456cc8f4cd86997afe0619
Yedidya Feldblum [Sun, 10 Dec 2017 20:39:24 +0000 (12:39 -0800)]
Remove multi-poster support from Baton
Summary:
[Folly] Remove multi-poster support from `Baton`.
Code which needs multi-poster support may use `SaturatingSemaphore` instead.
Reviewed By: magedm
Differential Revision:
D6529661
fbshipit-source-id:
d9dc053ca984ef3a404e9361910b0044817d4905
Andrew Gallagher [Sun, 10 Dec 2017 08:55:21 +0000 (00:55 -0800)]
Fix some clang build failures on aarch64
Reviewed By: Orvid
Differential Revision:
D6387412
fbshipit-source-id:
4c1424ed4fa49e69885de8cd72e78169314fc502
Maged Michael [Sun, 10 Dec 2017 06:31:03 +0000 (22:31 -0800)]
UnboundedBlockingQueue: Remove extra include
Summary: Remove include not needed after recent change
Reviewed By: yfeldblum
Differential Revision:
D6529608
fbshipit-source-id:
904072084e180125d68bd1ef6e4dffb2939cd1eb
Yedidya Feldblum [Sun, 10 Dec 2017 01:09:24 +0000 (17:09 -0800)]
Fix signed integer overflow in StaticTracepointTest.cpp
Summary:
[Folly] Fix signed integer overflow in `StaticTracepointTest.cpp`.
It is undefined behavior and is caught by UBSAN in some test runs.
Reviewed By: Orvid
Differential Revision:
D6528445
fbshipit-source-id:
e4a199e9005b57bcd93c8c4b69f37ccb1e072bdf
Yedidya Feldblum [Sat, 9 Dec 2017 17:50:25 +0000 (09:50 -0800)]
Split Baton wait methods into fast and slow paths
Summary:
[Folly] Split `Baton` wait methods into fast and slow paths.
Force-inline the fast paths, and force-outline the slow paths.
Reviewed By: magedm
Differential Revision:
D6501992
fbshipit-source-id:
611e26b3cfeef01eb8d3a3500ae3ebc26bee6e86
Yedidya Feldblum [Sat, 9 Dec 2017 17:47:06 +0000 (09:47 -0800)]
Fix UBSAN failure in RangeTest.cpp with libstdc++-v4.9
Summary:
[Folly] Fix UBSAN failure in `RangeTest.cpp` with `libstdc++-v4.9`.
The implementation of `std::array` in `libstdc++-v4.9` has undefined behavior in the case of the zero-length array - dereferencing (but immediately taking the address again) of `nullptr`. This is fixed in `libstdc++-v5`.
Reviewed By: ot
Differential Revision:
D6528614
fbshipit-source-id:
26be6bdc28d9e6dc6e6293a4d4ecffd769c01413
Yedidya Feldblum [Sat, 9 Dec 2017 05:11:03 +0000 (21:11 -0800)]
replace std::dequeue with UMPMCQueue in UnboundedBlockingQueue
Summary: As above. Thanks magedm for giving us this beautiful piece of equipment!
Reviewed By: magedm
Differential Revision:
D6488661
fbshipit-source-id:
95aa9646ca1ea937bb1d055e9baa037896c3161e
Maged Michael [Fri, 8 Dec 2017 17:25:57 +0000 (09:25 -0800)]
UnboundedQueue: Add LgAlign template parameter - Refactor code
Summary:
- Add a template parameter, LgAlign, to control memory usage. The parameter is used in DynamicBoundedQueue.
- Refactor code.
Reviewed By: yfeldblum
Differential Revision:
D6508015
fbshipit-source-id:
6e17b1d8fd900595147dc4217e04d379a13fbdf8
Yedidya Feldblum [Fri, 8 Dec 2017 08:24:44 +0000 (00:24 -0800)]
Move folly/Bits.h to folly/lang/
Summary: [Folly] Move `folly/Bits.h` to `folly/lang/`.
Reviewed By: phoad, Orvid
Differential Revision:
D6495547
fbshipit-source-id:
a93159321df8277f8a4b4f10a5e4e0fc58cb6022
Eric Niebler [Fri, 8 Dec 2017 06:36:49 +0000 (22:36 -0800)]
prevent folly::Function<T const&()> from being initialized with a function that returns a prvalue
Summary: If the folly::Function returns by const& and the wrapped function returns a prvalue, it is guaranteed to return a dangling reference. Prevent it.
Reviewed By: yfeldblum, aary
Differential Revision:
D6487447
fbshipit-source-id:
61700b4688e29409eefa27f546b31ecac258cfdd