Some renaming

This commit is contained in:
Denis Blank 2018-12-07 04:40:03 +01:00
parent f17cc4073c
commit 62ca39e59c
13 changed files with 132 additions and 70 deletions

View File

@ -578,13 +578,23 @@ public:
return materializer::apply(std::move(*this));
}
#ifdef DOXYGEN
/// Returns true if the continuable_base will resolve its promise
/// immediately on request.
///
/// \since 4.0.0
bool is_ready() const noexcept {
return false;
}
bool is_ready() const noexcept;
#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.
///
@ -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.
///
/// \tparam Args The types (signature hint) the given promise is resolved with.

View File

@ -52,7 +52,7 @@ namespace experimental {
template <typename Data, typename... Args, typename... FunctionArgs>
struct coroutine_traits<
cti::continuable_base<Data,
cti::detail::hints::signature_hint_tag<Args...>>,
cti::detail::traits::identity<Args...>>,
FunctionArgs...> {
using promise_type =

View File

@ -34,7 +34,7 @@
#include <type_traits>
#include <utility>
#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/utility/util.hpp>
@ -62,7 +62,7 @@ class promise_base
/// \cond false
;
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
/// \endcond
{ // clang-format on
@ -78,7 +78,7 @@ public:
}
/// \cond false
/// 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

View File

@ -35,7 +35,7 @@
#include <continuable/continuable-primitives.hpp>
#include <continuable/continuable-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>
namespace cti {
@ -67,12 +67,12 @@ class continuable_trait {
public:
/// The promise type which is used to resolve continuations
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.
using continuable =
continuable_base<ContinuationWrapper<sizeof(callback), void(promise)>,
detail::hints::signature_hint_tag<Args...>>;
detail::traits::identity<Args...>>;
};
/// \}
} // namespace cti

View File

@ -75,17 +75,17 @@ T&& unpack_lazy(container::flat_variant<T>&& value) {
template <typename Continuable>
class continuable_box;
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:
explicit continuable_box(
continuable_base<Data, hints::signature_hint_tag<>>&& continuable)
continuable_base<Data, traits::identity<>>&& continuable)
: continuable_(std::move(continuable)) {
}
continuable_base<Data, hints::signature_hint_tag<>>&& fetch() {
continuable_base<Data, traits::identity<>>&& fetch() {
return std::move(continuable_);
}
@ -98,18 +98,18 @@ public:
};
template <typename Data, typename First>
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_;
public:
explicit continuable_box(
continuable_base<Data, hints::signature_hint_tag<First>>&& continuable)
continuable_base<Data, traits::identity<First>>&& 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_);
}
@ -123,21 +123,21 @@ public:
};
template <typename Data, typename First, typename Second, typename... Rest>
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_;
lazy_value_t<std::tuple<First, Second, Rest...>> args_;
public:
explicit continuable_box(
continuable_base<Data,
hints::signature_hint_tag<First, Second, Rest...>>&&
traits::identity<First, Second, Rest...>>&&
continuable)
: continuable_(std::move(continuable)) {
}
continuable_base<Data, hints::signature_hint_tag<First, Second, Rest...>>&&
continuable_base<Data, traits::identity<First, Second, Rest...>>&&
fetch() {
return std::move(continuable_);
}
@ -215,7 +215,7 @@ constexpr auto finalize_impl(traits::identity<std::tuple<Args...>>,
struct hint_mapper {
template <typename... T>
constexpr auto operator()(T...) -> hints::signature_hint_tag<T...> {
constexpr auto operator()(T...) -> traits::identity<T...> {
return {};
}
};

View File

@ -41,7 +41,7 @@
#include <continuable/detail/connection/connection-aggregated.hpp>
#include <continuable/detail/connection/connection.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/utility/traits.hpp>

View File

@ -41,7 +41,7 @@
#include <continuable/continuable-promise-base.hpp>
#include <continuable/continuable-traverse.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/traversal/container-category.hpp>
#include <continuable/detail/utility/traits.hpp>
@ -95,7 +95,7 @@ struct result_deducer {
}
template <typename T>
static auto deduce_one(std::true_type, traits::identity<T> id) {
return hints::hint_of(id);
return base::annotation_of(id);
}
template <typename T>
static auto deduce(traversal::container_category_tag<false, false>,

View File

@ -28,8 +28,8 @@
SOFTWARE.
**/
#ifndef CONTINUABLE_DETAIL_HINTS_HPP_INCLUDED
#define CONTINUABLE_DETAIL_HINTS_HPP_INCLUDED
#ifndef CONTINUABLE_DETAIL_ANNOTATION_HPP_INCLUDED
#define CONTINUABLE_DETAIL_ANNOTATION_HPP_INCLUDED
#include <type_traits>
#include <continuable/detail/core/types.hpp>
@ -37,18 +37,18 @@
namespace cti {
namespace detail {
namespace hints {
/// Represents a present signature hint
template <typename Annotation>
struct annotation_trait;
/// Specialization for a present signature hint
template <typename... Args>
using signature_hint_tag = traits::identity<Args...>;
/// Returns the signature hint of the given continuable
template <typename Data, typename... Args>
constexpr signature_hint_tag<Args...>
hint_of(traits::identity<continuable_base<Data, signature_hint_tag<Args...>>>) {
return {};
}
struct annotation_trait<traits::identity<Args...>> {
using is_concrete_hint = std::true_type;
using hint_t = traits::identity<Args...>;
using is_materialized = std::true_type;
};
namespace hints {
/// Extracts the signature we pass to the internal continuable
/// from an argument pack as specified by make_continuable.
///
@ -67,4 +67,4 @@ constexpr auto extract(traits::identity<void> /*hint*/) {
} // namespace detail
} // namespace cti
#endif // CONTINUABLE_DETAIL_HINTS_HPP_INCLUDED
#endif // CONTINUABLE_DETAIL_ANNOTATION_HPP_INCLUDED

View File

@ -36,7 +36,7 @@
#include <utility>
#include <continuable/continuable-primitives.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/features.hpp>
#include <continuable/detail/utility/result-trait.hpp>
@ -69,6 +69,39 @@ struct is_continuable : std::false_type {};
template <typename Data, typename Annotation>
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 {
/// Creates a continuable_base from the given continuation, annotation
/// and ownership.
@ -78,7 +111,7 @@ struct attorney {
static auto create_from(T&& continuation, A annotation,
util::ownership ownership) {
(void)annotation;
return Continuable(std::forward<T>(continuation), ownership);
return Continuable({std::forward<T>(continuation)}, ownership);
}
/// 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
template <typename Data, typename Annotation, typename Callback>
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>
constexpr auto make_invoker(T&& invoke, hints::signature_hint_tag<Args...>) {
return invoker<std::decay_t<T>, hints::signature_hint_tag<Args...>>(
constexpr auto make_invoker(T&& invoke, traits::identity<Args...>) {
return invoker<std::decay_t<T>, traits::identity<Args...>>(
std::forward<T>(invoke));
}
@ -193,7 +234,7 @@ invoker_of(traits::identity<continuable_base<Data, Annotation>>) {
using Type =
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(
[](auto&& callback, auto&& next_callback, auto&&... args) {
@ -405,7 +446,7 @@ template <handle_results HandleResults, typename Base, typename Hint>
struct result_handler_base;
template <typename Base, typename... Args>
struct result_handler_base<handle_results::no, Base,
hints::signature_hint_tag<Args...>> {
traits::identity<Args...>> {
void operator()(Args... args) && {
// Forward the arguments to the next callback
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>
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
void operator()(Args... args) && {
// 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,
handle_errors HandleErrors, typename Callback, typename Executor,
typename NextCallback>
struct callback_base<hints::signature_hint_tag<Args...>, HandleResults,
HandleErrors, Callback, Executor, NextCallback>
struct callback_base<traits::identity<Args...>, HandleResults, HandleErrors,
Callback, Executor, NextCallback>
: proto::result_handler_base<
HandleResults,
callback_base<hints::signature_hint_tag<Args...>, HandleResults,
HandleErrors, Callback, Executor, NextCallback>,
hints::signature_hint_tag<Args...>>,
callback_base<traits::identity<Args...>, HandleResults, HandleErrors,
Callback, Executor, NextCallback>,
traits::identity<Args...>>,
proto::error_handler_base<
HandleErrors,
callback_base<hints::signature_hint_tag<Args...>, HandleResults,
HandleErrors, Callback, Executor, NextCallback>>,
callback_base<traits::identity<Args...>, HandleResults, HandleErrors,
Callback, Executor, NextCallback>>,
util::non_copyable {
Callback callback_;
@ -501,16 +542,15 @@ struct callback_base<hints::signature_hint_tag<Args...>, HandleResults,
/// Pull the result handling operator() in
using proto::result_handler_base<
HandleResults,
callback_base<hints::signature_hint_tag<Args...>, HandleResults,
HandleErrors, Callback, Executor, NextCallback>,
hints::signature_hint_tag<Args...>>::operator();
callback_base<traits::identity<Args...>, HandleResults, HandleErrors,
Callback, Executor, NextCallback>,
traits::identity<Args...>>::operator();
/// Pull the error handling operator() in
using proto::error_handler_base<
HandleErrors,
callback_base<hints::signature_hint_tag<Args...>, HandleResults,
HandleErrors, Callback, Executor, NextCallback>>::
operator();
callback_base<traits::identity<Args...>, HandleResults, HandleErrors,
Callback, Executor, NextCallback>>::operator();
/// Resolves the continuation with the given values
void set_value(Args... args) {
@ -581,7 +621,7 @@ template <typename T, typename... Args>
constexpr auto
next_hint_of(std::integral_constant<handle_results, handle_results::yes>,
traits::identity<T> /*callback*/,
hints::signature_hint_tag<Args...> /*current*/) {
traits::identity<Args...> /*current*/) {
// Partial Invoke the given callback
using Result = decltype(
decoration::invoke_callback(std::declval<T>(), std::declval<Args>()...));
@ -594,7 +634,7 @@ template <typename T, typename... Args>
constexpr auto
next_hint_of(std::integral_constant<handle_results, handle_results::no>,
traits::identity<T> /*callback*/,
hints::signature_hint_tag<Args...> current) {
traits::identity<Args...> current) {
return current;
}
@ -635,7 +675,7 @@ auto chain_continuation(Continuation&& continuation, Callback&& callback,
static_assert(is_continuable<std::decay_t<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 =
next_hint_of(std::integral_constant<handle_results, HandleResults>{},
traits::identify<decltype(callback)>{}, Hint{});

View File

@ -75,7 +75,7 @@ public:
};
/// Tag for constructing an empty promise_base .
struct promise_no_init_tag {};
struct promise_no_init_arg_t {};
} // namespace types
} // namespace detail
} // namespace cti

View File

@ -38,7 +38,7 @@
#include <experimental/coroutine>
#include <continuable/continuable-primitives.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/features.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.
template <typename Continuable>
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;
/// The continuable which is invoked upon suspension
@ -186,7 +186,7 @@ struct promise_type : promise_resolver_base<promise_type<Promise, Args...>> {
coroutine_handle<> handle_;
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() {

View File

@ -34,7 +34,7 @@
#include <future>
#include <continuable/continuable-primitives.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/features.hpp>
#include <continuable/detail/utility/util.hpp>
@ -77,7 +77,7 @@ template <typename Hint>
class promise_callback;
template <typename... Args>
class promise_callback<hints::signature_hint_tag<Args...>>
class promise_callback<traits::identity<Args...>>
: public future_trait<Args...> {
typename future_trait<Args...>::promise_t promise_;
@ -119,7 +119,7 @@ template <typename Data, typename Annotation>
auto as_future(continuable_base<Data, Annotation>&& continuable) {
// Create the promise which is able to supply the current arguments
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;
(void)hint;

View File

@ -34,7 +34,7 @@
#include <tuple>
#include <type_traits>
#include <utility>
#include <continuable/detail/core/hints.hpp>
#include <continuable/detail/core/annotation.hpp>
#include <continuable/detail/utility/traits.hpp>
#include <continuable/detail/utility/util.hpp>