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