Commit 812f803c authored by Hans Fugal's avatar Hans Fugal Committed by Sara Golemon

Future<Unit> global fixup

Summary: This is three codemods:

* `(folly::(Future|Promise|Try))<void>` -> `\1<folly::Unit>`
* `(Future|Promise|Try)<void>` -> `\1<Unit>`
* add `using folly::Unit` statements where needed

Then
* undo false positives in javascript files and fibers::Promise

cf D2201259, which this will land with

Reviewed By: @djwatson

Differential Revision: D2201801
parent 98a8a89d
......@@ -470,27 +470,15 @@ Future<Unit> makeFuture() {
return makeFuture(Unit{});
}
// XXX why is the dual necessary here? Can't we just use perfect forwarding
// and capture func by reference always?
template <class F>
auto makeFutureWith(
F&& func,
typename std::enable_if<!std::is_reference<F>::value, bool>::type sdf)
auto makeFutureWith(F&& func)
-> Future<typename Unit::Lift<decltype(func())>::type> {
using LiftedResult = typename Unit::Lift<decltype(func())>::type;
return makeFuture<LiftedResult>(makeTryWith([&func]() {
return (func)();
return makeFuture<LiftedResult>(makeTryWith([&func]() mutable {
return func();
}));
}
template <class F>
auto makeFutureWith(F const& func)
-> Future<typename Unit::Lift<decltype(func())>::type> {
F copy = func;
using LiftedResult = typename Unit::Lift<decltype(func())>::type;
return makeFuture<LiftedResult>(makeTryWith(std::move(copy)));
}
template <class T>
Future<T> makeFuture(std::exception_ptr const& e) {
return makeFuture(Try<T>(e));
......
......@@ -77,13 +77,7 @@ Future<Unit> makeFuture();
/** Make a completed Future by executing a function. If the function throws
we capture the exception, otherwise we capture the result. */
template <class F>
auto makeFutureWith(
F&& func,
typename std::enable_if<!std::is_reference<F>::value, bool>::type sdf)
-> Future<typename Unit::Lift<decltype(func())>::type>;
template <class F>
auto makeFutureWith(F const& func)
auto makeFutureWith(F&& func)
-> Future<typename Unit::Lift<decltype(func())>::type>;
/// Make a failed Future from an exception_ptr.
......
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