mirror of
https://github.com/Naios/continuable.git
synced 2026-02-16 23:29:48 +08:00
Some renaming
This commit is contained in:
parent
f17cc4073c
commit
62ca39e59c
@ -578,13 +578,23 @@ public:
|
|||||||
return materializer::apply(std::move(*this));
|
return materializer::apply(std::move(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DOXYGEN
|
||||||
/// Returns true if the continuable_base will resolve its promise
|
/// Returns true if the continuable_base will resolve its promise
|
||||||
/// immediately on request.
|
/// immediately on request.
|
||||||
///
|
///
|
||||||
/// \since 4.0.0
|
/// \since 4.0.0
|
||||||
bool is_ready() const noexcept {
|
bool is_ready() const noexcept;
|
||||||
return false;
|
#endif
|
||||||
}
|
|
||||||
|
#ifdef DOXYGEN
|
||||||
|
/// Returns the result of this continuable immediatly.
|
||||||
|
///
|
||||||
|
/// \attention requires that this continuable resolves immediatly on
|
||||||
|
/// request which means that is_ready() holds.
|
||||||
|
///
|
||||||
|
/// \since 4.0.0
|
||||||
|
unspecified request() &&;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Predicate to check whether the cti::continuable_base is frozen or not.
|
/// Predicate to check whether the cti::continuable_base is frozen or not.
|
||||||
///
|
///
|
||||||
@ -732,6 +742,18 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*template <typename Continuable>
|
||||||
|
struct continuable_trait
|
||||||
|
#ifdef DOXYGEN
|
||||||
|
{
|
||||||
|
/// Deduces to a true_type if the continuable_base is a concrete type
|
||||||
|
/// which means all lazy expression templates were materialized and
|
||||||
|
/// the continuable can be queried for a direct result through is_ready.
|
||||||
|
using is_concrete = std::true_type;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
;*/
|
||||||
|
|
||||||
/// Creates a continuable_base from a promise/callback taking function.
|
/// Creates a continuable_base from a promise/callback taking function.
|
||||||
///
|
///
|
||||||
/// \tparam Args The types (signature hint) the given promise is resolved with.
|
/// \tparam Args The types (signature hint) the given promise is resolved with.
|
||||||
|
|||||||
@ -52,7 +52,7 @@ namespace experimental {
|
|||||||
template <typename Data, typename... Args, typename... FunctionArgs>
|
template <typename Data, typename... Args, typename... FunctionArgs>
|
||||||
struct coroutine_traits<
|
struct coroutine_traits<
|
||||||
cti::continuable_base<Data,
|
cti::continuable_base<Data,
|
||||||
cti::detail::hints::signature_hint_tag<Args...>>,
|
cti::detail::traits::identity<Args...>>,
|
||||||
FunctionArgs...> {
|
FunctionArgs...> {
|
||||||
|
|
||||||
using promise_type =
|
using promise_type =
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <continuable/continuable-primitives.hpp>
|
#include <continuable/continuable-primitives.hpp>
|
||||||
#include <continuable/detail/core/hints.hpp>
|
#include <continuable/detail/core/annotation.hpp>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
#include <continuable/detail/utility/util.hpp>
|
#include <continuable/detail/utility/util.hpp>
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class promise_base
|
|||||||
/// \cond false
|
/// \cond false
|
||||||
;
|
;
|
||||||
template <typename Data, typename... Args>
|
template <typename Data, typename... Args>
|
||||||
class promise_base<Data, detail::hints::signature_hint_tag<Args...>>
|
class promise_base<Data, detail::traits::identity<Args...>>
|
||||||
: detail::util::non_copyable
|
: detail::util::non_copyable
|
||||||
/// \endcond
|
/// \endcond
|
||||||
{ // clang-format on
|
{ // clang-format on
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
}
|
}
|
||||||
/// \cond false
|
/// \cond false
|
||||||
/// Constructor for constructing an empty promise
|
/// Constructor for constructing an empty promise
|
||||||
explicit promise_base(detail::types::promise_no_init_tag) {
|
explicit promise_base(detail::types::promise_no_init_arg_t) {
|
||||||
}
|
}
|
||||||
/// \endcond
|
/// \endcond
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@
|
|||||||
#include <continuable/continuable-primitives.hpp>
|
#include <continuable/continuable-primitives.hpp>
|
||||||
#include <continuable/continuable-base.hpp>
|
#include <continuable/continuable-base.hpp>
|
||||||
#include <continuable/continuable-promise-base.hpp>
|
#include <continuable/continuable-promise-base.hpp>
|
||||||
#include <continuable/detail/core/hints.hpp>
|
#include <continuable/detail/core/annotation.hpp>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
@ -67,12 +67,12 @@ class continuable_trait {
|
|||||||
public:
|
public:
|
||||||
/// The promise type which is used to resolve continuations
|
/// The promise type which is used to resolve continuations
|
||||||
using promise =
|
using promise =
|
||||||
promise_base<callback, detail::hints::signature_hint_tag<Args...>>;
|
promise_base<callback, detail::traits::identity<Args...>>;
|
||||||
|
|
||||||
/// The continuable type for the given parameters.
|
/// The continuable type for the given parameters.
|
||||||
using continuable =
|
using continuable =
|
||||||
continuable_base<ContinuationWrapper<sizeof(callback), void(promise)>,
|
continuable_base<ContinuationWrapper<sizeof(callback), void(promise)>,
|
||||||
detail::hints::signature_hint_tag<Args...>>;
|
detail::traits::identity<Args...>>;
|
||||||
};
|
};
|
||||||
/// \}
|
/// \}
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|||||||
@ -75,17 +75,17 @@ T&& unpack_lazy(container::flat_variant<T>&& value) {
|
|||||||
template <typename Continuable>
|
template <typename Continuable>
|
||||||
class continuable_box;
|
class continuable_box;
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
class continuable_box<continuable_base<Data, hints::signature_hint_tag<>>> {
|
class continuable_box<continuable_base<Data, traits::identity<>>> {
|
||||||
|
|
||||||
continuable_base<Data, hints::signature_hint_tag<>> continuable_;
|
continuable_base<Data, traits::identity<>> continuable_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit continuable_box(
|
explicit continuable_box(
|
||||||
continuable_base<Data, hints::signature_hint_tag<>>&& continuable)
|
continuable_base<Data, traits::identity<>>&& continuable)
|
||||||
: continuable_(std::move(continuable)) {
|
: continuable_(std::move(continuable)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
continuable_base<Data, hints::signature_hint_tag<>>&& fetch() {
|
continuable_base<Data, traits::identity<>>&& fetch() {
|
||||||
return std::move(continuable_);
|
return std::move(continuable_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,18 +98,18 @@ public:
|
|||||||
};
|
};
|
||||||
template <typename Data, typename First>
|
template <typename Data, typename First>
|
||||||
class continuable_box<
|
class continuable_box<
|
||||||
continuable_base<Data, hints::signature_hint_tag<First>>> {
|
continuable_base<Data, traits::identity<First>>> {
|
||||||
|
|
||||||
continuable_base<Data, hints::signature_hint_tag<First>> continuable_;
|
continuable_base<Data, traits::identity<First>> continuable_;
|
||||||
lazy_value_t<First> first_;
|
lazy_value_t<First> first_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit continuable_box(
|
explicit continuable_box(
|
||||||
continuable_base<Data, hints::signature_hint_tag<First>>&& continuable)
|
continuable_base<Data, traits::identity<First>>&& continuable)
|
||||||
: continuable_(std::move(continuable)) {
|
: continuable_(std::move(continuable)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
continuable_base<Data, hints::signature_hint_tag<First>>&& fetch() {
|
continuable_base<Data, traits::identity<First>>&& fetch() {
|
||||||
return std::move(continuable_);
|
return std::move(continuable_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,21 +123,21 @@ public:
|
|||||||
};
|
};
|
||||||
template <typename Data, typename First, typename Second, typename... Rest>
|
template <typename Data, typename First, typename Second, typename... Rest>
|
||||||
class continuable_box<
|
class continuable_box<
|
||||||
continuable_base<Data, hints::signature_hint_tag<First, Second, Rest...>>> {
|
continuable_base<Data, traits::identity<First, Second, Rest...>>> {
|
||||||
|
|
||||||
continuable_base<Data, hints::signature_hint_tag<First, Second, Rest...>>
|
continuable_base<Data, traits::identity<First, Second, Rest...>>
|
||||||
continuable_;
|
continuable_;
|
||||||
lazy_value_t<std::tuple<First, Second, Rest...>> args_;
|
lazy_value_t<std::tuple<First, Second, Rest...>> args_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit continuable_box(
|
explicit continuable_box(
|
||||||
continuable_base<Data,
|
continuable_base<Data,
|
||||||
hints::signature_hint_tag<First, Second, Rest...>>&&
|
traits::identity<First, Second, Rest...>>&&
|
||||||
continuable)
|
continuable)
|
||||||
: continuable_(std::move(continuable)) {
|
: continuable_(std::move(continuable)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
continuable_base<Data, hints::signature_hint_tag<First, Second, Rest...>>&&
|
continuable_base<Data, traits::identity<First, Second, Rest...>>&&
|
||||||
fetch() {
|
fetch() {
|
||||||
return std::move(continuable_);
|
return std::move(continuable_);
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ constexpr auto finalize_impl(traits::identity<std::tuple<Args...>>,
|
|||||||
|
|
||||||
struct hint_mapper {
|
struct hint_mapper {
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
constexpr auto operator()(T...) -> hints::signature_hint_tag<T...> {
|
constexpr auto operator()(T...) -> traits::identity<T...> {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
#include <continuable/detail/connection/connection-aggregated.hpp>
|
#include <continuable/detail/connection/connection-aggregated.hpp>
|
||||||
#include <continuable/detail/connection/connection.hpp>
|
#include <continuable/detail/connection/connection.hpp>
|
||||||
#include <continuable/detail/core/base.hpp>
|
#include <continuable/detail/core/base.hpp>
|
||||||
#include <continuable/detail/core/hints.hpp>
|
#include <continuable/detail/core/annotation.hpp>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
#include <continuable/detail/utility/traits.hpp>
|
#include <continuable/detail/utility/traits.hpp>
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
#include <continuable/continuable-promise-base.hpp>
|
#include <continuable/continuable-promise-base.hpp>
|
||||||
#include <continuable/continuable-traverse.hpp>
|
#include <continuable/continuable-traverse.hpp>
|
||||||
#include <continuable/detail/core/base.hpp>
|
#include <continuable/detail/core/base.hpp>
|
||||||
#include <continuable/detail/core/hints.hpp>
|
#include <continuable/detail/core/annotation.hpp>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
#include <continuable/detail/traversal/container-category.hpp>
|
#include <continuable/detail/traversal/container-category.hpp>
|
||||||
#include <continuable/detail/utility/traits.hpp>
|
#include <continuable/detail/utility/traits.hpp>
|
||||||
@ -95,7 +95,7 @@ struct result_deducer {
|
|||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static auto deduce_one(std::true_type, traits::identity<T> id) {
|
static auto deduce_one(std::true_type, traits::identity<T> id) {
|
||||||
return hints::hint_of(id);
|
return base::annotation_of(id);
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static auto deduce(traversal::container_category_tag<false, false>,
|
static auto deduce(traversal::container_category_tag<false, false>,
|
||||||
|
|||||||
@ -28,8 +28,8 @@
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef CONTINUABLE_DETAIL_HINTS_HPP_INCLUDED
|
#ifndef CONTINUABLE_DETAIL_ANNOTATION_HPP_INCLUDED
|
||||||
#define CONTINUABLE_DETAIL_HINTS_HPP_INCLUDED
|
#define CONTINUABLE_DETAIL_ANNOTATION_HPP_INCLUDED
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
@ -37,18 +37,18 @@
|
|||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
namespace hints {
|
template <typename Annotation>
|
||||||
/// Represents a present signature hint
|
struct annotation_trait;
|
||||||
|
|
||||||
|
/// Specialization for a present signature hint
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
using signature_hint_tag = traits::identity<Args...>;
|
struct annotation_trait<traits::identity<Args...>> {
|
||||||
|
using is_concrete_hint = std::true_type;
|
||||||
/// Returns the signature hint of the given continuable
|
using hint_t = traits::identity<Args...>;
|
||||||
template <typename Data, typename... Args>
|
using is_materialized = std::true_type;
|
||||||
constexpr signature_hint_tag<Args...>
|
};
|
||||||
hint_of(traits::identity<continuable_base<Data, signature_hint_tag<Args...>>>) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
namespace hints {
|
||||||
/// Extracts the signature we pass to the internal continuable
|
/// Extracts the signature we pass to the internal continuable
|
||||||
/// from an argument pack as specified by make_continuable.
|
/// from an argument pack as specified by make_continuable.
|
||||||
///
|
///
|
||||||
@ -67,4 +67,4 @@ constexpr auto extract(traits::identity<void> /*hint*/) {
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
#endif // CONTINUABLE_DETAIL_HINTS_HPP_INCLUDED
|
#endif // CONTINUABLE_DETAIL_ANNOTATION_HPP_INCLUDED
|
||||||
@ -36,7 +36,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <continuable/continuable-primitives.hpp>
|
#include <continuable/continuable-primitives.hpp>
|
||||||
#include <continuable/continuable-result.hpp>
|
#include <continuable/continuable-result.hpp>
|
||||||
#include <continuable/detail/core/hints.hpp>
|
#include <continuable/detail/core/annotation.hpp>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
#include <continuable/detail/features.hpp>
|
#include <continuable/detail/features.hpp>
|
||||||
#include <continuable/detail/utility/result-trait.hpp>
|
#include <continuable/detail/utility/result-trait.hpp>
|
||||||
@ -69,6 +69,39 @@ struct is_continuable : std::false_type {};
|
|||||||
template <typename Data, typename Annotation>
|
template <typename Data, typename Annotation>
|
||||||
struct is_continuable<continuable_base<Data, Annotation>> : std::true_type {};
|
struct is_continuable<continuable_base<Data, Annotation>> : std::true_type {};
|
||||||
|
|
||||||
|
/*template <typename... Args>
|
||||||
|
struct ready_continuable {
|
||||||
|
std::tuple<Args...> values_;
|
||||||
|
|
||||||
|
template <typename Callback>
|
||||||
|
void operator()(Callback&& callback) && {
|
||||||
|
traits::unpack(std::forward<Callback>(callback), std::move(values_));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator()(is_ready_arg_t) const noexcept {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::tuple<Args...> operator()(get_arg_t) && {
|
||||||
|
return std::move(values_);
|
||||||
|
}
|
||||||
|
};*/
|
||||||
|
|
||||||
|
/*template <typename Continuation, typename Args>
|
||||||
|
struct proxy_continuable : Continuation {
|
||||||
|
using Continuation::Continuation;
|
||||||
|
|
||||||
|
using Continuation::operator();
|
||||||
|
|
||||||
|
bool operator()(is_ready_arg_t) const noexcept {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::tuple<T...> operator()(get_arg_t) && {
|
||||||
|
util::unreachable();
|
||||||
|
}
|
||||||
|
};*/
|
||||||
|
|
||||||
struct attorney {
|
struct attorney {
|
||||||
/// Creates a continuable_base from the given continuation, annotation
|
/// Creates a continuable_base from the given continuation, annotation
|
||||||
/// and ownership.
|
/// and ownership.
|
||||||
@ -78,7 +111,7 @@ struct attorney {
|
|||||||
static auto create_from(T&& continuation, A annotation,
|
static auto create_from(T&& continuation, A annotation,
|
||||||
util::ownership ownership) {
|
util::ownership ownership) {
|
||||||
(void)annotation;
|
(void)annotation;
|
||||||
return Continuable(std::forward<T>(continuation), ownership);
|
return Continuable({std::forward<T>(continuation)}, ownership);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the ownership of the given continuable_base
|
/// Returns the ownership of the given continuable_base
|
||||||
@ -93,6 +126,14 @@ struct attorney {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Returns the signature hint of the given continuable
|
||||||
|
template <typename Data, typename... Args>
|
||||||
|
constexpr traits::identity<Args...>
|
||||||
|
annotation_of(traits::identity<continuable_base<Data, //
|
||||||
|
traits::identity<Args...>>>) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
/// Invokes a continuation object in a reference correct way
|
/// Invokes a continuation object in a reference correct way
|
||||||
template <typename Data, typename Annotation, typename Callback>
|
template <typename Data, typename Annotation, typename Callback>
|
||||||
void invoke_continuation(continuable_base<Data, Annotation>&& continuation,
|
void invoke_continuation(continuable_base<Data, Annotation>&& continuation,
|
||||||
@ -180,8 +221,8 @@ void invoke_void_no_except(traits::identity<Args...>, T&& callable) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
constexpr auto make_invoker(T&& invoke, hints::signature_hint_tag<Args...>) {
|
constexpr auto make_invoker(T&& invoke, traits::identity<Args...>) {
|
||||||
return invoker<std::decay_t<T>, hints::signature_hint_tag<Args...>>(
|
return invoker<std::decay_t<T>, traits::identity<Args...>>(
|
||||||
std::forward<T>(invoke));
|
std::forward<T>(invoke));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +234,7 @@ invoker_of(traits::identity<continuable_base<Data, Annotation>>) {
|
|||||||
using Type =
|
using Type =
|
||||||
decltype(std::declval<continuable_base<Data, Annotation>>().finish());
|
decltype(std::declval<continuable_base<Data, Annotation>>().finish());
|
||||||
|
|
||||||
auto constexpr const hint = hints::hint_of(traits::identify<Type>{});
|
auto constexpr const hint = base::annotation_of(traits::identify<Type>{});
|
||||||
|
|
||||||
return make_invoker(
|
return make_invoker(
|
||||||
[](auto&& callback, auto&& next_callback, auto&&... args) {
|
[](auto&& callback, auto&& next_callback, auto&&... args) {
|
||||||
@ -405,7 +446,7 @@ template <handle_results HandleResults, typename Base, typename Hint>
|
|||||||
struct result_handler_base;
|
struct result_handler_base;
|
||||||
template <typename Base, typename... Args>
|
template <typename Base, typename... Args>
|
||||||
struct result_handler_base<handle_results::no, Base,
|
struct result_handler_base<handle_results::no, Base,
|
||||||
hints::signature_hint_tag<Args...>> {
|
traits::identity<Args...>> {
|
||||||
void operator()(Args... args) && {
|
void operator()(Args... args) && {
|
||||||
// Forward the arguments to the next callback
|
// Forward the arguments to the next callback
|
||||||
std::move(static_cast<Base*>(this)->next_callback_)(std::move(args)...);
|
std::move(static_cast<Base*>(this)->next_callback_)(std::move(args)...);
|
||||||
@ -413,7 +454,7 @@ struct result_handler_base<handle_results::no, Base,
|
|||||||
};
|
};
|
||||||
template <typename Base, typename... Args>
|
template <typename Base, typename... Args>
|
||||||
struct result_handler_base<handle_results::yes, Base,
|
struct result_handler_base<handle_results::yes, Base,
|
||||||
hints::signature_hint_tag<Args...>> {
|
traits::identity<Args...>> {
|
||||||
/// The operator which is called when the result was provided
|
/// The operator which is called when the result was provided
|
||||||
void operator()(Args... args) && {
|
void operator()(Args... args) && {
|
||||||
// In order to retrieve the correct decorator we must know what the
|
// In order to retrieve the correct decorator we must know what the
|
||||||
@ -475,17 +516,17 @@ struct callback_base;
|
|||||||
template <typename... Args, handle_results HandleResults,
|
template <typename... Args, handle_results HandleResults,
|
||||||
handle_errors HandleErrors, typename Callback, typename Executor,
|
handle_errors HandleErrors, typename Callback, typename Executor,
|
||||||
typename NextCallback>
|
typename NextCallback>
|
||||||
struct callback_base<hints::signature_hint_tag<Args...>, HandleResults,
|
struct callback_base<traits::identity<Args...>, HandleResults, HandleErrors,
|
||||||
HandleErrors, Callback, Executor, NextCallback>
|
Callback, Executor, NextCallback>
|
||||||
: proto::result_handler_base<
|
: proto::result_handler_base<
|
||||||
HandleResults,
|
HandleResults,
|
||||||
callback_base<hints::signature_hint_tag<Args...>, HandleResults,
|
callback_base<traits::identity<Args...>, HandleResults, HandleErrors,
|
||||||
HandleErrors, Callback, Executor, NextCallback>,
|
Callback, Executor, NextCallback>,
|
||||||
hints::signature_hint_tag<Args...>>,
|
traits::identity<Args...>>,
|
||||||
proto::error_handler_base<
|
proto::error_handler_base<
|
||||||
HandleErrors,
|
HandleErrors,
|
||||||
callback_base<hints::signature_hint_tag<Args...>, HandleResults,
|
callback_base<traits::identity<Args...>, HandleResults, HandleErrors,
|
||||||
HandleErrors, Callback, Executor, NextCallback>>,
|
Callback, Executor, NextCallback>>,
|
||||||
util::non_copyable {
|
util::non_copyable {
|
||||||
|
|
||||||
Callback callback_;
|
Callback callback_;
|
||||||
@ -501,16 +542,15 @@ struct callback_base<hints::signature_hint_tag<Args...>, HandleResults,
|
|||||||
/// Pull the result handling operator() in
|
/// Pull the result handling operator() in
|
||||||
using proto::result_handler_base<
|
using proto::result_handler_base<
|
||||||
HandleResults,
|
HandleResults,
|
||||||
callback_base<hints::signature_hint_tag<Args...>, HandleResults,
|
callback_base<traits::identity<Args...>, HandleResults, HandleErrors,
|
||||||
HandleErrors, Callback, Executor, NextCallback>,
|
Callback, Executor, NextCallback>,
|
||||||
hints::signature_hint_tag<Args...>>::operator();
|
traits::identity<Args...>>::operator();
|
||||||
|
|
||||||
/// Pull the error handling operator() in
|
/// Pull the error handling operator() in
|
||||||
using proto::error_handler_base<
|
using proto::error_handler_base<
|
||||||
HandleErrors,
|
HandleErrors,
|
||||||
callback_base<hints::signature_hint_tag<Args...>, HandleResults,
|
callback_base<traits::identity<Args...>, HandleResults, HandleErrors,
|
||||||
HandleErrors, Callback, Executor, NextCallback>>::
|
Callback, Executor, NextCallback>>::operator();
|
||||||
operator();
|
|
||||||
|
|
||||||
/// Resolves the continuation with the given values
|
/// Resolves the continuation with the given values
|
||||||
void set_value(Args... args) {
|
void set_value(Args... args) {
|
||||||
@ -581,7 +621,7 @@ template <typename T, typename... Args>
|
|||||||
constexpr auto
|
constexpr auto
|
||||||
next_hint_of(std::integral_constant<handle_results, handle_results::yes>,
|
next_hint_of(std::integral_constant<handle_results, handle_results::yes>,
|
||||||
traits::identity<T> /*callback*/,
|
traits::identity<T> /*callback*/,
|
||||||
hints::signature_hint_tag<Args...> /*current*/) {
|
traits::identity<Args...> /*current*/) {
|
||||||
// Partial Invoke the given callback
|
// Partial Invoke the given callback
|
||||||
using Result = decltype(
|
using Result = decltype(
|
||||||
decoration::invoke_callback(std::declval<T>(), std::declval<Args>()...));
|
decoration::invoke_callback(std::declval<T>(), std::declval<Args>()...));
|
||||||
@ -594,7 +634,7 @@ template <typename T, typename... Args>
|
|||||||
constexpr auto
|
constexpr auto
|
||||||
next_hint_of(std::integral_constant<handle_results, handle_results::no>,
|
next_hint_of(std::integral_constant<handle_results, handle_results::no>,
|
||||||
traits::identity<T> /*callback*/,
|
traits::identity<T> /*callback*/,
|
||||||
hints::signature_hint_tag<Args...> current) {
|
traits::identity<Args...> current) {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,7 +675,7 @@ auto chain_continuation(Continuation&& continuation, Callback&& callback,
|
|||||||
static_assert(is_continuable<std::decay_t<Continuation>>{},
|
static_assert(is_continuable<std::decay_t<Continuation>>{},
|
||||||
"Expected a continuation!");
|
"Expected a continuation!");
|
||||||
|
|
||||||
using Hint = decltype(hints::hint_of(traits::identify<Continuation>()));
|
using Hint = decltype(base::annotation_of(traits::identify<Continuation>()));
|
||||||
constexpr auto next_hint =
|
constexpr auto next_hint =
|
||||||
next_hint_of(std::integral_constant<handle_results, HandleResults>{},
|
next_hint_of(std::integral_constant<handle_results, HandleResults>{},
|
||||||
traits::identify<decltype(callback)>{}, Hint{});
|
traits::identify<decltype(callback)>{}, Hint{});
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Tag for constructing an empty promise_base .
|
/// Tag for constructing an empty promise_base .
|
||||||
struct promise_no_init_tag {};
|
struct promise_no_init_arg_t {};
|
||||||
} // namespace types
|
} // namespace types
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
#include <experimental/coroutine>
|
#include <experimental/coroutine>
|
||||||
#include <continuable/continuable-primitives.hpp>
|
#include <continuable/continuable-primitives.hpp>
|
||||||
#include <continuable/continuable-result.hpp>
|
#include <continuable/continuable-result.hpp>
|
||||||
#include <continuable/detail/core/hints.hpp>
|
#include <continuable/detail/core/annotation.hpp>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
#include <continuable/detail/features.hpp>
|
#include <continuable/detail/features.hpp>
|
||||||
#include <continuable/detail/utility/traits.hpp>
|
#include <continuable/detail/utility/traits.hpp>
|
||||||
@ -65,7 +65,7 @@ struct result_from_identity<traits::identity<T...>> {
|
|||||||
/// for waiting on a continuable in a stackless coroutine.
|
/// for waiting on a continuable in a stackless coroutine.
|
||||||
template <typename Continuable>
|
template <typename Continuable>
|
||||||
class awaitable {
|
class awaitable {
|
||||||
using hint_t = decltype(hints::hint_of(traits::identify<Continuable>{}));
|
using hint_t = decltype(base::annotation_of(traits::identify<Continuable>{}));
|
||||||
using result_t = typename result_from_identity<hint_t>::result_t;
|
using result_t = typename result_from_identity<hint_t>::result_t;
|
||||||
|
|
||||||
/// The continuable which is invoked upon suspension
|
/// The continuable which is invoked upon suspension
|
||||||
@ -186,7 +186,7 @@ struct promise_type : promise_resolver_base<promise_type<Promise, Args...>> {
|
|||||||
coroutine_handle<> handle_;
|
coroutine_handle<> handle_;
|
||||||
Promise promise_;
|
Promise promise_;
|
||||||
|
|
||||||
explicit promise_type() : promise_(types::promise_no_init_tag{}) {
|
explicit promise_type() : promise_(types::promise_no_init_arg_t{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_return_object() {
|
auto get_return_object() {
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
#include <future>
|
#include <future>
|
||||||
#include <continuable/continuable-primitives.hpp>
|
#include <continuable/continuable-primitives.hpp>
|
||||||
#include <continuable/detail/core/base.hpp>
|
#include <continuable/detail/core/base.hpp>
|
||||||
#include <continuable/detail/core/hints.hpp>
|
#include <continuable/detail/core/annotation.hpp>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
#include <continuable/detail/features.hpp>
|
#include <continuable/detail/features.hpp>
|
||||||
#include <continuable/detail/utility/util.hpp>
|
#include <continuable/detail/utility/util.hpp>
|
||||||
@ -77,7 +77,7 @@ template <typename Hint>
|
|||||||
class promise_callback;
|
class promise_callback;
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
class promise_callback<hints::signature_hint_tag<Args...>>
|
class promise_callback<traits::identity<Args...>>
|
||||||
: public future_trait<Args...> {
|
: public future_trait<Args...> {
|
||||||
|
|
||||||
typename future_trait<Args...>::promise_t promise_;
|
typename future_trait<Args...>::promise_t promise_;
|
||||||
@ -119,7 +119,7 @@ template <typename Data, typename Annotation>
|
|||||||
auto as_future(continuable_base<Data, Annotation>&& continuable) {
|
auto as_future(continuable_base<Data, Annotation>&& continuable) {
|
||||||
// Create the promise which is able to supply the current arguments
|
// Create the promise which is able to supply the current arguments
|
||||||
constexpr auto const hint =
|
constexpr auto const hint =
|
||||||
hints::hint_of(traits::identify<decltype(continuable)>{});
|
base::annotation_of(traits::identify<decltype(continuable)>{});
|
||||||
|
|
||||||
promise_callback<std::decay_t<decltype(hint)>> callback;
|
promise_callback<std::decay_t<decltype(hint)>> callback;
|
||||||
(void)hint;
|
(void)hint;
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <continuable/detail/core/hints.hpp>
|
#include <continuable/detail/core/annotation.hpp>
|
||||||
#include <continuable/detail/utility/traits.hpp>
|
#include <continuable/detail/utility/traits.hpp>
|
||||||
#include <continuable/detail/utility/util.hpp>
|
#include <continuable/detail/utility/util.hpp>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user