folly: specialise makeFutureWith for functions returning futures
Summary: makeFutureWith executes a function and returns a future containing set to the function's return value. This diff adds a specialisation for the case when the function returns some type Future<T>. Instead of returning Future<Future<T>>, makeFutureWith now just passes on the future that the function returned, which may or may not have a value set at this time. In case the function throws, makeFutureWith returns a Future<T> containing the exception. With this diff, the following two lines produce equivalent results: auto f1 = makeFutureWith(func); auto f2 = makeFuture().then(func); except for the fact that f2 requires an additional temporary Future<Unit> to be created and destroyed. Reviewed By: @fugalh Differential Revision: D2388335
Showing
Please register or sign in to comment