Commit 28efb04f authored by Eric Niebler's avatar Eric Niebler Committed by Facebook Github Bot

Use FOLLY_HAS_COROUTINES portability macro where appropriate

Summary: Prefer `FOLLY_HAS_COROUTINES` from `<folly/Portability.h>` over directly testing `__cpp_coroutines` because of MSVC.

Reviewed By: yfeldblum

Differential Revision: D14816497

fbshipit-source-id: 1f569824d5a79beca5255dfd43da8baf1556f8fe
parent be0f84c4
...@@ -18,10 +18,12 @@ ...@@ -18,10 +18,12 @@
#include <utility> #include <utility>
#include <type_traits> #include <type_traits>
#include <folly/Portability.h>
#include <folly/Traits.h> #include <folly/Traits.h>
#if defined(__cpp_coroutines) #if FOLLY_HAS_COROUTINES
#include <folly/experimental/coro/Traits.h> #include <folly/experimental/coro/Traits.h>
#endif #endif
#include <folly/experimental/pushmi/detail/concept_def.h> #include <folly/experimental/pushmi/detail/concept_def.h>
#include <folly/experimental/pushmi/forwards.h> #include <folly/experimental/pushmi/forwards.h>
#include <folly/experimental/pushmi/sender/detail/concepts.h> #include <folly/experimental/pushmi/sender/detail/concepts.h>
...@@ -30,7 +32,7 @@ ...@@ -30,7 +32,7 @@
namespace folly { namespace folly {
namespace pushmi { namespace pushmi {
#if defined(__cpp_coroutines) #if FOLLY_HAS_COROUTINES
namespace detail { namespace detail {
...@@ -103,12 +105,12 @@ PUSHMI_CONCEPT_DEF( ...@@ -103,12 +105,12 @@ PUSHMI_CONCEPT_DEF(
Awaitable<Tp> && ConvertibleTo<coro::await_result_t<Tp>, Result> Awaitable<Tp> && ConvertibleTo<coro::await_result_t<Tp>, Result>
); );
#else // if defined(__cpp_coroutines) #else // if FOLLY_HAS_COROUTINES
namespace detail { namespace detail {
template <class> template <class>
using awaitable_sender_traits = awaitable_senders::sender_adl_hook; using awaitable_sender_traits = awaitable_senders::sender_adl_hook;
} // namespace detail } // namespace detail
#endif // if defined(__cpp_coroutines) #endif // if FOLLY_HAS_COROUTINES
namespace detail { namespace detail {
template<class S> template<class S>
......
...@@ -18,15 +18,11 @@ ...@@ -18,15 +18,11 @@
#include <cassert> #include <cassert>
#include <exception> #include <exception>
#if defined(__cpp_coroutines)
#include <experimental/coroutine>
#endif
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#if defined(__cpp_coroutines) #include <folly/Portability.h>
#include <folly/experimental/coro/detail/ManualLifetime.h>
#endif
#include <folly/experimental/pushmi/awaitable/concepts.h> #include <folly/experimental/pushmi/awaitable/concepts.h>
#include <folly/experimental/pushmi/sender/detail/concepts.h> #include <folly/experimental/pushmi/sender/detail/concepts.h>
#include <folly/experimental/pushmi/sender/primitives.h> #include <folly/experimental/pushmi/sender/primitives.h>
...@@ -34,6 +30,11 @@ ...@@ -34,6 +30,11 @@
#include <folly/experimental/pushmi/traits.h> #include <folly/experimental/pushmi/traits.h>
#include <folly/experimental/pushmi/receiver/tags.h> #include <folly/experimental/pushmi/receiver/tags.h>
#if FOLLY_HAS_COROUTINES
#include <experimental/coroutine>
#include <folly/experimental/coro/detail/ManualLifetime.h>
#endif
namespace folly { namespace folly {
namespace pushmi { namespace pushmi {
...@@ -43,7 +44,7 @@ struct operation_cancelled : std::exception { ...@@ -43,7 +44,7 @@ struct operation_cancelled : std::exception {
} }
}; };
#if defined(__cpp_coroutines) #if FOLLY_HAS_COROUTINES
PUSHMI_TEMPLATE(class From)( // PUSHMI_TEMPLATE(class From)( //
requires SingleTypedSender<From> // requires SingleTypedSender<From> //
...@@ -186,7 +187,7 @@ namespace awaitable_senders { ...@@ -186,7 +187,7 @@ namespace awaitable_senders {
} }
} // namespace awaitable_senders } // namespace awaitable_senders
#endif #endif // FOLLY_HAS_COROUTINES
} // namespace pushmi } // namespace pushmi
} // namespace folly } // namespace folly
...@@ -58,7 +58,7 @@ namespace _submit_adl { ...@@ -58,7 +58,7 @@ namespace _submit_adl {
) )
); );
#if defined(__cpp_coroutines) #if FOLLY_HAS_COROUTINES
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template (class A, class R) template (class A, class R)
concept IsSubmittableAwaitable_, concept IsSubmittableAwaitable_,
...@@ -71,7 +71,7 @@ namespace _submit_adl { ...@@ -71,7 +71,7 @@ namespace _submit_adl {
struct _fn struct _fn
{ {
private: private:
#if defined(__cpp_coroutines) #if FOLLY_HAS_COROUTINES
template<class A, class R> template<class A, class R>
static void _submit_awaitable_(A awaitable, R to) noexcept; static void _submit_awaitable_(A awaitable, R to) noexcept;
#endif #endif
...@@ -91,7 +91,7 @@ namespace _submit_adl { ...@@ -91,7 +91,7 @@ namespace _submit_adl {
submit(id((S&&) from), (R&&) to); submit(id((S&&) from), (R&&) to);
return std::true_type{}; return std::true_type{};
) else ( ) else (
#if defined(__cpp_coroutines) #if FOLLY_HAS_COROUTINES
// Otherwise, if we support coroutines and S looks like an // Otherwise, if we support coroutines and S looks like an
// awaitable, dispatch to the // awaitable, dispatch to the
PUSHMI_IF_CONSTEXPR_RETURN((IsSubmittableAwaitable_<S, R>) ( PUSHMI_IF_CONSTEXPR_RETURN((IsSubmittableAwaitable_<S, R>) (
...@@ -116,7 +116,7 @@ namespace _submit_adl { ...@@ -116,7 +116,7 @@ namespace _submit_adl {
} }
}; };
#if defined(__cpp_coroutines) #if FOLLY_HAS_COROUTINES
struct FOLLY_MAYBE_UNUSED oneway_task struct FOLLY_MAYBE_UNUSED oneway_task
{ {
struct promise_type struct promise_type
...@@ -130,7 +130,7 @@ namespace _submit_adl { ...@@ -130,7 +130,7 @@ namespace _submit_adl {
}; };
#endif #endif
#if defined(__cpp_coroutines) #if FOLLY_HAS_COROUTINES
// Make all awaitables senders: // Make all awaitables senders:
template<class A, class R> template<class A, class R>
void _fn::_submit_awaitable_(A awaitable, R to) noexcept void _fn::_submit_awaitable_(A awaitable, R to) noexcept
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
#if defined(__cpp_coroutines) #include <folly/Portability.h>
#if FOLLY_HAS_COROUTINES
#include <folly/experimental/coro/BlockingWait.h> #include <folly/experimental/coro/BlockingWait.h>
#include <folly/experimental/coro/detail/InlineTask.h> #include <folly/experimental/coro/detail/InlineTask.h>
......
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