|
| 1 | +// include/beman/execution/detail/get_forward_progress_guarantee.hpp -*-C++-*- |
| 2 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | + |
| 4 | +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_GET_FORWARD_PROGRESS_GUARANTEE |
| 5 | +#define INCLUDED_BEMAN_EXECUTION_DETAIL_GET_FORWARD_PROGRESS_GUARANTEE |
| 6 | + |
| 7 | +#include <beman/execution/detail/common.hpp> |
| 8 | +#include <beman/execution/detail/suppress_push.hpp> |
| 9 | +#ifdef BEMAN_HAS_IMPORT_STD |
| 10 | +import std; |
| 11 | +#else |
| 12 | +#include <concepts> |
| 13 | +#endif |
| 14 | +#ifdef BEMAN_HAS_MODULES |
| 15 | +import beman.execution.detail.forwarding_query; |
| 16 | +#else |
| 17 | +#include <beman/execution/detail/forwarding_query.hpp> |
| 18 | +#endif |
| 19 | + |
| 20 | +// ---------------------------------------------------------------------------- |
| 21 | + |
| 22 | +namespace beman::execution { |
| 23 | + |
| 24 | +enum class forward_progress_guarantee { concurrent, parallel, weakly_parallel }; |
| 25 | + |
| 26 | +struct get_forward_progress_guarantee_t { |
| 27 | + template <typename Object> |
| 28 | + requires requires(const Object& object, const get_forward_progress_guarantee_t& tag) { object.query(tag); } |
| 29 | + auto operator()(const Object& object) const noexcept -> forward_progress_guarantee { |
| 30 | + static_assert(::std::same_as<decltype(object.query(*this)), forward_progress_guarantee>); |
| 31 | + return object.query(*this); |
| 32 | + } |
| 33 | + |
| 34 | + template <typename Object> |
| 35 | + auto operator()(const Object&) const noexcept -> forward_progress_guarantee { |
| 36 | + return forward_progress_guarantee::weakly_parallel; |
| 37 | + } |
| 38 | + |
| 39 | + static constexpr auto query(const ::beman::execution::forwarding_query_t&) noexcept -> bool { return true; } |
| 40 | +}; |
| 41 | + |
| 42 | +inline constexpr get_forward_progress_guarantee_t get_forward_progress_guarantee{}; |
| 43 | +} // namespace beman::execution |
| 44 | + |
| 45 | +// ---------------------------------------------------------------------------- |
| 46 | + |
| 47 | +#include <beman/execution/detail/suppress_pop.hpp> |
| 48 | + |
| 49 | +#endif // INCLUDED_BEMAN_EXECUTION_DETAIL_GET_FORWARD_PROGRESS_GUARANTEE |
0 commit comments