Commit 773131b9 authored by Marshall Cline's avatar Marshall Cline Committed by Facebook Github Bot

remove lvalue-qual Future::within(...)

Summary:
This is part of "the great r-valuification of folly::Future":
* This is something we should do for safety in general.
* Several of folly::Future's methods are lvalue-qualified even though they act as though they are rvalue-qualified, that is, they provide a postcondition that says, in effect, callers should act as though the method invalidated its `this` object (regardless of whether that invalidation was actual or logical).
* This violates the C++ principle to "Express ideas directly in code" (see Core Guidelines), and generally makes it more confusing for callers as well as hiding the actual semantics from tools (linters, compilers, etc.).
* This dichotomy and confusion has manifested itself by some failures around D7840699 since lvalue-qualification hides that operation's move-out semantics - leads to some use of future operations that are really not correct, but are not obviously incorrect.
* The goal of rvalueification is to make sure methods that are logically rvalue-qualified are actually rvalue-qualified, which forces callsites to acknowledge that rvalueification, e.g., `std::move(f).within(...)` instead of `f.within(...)`. This syntactic change in the callsites forces callers to acknowledge the method's rvalue semantics.

Reviewed By: LeeHowes

Differential Revision: D9442319

fbshipit-source-id: c751a5e295620bff22c8bdaed57d417bcc0973d1
parent 37d13ba2
...@@ -1538,10 +1538,6 @@ class Future : private futures::detail::FutureBase<T> { ...@@ -1538,10 +1538,6 @@ class Future : private futures::detail::FutureBase<T> {
/// - `RESULT.valid() == true` /// - `RESULT.valid() == true`
Future<T> within(Duration dur, Timekeeper* tk = nullptr) &&; Future<T> within(Duration dur, Timekeeper* tk = nullptr) &&;
Future<T> within(Duration dur, Timekeeper* tk = nullptr) & {
return std::move(*this).within(dur, tk);
}
/// Throw the given exception if this Future does not complete within the /// Throw the given exception if this Future does not complete within the
/// given duration from now. The optional Timekeeper is as with /// given duration from now. The optional Timekeeper is as with
/// futures::sleep(). /// futures::sleep().
...@@ -1558,11 +1554,6 @@ class Future : private futures::detail::FutureBase<T> { ...@@ -1558,11 +1554,6 @@ class Future : private futures::detail::FutureBase<T> {
template <class E> template <class E>
Future<T> within(Duration dur, E exception, Timekeeper* tk = nullptr) &&; Future<T> within(Duration dur, E exception, Timekeeper* tk = nullptr) &&;
template <class E>
Future<T> within(Duration dur, E exception, Timekeeper* tk = nullptr) & {
return std::move(*this).within(dur, exception, tk);
}
/// Delay the completion of this Future for at least this duration from /// Delay the completion of this Future for at least this duration from
/// now. The optional Timekeeper is as with futures::sleep(). /// now. The optional Timekeeper is as with futures::sleep().
/// ///
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment