folly.git
6 years agoUnsafe pre-sorted construction for sorted-vector containers
Yedidya Feldblum [Fri, 12 Jan 2018 05:56:07 +0000 (21:56 -0800)]
Unsafe pre-sorted construction for sorted-vector containers

Summary:
[Folly] Unsafe pre-sorted construction for sorted-vector containers.

If the backing container type can be constructed directly in sorted order or can be determined in advance to be in sorted order, then a special constructor can help code take advantage of this condition by avoiding an extra invocation of `std::sort`.

Reviewed By: spalamarchuk

Differential Revision: D6708379

fbshipit-source-id: 25d886b0814dc9230c6046ed1e7f199fac47754e

6 years agocmake: fix error message on non-Windows platform
Adam Simpkins [Fri, 12 Jan 2018 02:24:07 +0000 (18:24 -0800)]
cmake: fix error message on non-Windows platform

Summary:
Building folly with cmake is only supported on Windows for now.  This fixes
cmake on non-Windows platforms to fail with a helpful message telling people to
use autoconf.  This message was in place before, but was after an MSVC version
check preventing it from appearing.

Reviewed By: meyering

Differential Revision: D6707328

fbshipit-source-id: a28a07ab0da41d605b11d93bba40f33520c5f57e

6 years agoMemoryIdler::futexWaitUntil
Yedidya Feldblum [Thu, 11 Jan 2018 21:26:45 +0000 (13:26 -0800)]
MemoryIdler::futexWaitUntil

Summary:
[Folly] `MemoryIdler::futexWaitUntil`.

Adds `MemoryIdler::futexWaitUntil` that works like `Futex::futexWaitUntil`, in a similar way that `MemoryIdler::futexWait` works like `Futex::futexWait`.

Removes the ability to customize the idle-timeout clock for `MemoryIdler::futexWait` as a side-effect; the idle-timeout is now a pure duration. Now, the clock used with the idle-timeout is the same as the normal deadline clock, so the idle-timeout clock can be set for `MemoryIdler::futexWaitUntil` by providing a deadline with that clock type. This normally would not matter, but it affects the unit-tests.

Reviewed By: djwatson

Differential Revision: D6681679

fbshipit-source-id: e3cf6e71d7530c5877a834b318b423eb91f71eb9

6 years agoRelax stop_ memory order
Dave Watson [Thu, 11 Jan 2018 16:00:19 +0000 (08:00 -0800)]
Relax stop_ memory order

Summary: stop_ can be relaxed everywhere, it implies only an asynchronous signal, not any sort of memory barrier.

Reviewed By: davidtgoldblatt

Differential Revision: D6690079

fbshipit-source-id: 6f193204e1619f9a8adf81db2d46d05954bfbf85

6 years agoCut the ScopeGuard alias now that we have auto
Yedidya Feldblum [Thu, 11 Jan 2018 01:52:16 +0000 (17:52 -0800)]
Cut the ScopeGuard alias now that we have auto

Summary:
[Folly] Cut the `ScopeGuard` alias now that we have `auto`.

This form works because of hidden lifetime extension:
```lang=c++
folly::ScopeGuard guard = folly::makeGuard([] { /*...*/ });
//  ...
//  guard falls out of scope
```
But this form would not work correctly:
```lang=c++
folly::ScopeGuard guard = folly::makeGuard([] { /*...*/ });
std::async(std::launch::async, [guard = std::move(guard)] {});
```
Because `folly::ScopeGuard` is an rvalue-reference-to-base.
We have `auto`, so just remove `folly::ScopeGuard`. This form works correctly:
```lang=c++
auto guard = folly::makeGuard([] { /*...*/ });
std::async(std::launch::async, [guard = std::move(guard)] {});
```

Reviewed By: igorsugak

Differential Revision: D6690070

fbshipit-source-id: 54e32b300d36fce4eb95a59f1828819afe312ec0

6 years agoMove ScopeGuardImpl and ScopeGuardImplBase into the detail namespace
Yedidya Feldblum [Thu, 11 Jan 2018 01:52:13 +0000 (17:52 -0800)]
Move ScopeGuardImpl and ScopeGuardImplBase into the detail namespace

Summary:
[Folly] Move `ScopeGuardImpl` and `ScopeGuardImplBase` into the `detail` namespace.

Let them be marked as private implementation details.

Reviewed By: andrewjcg

Differential Revision: D6665317

fbshipit-source-id: 03e8fee6a16338395ec92c582613b053bd9f74ec

6 years agoStop using ScopeGuardImpl in DynamicParser
Yedidya Feldblum [Thu, 11 Jan 2018 01:52:11 +0000 (17:52 -0800)]
Stop using ScopeGuardImpl in DynamicParser

Summary:
[Folly] Stop using `ScopeGuardImpl` in `DynamicParser`.

`ScopeGuardImpl` is an impl type that should not be treated as public.

Reviewed By: igorsugak

Differential Revision: D6689835

fbshipit-source-id: aea6c985e40887594c0aeb0c0948fa77c149a89b

6 years agofolly::Init, RAII variant of folly::init
Yedidya Feldblum [Wed, 10 Jan 2018 21:44:14 +0000 (13:44 -0800)]
folly::Init, RAII variant of folly::init

Summary:
[Folly] `folly::Init`, RAII variant of `folly::init`.

Use it in `main` used by unit-tests.

Reviewed By: ot

Differential Revision: D6566358

fbshipit-source-id: fb8e5a18fc43eb65e2cbeb070d97094bd413bb96

6 years agoUnboundedQueue: Use hazptr_obj_batch
Maged Michael [Wed, 10 Jan 2018 20:43:40 +0000 (12:43 -0800)]
UnboundedQueue: Use hazptr_obj_batch

Summary: Manage retirement of removed segments using hazptr_obj_batch in order to reduce the chances of fragmenting related segments across thread local lists of retired objects of many threads, which could lead to unnecessarily high memory usage.

Reviewed By: djwatson

Differential Revision: D6686697

fbshipit-source-id: 0d786c0f9e0bac2c44183ed3da21619e1feb3d52

6 years agologging: fix build error when using gcc with -Wmissing-braces
Adam Simpkins [Wed, 10 Jan 2018 20:29:05 +0000 (12:29 -0800)]
logging: fix build error when using gcc with -Wmissing-braces

Summary:
Since std::array is actually a struct containing an array it technically
requires double braces around its initializer.  The language allows eliding
these braces, and clang doesn't complain about only using a single brace, but
gcc does when using `-Wmissing-braces`.

Reviewed By: yfeldblum

Differential Revision: D6695289

fbshipit-source-id: 913fcfbea4164a02d001bd2344e340c0b6ee62aa

6 years agoLet Futex import base-class ctors
Yedidya Feldblum [Wed, 10 Jan 2018 20:05:34 +0000 (12:05 -0800)]
Let Futex import base-class ctors

Summary:
[Folly] Let `Futex` import base-class ctors.

Rather than needing to define ctors and inherit `boost::noncopyable`.

Reviewed By: WillerZ

Differential Revision: D6674054

fbshipit-source-id: 59e0a4815682b227346954fe47c6eda49e3ad62f

6 years agoAdd hazptr_obj_batch
Maged Michael [Wed, 10 Jan 2018 16:40:46 +0000 (08:40 -0800)]
Add hazptr_obj_batch

Summary: Provide capability for custom batching retirement of objects, for example object that belong to the same data structure, to avoid the risk fragmenting related objects across thread local lists of retired objects of many threads, which could lead to unnecessarily high memory usage.

Reviewed By: djwatson

Differential Revision: D6686603

fbshipit-source-id: fadcade73e71170ef1bcec221c4da6f4ddeecff5

6 years agoTweak FutexResult comments
Yedidya Feldblum [Wed, 10 Jan 2018 06:39:16 +0000 (22:39 -0800)]
Tweak FutexResult comments

Summary: [Folly] Tweak `FutexResult` comments.

Reviewed By: nbronson

Differential Revision: D6673979

fbshipit-source-id: 1777311cd93d5a83432c4ebb48a8432a1c504ca9

6 years agoFutex::futexWait returns FutexResult
Yedidya Feldblum [Wed, 10 Jan 2018 06:39:13 +0000 (22:39 -0800)]
Futex::futexWait returns FutexResult

Summary: [Folly] `Futex::futexWait` returns `FutexResult`.

Reviewed By: nbronson

Differential Revision: D6673871

fbshipit-source-id: 378c69d8362970e985da31e31d8e9b0179d2917f

6 years agoSupport for all clock types in Futex
Yedidya Feldblum [Wed, 10 Jan 2018 06:39:11 +0000 (22:39 -0800)]
Support for all clock types in Futex

Summary:
[Folly] Support for all clock types in `Futex`.

Only `system_clock` and `steady_clock` remain optimal as before, but at least let `Futex` work, even if non-optimally, for all clock types.

Reviewed By: nbronson

Differential Revision: D6673741

fbshipit-source-id: 0a0f778f61b71bea76e12b7fab478e33ce3bbaae

6 years agoUse ptr-to-const in Futex
Yedidya Feldblum [Wed, 10 Jan 2018 06:39:10 +0000 (22:39 -0800)]
Use ptr-to-const in Futex

Summary: [Folly] Use ptr-to-`const` in `Futex`.

Reviewed By: igorsugak

Differential Revision: D6673723

fbshipit-source-id: b828c2284b40ec8166e823eca7725beccd330f87

6 years agoFix some copyright lines in folly/detail/ and folly/test/
Yedidya Feldblum [Wed, 10 Jan 2018 06:39:08 +0000 (22:39 -0800)]
Fix some copyright lines in folly/detail/ and folly/test/

Summary: [Folly] Fix some copyright lines in `folly/detail/` and `folly/test/`.

Differential Revision: D6673878

fbshipit-source-id: 6c060a974bb4d40d0f24a44ebddddf892805c65e

6 years agoBaton support for wait-options
Yedidya Feldblum [Wed, 10 Jan 2018 04:11:18 +0000 (20:11 -0800)]
Baton support for wait-options

Summary: [Folly] Baton support for wait-options

Reviewed By: nbronson

Differential Revision: D6591168

fbshipit-source-id: beca8422ac0daa572fb43c371923a86f199999f9

6 years agoTimed wait operations for spin-only Baton
Yedidya Feldblum [Wed, 10 Jan 2018 04:11:16 +0000 (20:11 -0800)]
Timed wait operations for spin-only Baton

Summary:
[Folly] Timed wait operations for spin-only `Baton`.

Enables `try_wait_for` and `try_wait_until` for `Baton</* MayBlock = */ false, /*...*/>`.

Reviewed By: nbronson

Differential Revision: D6672153

fbshipit-source-id: 95da07260b21c2b88b8f7bf81cbfcbe5f5099ac0

6 years agologging: include file name suffixes in XLOG() category names
Adam Simpkins [Wed, 10 Jan 2018 04:08:38 +0000 (20:08 -0800)]
logging: include file name suffixes in XLOG() category names

Summary:
Update `getXlogCategoryNameForFile()` to keep the file name suffix (e.g., `.h`
or `.cpp`) in the category name.  Previously the code had stripped this out.
However it seems worth leaving it in:
- This makes it possible to independently control log levels for messages from
  the header file vs the cpp file.
- This makes the category name logic slightly easier to explain to users.

The documents I added in D6525997 already describe this new category name
selection behavior.  This change updates the code to match the documented
behavior.

Reviewed By: yfeldblum

Differential Revision: D6690464

fbshipit-source-id: 9af6b549d084bd900f788a08e9213e82579b664a

6 years agologging: add numbered INFO* log level values
Adam Simpkins [Wed, 10 Jan 2018 04:08:37 +0000 (20:08 -0800)]
logging: add numbered INFO* log level values

Summary:
Define INFO0 through INFO9 levels for users that want to have finer-grained
control over info log messages.

This also renumbers the DBG log levels slightly so that there are exactly 1000
levels between each major log level step.  This renumbering change should not
affect any code behavior, since these level values are primarily used in memory
and aren't saved persistently anywhere.

Reviewed By: yfeldblum

Differential Revision: D6690466

fbshipit-source-id: acd499cff6830a1d1b579f295bd4b2bac93b5ada

6 years agologging: rename the `DEBUG` log level to `DBG`
Adam Simpkins [Wed, 10 Jan 2018 04:08:35 +0000 (20:08 -0800)]
logging: rename the `DEBUG` log level to `DBG`

Summary:
I ran into some open source projects that define `DEBUG` as a preprocessor
macro on the compiler command line.  (They effectively defined it as the
opposite of `NDEBUG`.)  Doing some Google searches revealed that there are a
number of projects that appear to use this as a macro.

Therefore this diff renames the `DEBUG` log level enum value to `DBG` to avoid
potentially conflicting with projects that do use `DEBUG` as a macro name.

I did keep the behavior that `logLevelToString()` returns "DEBUG" for an input
of `LogLevel::DBG`.

Reviewed By: yfeldblum

Differential Revision: D6690465

fbshipit-source-id: 35bb1698afb45eb670e60c192f21390cbf09331d

6 years agoChange the enumerate() example to bind the proxy by reference
Giuseppe Ottaviano [Wed, 10 Jan 2018 02:44:44 +0000 (18:44 -0800)]
Change the enumerate() example to bind the proxy by reference

Summary:
When compiling without optimizations binding the proxy by
reference is slightly faster (no differences in opt mode), so change
the documentation to recommend this syntax.

The proxy can still be bound by `auto`, `const auto`, and `const
auto&`, in all case behaving as expected and with no overhead in opt
mode. Added a test to make sure these all work.

Reviewed By: yfeldblum, luciang

Differential Revision: D6688958

fbshipit-source-id: 7c6b460a01708786bda7614546fa2e1667f27299

6 years agoImprove performance of enumerate() with optimization disabled
Giuseppe Ottaviano [Wed, 10 Jan 2018 02:44:43 +0000 (18:44 -0800)]
Improve performance of enumerate() with optimization disabled

Reviewed By: yfeldblum, WillerZ

Differential Revision: D6682606

fbshipit-source-id: 5a203a849e96d3020cf9ad2669451122954c2199

6 years agoFixing typo in sorted_vector_types.h
Adriana Libório [Wed, 10 Jan 2018 00:13:22 +0000 (16:13 -0800)]
Fixing typo in sorted_vector_types.h

Summary:
title

Created from Diffusion's 'Open in Editor' feature.

(Note: this ignores all push blocking failures!)

Reviewed By: Sushisugre

Differential Revision: D6688367

fbshipit-source-id: 6e2f2d3fcb897fe78c1caef841515856b1f2bd42

6 years agoReturn if we handle any error messages to avoid unnecessarily calling recv/send
Dan Melnic [Tue, 9 Jan 2018 19:36:55 +0000 (11:36 -0800)]
Return if we handle any error messages to avoid unnecessarily calling recv/send

Summary: Return if we handle any error messages to avoid unnecessarily calling recv/send

Reviewed By: yfeldblum

Differential Revision: D6677314

fbshipit-source-id: 21f724bb2c92b954888ba97bf7820d72decd2775

6 years agouse in futex
Dave Watson [Tue, 9 Jan 2018 15:32:57 +0000 (07:32 -0800)]
use in futex

Summary: Use new ParkingLot API in futex.

Reviewed By: yfeldblum

Differential Revision: D6595853

fbshipit-source-id: 7024ac1d3e0c5958a651a3e33c1427038bbe7808

6 years agoAdd a check if max atomic_shared_ptrs is reached.
Dave Watson [Tue, 9 Jan 2018 15:30:49 +0000 (07:30 -0800)]
Add a check if max atomic_shared_ptrs is reached.

Summary:
Batching reference counts reduces the maximum number of atomic_shared_ptrs
available to the system (and also shared_ptrs).

Add a check, test, and some comments about it.

Reviewed By: yfeldblum

Differential Revision: D5916291

fbshipit-source-id: 0bbf7b43284d94a304201219883c82b3654c1585

6 years agoUnboundedBlockingQueue: Adjust segment size
Maged Michael [Tue, 9 Jan 2018 00:29:24 +0000 (16:29 -0800)]
UnboundedBlockingQueue: Adjust segment size

Summary: Adjust the segment size of the `UnboundedQueue` to 64 instead of 256, a size more suitable for CPUThreadPoolExecutor::CPUTask elements.

Reviewed By: djwatson

Differential Revision: D6665918

fbshipit-source-id: c34c4fa936ee5c6d6a3dd4489129c936369f3980

6 years agogive all folly exception types default visibility
Eric Niebler [Mon, 8 Jan 2018 23:21:57 +0000 (15:21 -0800)]
give all folly exception types default visibility

Summary: This makes sure that whether folly is statically or dynamically linked, all folly exception types will have exactly one definition, and one set of type information.

Reviewed By: mzlee

Differential Revision: D6671431

fbshipit-source-id: 1c06826a05f87cbf9af747c9abdb5f524744d054

6 years agoUpdate cpuid test to expect failure on non intel cpu
Keith Daigle [Mon, 8 Jan 2018 19:31:12 +0000 (11:31 -0800)]
Update cpuid test to expect failure on non intel cpu

Summary: Found that testing would fail on aarch64 since mmx is an Intel thing.  Changed it to just check for x64.

Reviewed By: yfeldblum

Differential Revision: D6670050

fbshipit-source-id: 6ce4b45bb5ef02d65305636d6ac28be7631ddf1b

6 years agotest that _sp includes nul bytes
Chad Austin [Mon, 8 Jan 2018 19:12:18 +0000 (11:12 -0800)]
test that _sp includes nul bytes

Summary:
D6617812 wants to build a StringPiece from a literal with an
embedded nul. Add a test to verify that _sp is suitable for this use
case.

Reviewed By: yfeldblum

Differential Revision: D6651024

fbshipit-source-id: be4fb875762829fdb61c57fa72954fef286e9df0

6 years agoUse local error buffer in readStoreFromBuffer
Neel Goyal [Mon, 8 Jan 2018 16:49:37 +0000 (08:49 -0800)]
Use local error buffer in readStoreFromBuffer

Summary: ERR_error_string will use a static buffer if none is provided.  This is unsafe in threaded envs when we build a string out of it later.  Switch this to use ERR_error_string_n

Reviewed By: yfeldblum, knekritz

Differential Revision: D6664958

fbshipit-source-id: 2071347373ac61ebc28296fa66845cd718172b5e

6 years agoRemove gcc-v4.7 support from MemoryIdler v2018.01.08.00
Yedidya Feldblum [Mon, 8 Jan 2018 05:40:55 +0000 (21:40 -0800)]
Remove gcc-v4.7 support from MemoryIdler

Summary:
[Folly] Remove gcc-v4.7 support from `MemoryIdler`.

As of gcc-v4.8, `std::is_trivial<std::chrono::duration<Rep, Period>>::value` holds. We no longer need any extra support.

Reviewed By: meyering

Differential Revision: D6673517

fbshipit-source-id: f28b2d126f113547ebf36c85f9fa37a5d944d65b

6 years agoTerminal comma for FutexResult enumerators
Yedidya Feldblum [Sun, 7 Jan 2018 22:19:17 +0000 (14:19 -0800)]
Terminal comma for FutexResult enumerators

Summary: [Folly] Terminal comma for `FutexResult` enumerators. Style nit.

Reviewed By: meyering

Differential Revision: D6673523

fbshipit-source-id: abf9f4d3e99bf9a6d3042a49252b1b1190e69b9f

6 years agoUse auto for scope-guard locals v.s. folly::ScopeGuard
Yedidya Feldblum [Sat, 6 Jan 2018 06:45:21 +0000 (22:45 -0800)]
Use auto for scope-guard locals v.s. folly::ScopeGuard

Summary: Use `auto` for scope-guard locals v.s. `folly::ScopeGuard`.

Reviewed By: igorsugak, meyering

Differential Revision: D6664915

fbshipit-source-id: ea239b712f3f9dc7ef81105aaf82f4b36bc07db5

6 years agogive EventBase a non-explicit default constructor
Eric Niebler [Sat, 6 Jan 2018 01:31:41 +0000 (17:31 -0800)]
give EventBase a non-explicit default constructor

Summary: Default constructors are strange and often unexpected. Refactor.

Reviewed By: yfeldblum

Differential Revision: D6667480

fbshipit-source-id: 24c456c46c846c61e28f1a88806d7c36d9192493

6 years agoAdd threshold for thread local retired objects
Maged Michael [Sat, 6 Jan 2018 00:10:46 +0000 (16:10 -0800)]
Add threshold for thread local retired objects

Summary: Change the threshold for pushing privately held retired object to the domain to a moderate constant instead of using the threshold for bulk reclamation which is too high for this purpose.

Reviewed By: djwatson

Differential Revision: D6665904

fbshipit-source-id: 0b090884843b0296a93af7994f7183f41c00000e

6 years agoSynchronized::exchange
Yedidya Feldblum [Fri, 5 Jan 2018 22:23:31 +0000 (14:23 -0800)]
Synchronized::exchange

Summary:
[Folly] `Synchronized::exchange`, for assigning a new value and returning the old value.

(Note: this ignores all push blocking failures!)

Differential Revision: D6653482

fbshipit-source-id: 68f4bd330bc2cf37bb92aff98b8ce3221334112e

6 years agoFix copyright lines in folly/synchronization/Baton.h
Yedidya Feldblum [Fri, 5 Jan 2018 21:29:57 +0000 (13:29 -0800)]
Fix copyright lines in folly/synchronization/Baton.h

Summary: [Folly] Fix copyright lines in `folly/synchronization/Baton.h`.

Reviewed By: meyering

Differential Revision: D6665595

fbshipit-source-id: 84aa0c475f01c858d543a047103437c083b3a4ed

6 years agoClarify folly::ssl::init documentation
Mingtao Yang [Fri, 5 Jan 2018 20:54:46 +0000 (12:54 -0800)]
Clarify folly::ssl::init documentation

Summary: Adds wording indicating that it is safe to call this function multiple times.

Reviewed By: yfeldblum

Differential Revision: D6625530

fbshipit-source-id: 2305f7b8e3451a6663003d23230b22c6f65a3729

6 years agoCut glog include from folly/synchronization/RWSpinLock.h
Yedidya Feldblum [Fri, 5 Jan 2018 07:08:09 +0000 (23:08 -0800)]
Cut glog include from folly/synchronization/RWSpinLock.h

Summary: [Folly] Cut `glog` include from `folly/synchronization/RWSpinLock.h`.

Reviewed By: meyering

Differential Revision: D6659300

fbshipit-source-id: 0f1b79d98be0656694f57667252a16acd54e2414

6 years agoMove folly/RWSpinLock.h to folly/synchronization/
Yedidya Feldblum [Fri, 5 Jan 2018 07:08:03 +0000 (23:08 -0800)]
Move folly/RWSpinLock.h to folly/synchronization/

Summary: [Folly] Move `folly/RWSpinLock.h` to `folly/synchronization/`.

Reviewed By: elsteveogrande

Differential Revision: D6659265

fbshipit-source-id: 307723e22f42ceb104f26657aed8b34f7e183afb

6 years agoExtract WaitOptions
Yedidya Feldblum [Fri, 5 Jan 2018 07:02:09 +0000 (23:02 -0800)]
Extract WaitOptions

Summary:
[Folly] Extract `WaitOptions` from `SaturatingSemaphore`.

This type may prove useful in the future for a variety of similar cases, and so does not need to be locked up inside `SaturatingSemaphore`.

Additionally:
* Extract and redraft a comment from `Baton`.
* Rename `pre_block` to `spin_max`.

Reviewed By: djwatson, aary

Differential Revision: D6632875

fbshipit-source-id: 6b7faeeb6e1ac2011a037c2b560def0ee2e9f3d4

6 years agoMove folly/BitIterator.h to folly/container/
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

6 years agoMove InPlaceConstruction test in folly/test/SynchronizedTest.cpp
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

6 years agoFix copyright lines for folly/Synchronized.h
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

6 years agoAdd utility to create stores
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

6 years agoMake FOLLY_HAS_COROUTINES dependent on header
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

6 years agoAvoid allocs in dtors in futures collect
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

6 years agoFix to build SharedMutexTest on aarch64
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

6 years agoMake consistent set of get and getTry methods on SemiFuture.
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

6 years agoRemove SingletonVault C bindings
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

6 years agoUse member-invoke traits in LockTraits
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

6 years agoinvoke and member-invoke tweaks
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

6 years agoAdd ColdClassTest.cpp to oss builds
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

6 years agoFix copyright lines for Bits.h and move BitsBenchmark.cpp
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

6 years agoFix some copyright lines in folly/
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

6 years agoFix some copyright lines in folly/lang/
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

6 years agoFix some copyright lines in folly/experimental/symbolizer/
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

6 years agoconstexpr_pow v2018.01.01.00
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

6 years agoGive detail functions in ConstexprMath.h decorated names
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

6 years agoShift monotonic_coarse_clock into Chrono.h and rename it to coarse_steady_clock
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

6 years agoInclude synchronization/SaturatingSemaphore.h in the makefile
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

6 years agoTweaks to folly::call_once and folly::once_flag
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

6 years agoAdded remove_cvref
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

6 years agofolly::Indestructible interface improvement
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

6 years agosynchronization/ParkingLot
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

6 years agoAdd getVia and getTryVia to SemiFuture.
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

6 years agoMove getTry to subclasses.
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

6 years agoAdd continuation to semifuture return test.
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

6 years agoAdd deprecation comments to folly::makeFuture.
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

6 years agoAdd getSemiFuture to folly::SharedPromise
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

6 years agoNamespacing and comments in folly/Likely.h
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

6 years agoTweaks to AtomicStruct
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

6 years agoEnsure that returning a semifuture from a continuation works correctly.
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

6 years agoRemove folly/detail/UncaughtExceptionCounter.h
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

6 years agoconstexpr_log2_ceil
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

6 years agoMove folly/detail/Sleeper.h to folly/synchronization/detail/
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

6 years agoFix link to window tests in folly/future/README.md
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

6 years agoFormat digits10
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

6 years agoMove folly/AtomicStruct.h to folly/synchronization/
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

6 years agoRemove unused boost dep from Conv.h
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

6 years agoUpdate homebrew script to use gtest 1.8.0 v2017.12.25.00
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

6 years agoMove expensive Singleton code to .cpp
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

6 years agoAdd getSemiFuture to folly::Promise
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

6 years agoNamespace portability symbols better in Singleton.cpp
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

6 years agoFix the assumption in the propagate_const test about local layout
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

6 years agoReturning reference to *this from propagate_const
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

6 years agoFix crashing on corrupted ELF binaries with invalid offsets in ELF header.
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

6 years agotest that the value remains alive even if the .then callback takes no arguments
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

6 years agoKill FOLLY_ALIGNED etc
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

6 years agoFix Build: propagate_const under GCC
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

6 years agoAdd readWithPriority to PriorityMPMCQueue
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

6 years agoAdd hardware_destructive_interference_size
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

6 years agopropagate_const
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

6 years agoFix erase in Iterate (2)
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

6 years agoFix ThreadLocal races
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

6 years agoSwitch the Baton template params
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

6 years agoSecure RNG utilities
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