Summary:
In
D3241498 addTaskFuture was fixed to work with function returning void. This however changed addTaskFinally API to not allow finally functor which accepts Try<void>.
folly::fibers generally supports Try<void> so there's no reason to force users to use folly::Unit instead of void for addTaskFinally too.
Reviewed By: yfeldblum
Differential Revision:
D3243893
fb-gh-sync-id:
d1df54738157d2019120103956f59b3971ba25ff
fbshipit-source-id:
d1df54738157d2019120103956f59b3971ba25ff
template <typename F>
auto FiberManager::addTaskFuture(F&& func) -> folly::Future<
typename folly::Unit::Lift<typename std::result_of<F()>::type>::type> {
template <typename F>
auto FiberManager::addTaskFuture(F&& func) -> folly::Future<
typename folly::Unit::Lift<typename std::result_of<F()>::type>::type> {
- using T =
- typename folly::Unit::Lift<typename std::result_of<F()>::type>::type;
- folly::Promise<T> p;
+ using T = typename std::result_of<F()>::type;
+ using FutureT = typename folly::Unit::Lift<T>::type;
+
+ folly::Promise<FutureT> p;
auto f = p.getFuture();
addTaskFinally(
[func = std::forward<F>(func)]() mutable { return func(); },
auto f = p.getFuture();
addTaskFinally(
[func = std::forward<F>(func)]() mutable { return func(); },
template <typename F, typename G>
void FiberManager::addTaskFinally(F&& func, G&& finally) {
template <typename F, typename G>
void FiberManager::addTaskFinally(F&& func, G&& finally) {
- typedef typename folly::Unit::Lift<typename std::result_of<F()>::type>::type
- Result;
+ typedef typename std::result_of<F()>::type Result;
static_assert(
IsRvalueRefTry<typename FirstArgOf<G>::type>::value,
static_assert(
IsRvalueRefTry<typename FirstArgOf<G>::type>::value,
template <>
class Try<void> {
public:
template <>
class Try<void> {
public:
+ /*
+ * The value type for the Try
+ */
+ typedef void element_type;
+
// Construct a Try holding a successful and void result
Try() : hasValue_(true) {}
// Construct a Try holding a successful and void result
Try() : hasValue_(true) {}