From ebc7dd0de112dba0d72d297400b031708ba8f970 Mon Sep 17 00:00:00 2001 From: Andrii Grynenko Date: Fri, 29 Apr 2016 17:50:50 -0700 Subject: [PATCH] Don't require folly::Unit in addTaskFinally 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. folly::fibers generally supports Try 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 --- folly/experimental/fibers/FiberManager-inl.h | 10 +++++----- folly/futures/Try.h | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/folly/experimental/fibers/FiberManager-inl.h b/folly/experimental/fibers/FiberManager-inl.h index 8f31ede1..1e91a5a6 100644 --- a/folly/experimental/fibers/FiberManager-inl.h +++ b/folly/experimental/fibers/FiberManager-inl.h @@ -283,9 +283,10 @@ void FiberManager::addTask(F&& func) { template auto FiberManager::addTaskFuture(F&& func) -> folly::Future< typename folly::Unit::Lift::type>::type> { - using T = - typename folly::Unit::Lift::type>::type; - folly::Promise p; + using T = typename std::result_of::type; + using FutureT = typename folly::Unit::Lift::type; + + folly::Promise p; auto f = p.getFuture(); addTaskFinally( [func = std::forward(func)]() mutable { return func(); }, @@ -398,8 +399,7 @@ struct FiberManager::AddTaskFinallyHelper { template void FiberManager::addTaskFinally(F&& func, G&& finally) { - typedef typename folly::Unit::Lift::type>::type - Result; + typedef typename std::result_of::type Result; static_assert( IsRvalueRefTry::type>::value, diff --git a/folly/futures/Try.h b/folly/futures/Try.h index b4152dd4..5fae57f5 100644 --- a/folly/futures/Try.h +++ b/folly/futures/Try.h @@ -244,6 +244,11 @@ class Try { template <> class Try { public: + /* + * The value type for the Try + */ + typedef void element_type; + // Construct a Try holding a successful and void result Try() : hasValue_(true) {} -- 2.34.1