mirror of
https://github.com/Naios/continuable.git
synced 2026-02-17 07:39:49 +08:00
Rename composition to connection
This commit is contained in:
parent
093ecae1c0
commit
9ab9b5e7fb
@ -37,14 +37,14 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <continuable/detail/base.hpp>
|
#include <continuable/detail/base.hpp>
|
||||||
#include <continuable/detail/composition-all.hpp>
|
#include <continuable/detail/connection-all.hpp>
|
||||||
#include <continuable/detail/composition-any.hpp>
|
#include <continuable/detail/connection-any.hpp>
|
||||||
#include <continuable/detail/composition-seq.hpp>
|
#include <continuable/detail/connection-seq.hpp>
|
||||||
#include <continuable/detail/composition.hpp>
|
#include <continuable/detail/connection.hpp>
|
||||||
|
#include <continuable/detail/features.hpp>
|
||||||
#include <continuable/detail/traits.hpp>
|
#include <continuable/detail/traits.hpp>
|
||||||
#include <continuable/detail/types.hpp>
|
#include <continuable/detail/types.hpp>
|
||||||
#include <continuable/detail/util.hpp>
|
#include <continuable/detail/util.hpp>
|
||||||
#include <continuable/detail/features.hpp>
|
|
||||||
|
|
||||||
#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||||
#include <continuable/detail/awaiting.hpp>
|
#include <continuable/detail/awaiting.hpp>
|
||||||
@ -490,8 +490,8 @@ public:
|
|||||||
/// \since 1.0.0
|
/// \since 1.0.0
|
||||||
template <typename OData, typename OAnnotation>
|
template <typename OData, typename OAnnotation>
|
||||||
auto operator&&(continuable_base<OData, OAnnotation>&& right) && {
|
auto operator&&(continuable_base<OData, OAnnotation>&& right) && {
|
||||||
return detail::composition::connect(
|
return detail::connection::connect(
|
||||||
detail::composition::composition_strategy_all_tag{}, std::move(*this),
|
detail::connection::connection_strategy_all_tag{}, std::move(*this),
|
||||||
std::move(right));
|
std::move(right));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,8 +528,8 @@ public:
|
|||||||
/// \since 1.0.0
|
/// \since 1.0.0
|
||||||
template <typename OData, typename OAnnotation>
|
template <typename OData, typename OAnnotation>
|
||||||
auto operator||(continuable_base<OData, OAnnotation>&& right) && {
|
auto operator||(continuable_base<OData, OAnnotation>&& right) && {
|
||||||
return detail::composition::connect(
|
return detail::connection::connect(
|
||||||
detail::composition::composition_strategy_any_tag{}, std::move(*this),
|
detail::connection::connection_strategy_any_tag{}, std::move(*this),
|
||||||
std::move(right));
|
std::move(right));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,8 +557,8 @@ public:
|
|||||||
/// \since 1.0.0
|
/// \since 1.0.0
|
||||||
template <typename OData, typename OAnnotation>
|
template <typename OData, typename OAnnotation>
|
||||||
auto operator>>(continuable_base<OData, OAnnotation>&& right) && {
|
auto operator>>(continuable_base<OData, OAnnotation>&& right) && {
|
||||||
return detail::composition::seq::sequential_connect(std::move(*this),
|
return detail::connection::seq::sequential_connect(std::move(*this),
|
||||||
std::move(right));
|
std::move(right));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Invokes the continuation chain manually even before the
|
/// Invokes the continuation chain manually even before the
|
||||||
@ -695,7 +695,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto materialize() && {
|
auto materialize() && {
|
||||||
return detail::composition::materializer<continuable_base>::apply(
|
return detail::connection::materializer<continuable_base>::apply(
|
||||||
std::move(*this));
|
std::move(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,10 +36,10 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <continuable/detail/composition-all.hpp>
|
#include <continuable/detail/connection-all.hpp>
|
||||||
#include <continuable/detail/composition-any.hpp>
|
#include <continuable/detail/connection-any.hpp>
|
||||||
#include <continuable/detail/composition-seq.hpp>
|
#include <continuable/detail/connection-seq.hpp>
|
||||||
#include <continuable/detail/composition.hpp>
|
#include <continuable/detail/connection.hpp>
|
||||||
#include <continuable/detail/range.hpp>
|
#include <continuable/detail/range.hpp>
|
||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
@ -77,8 +77,8 @@ namespace cti {
|
|||||||
/// \since 1.1.0
|
/// \since 1.1.0
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto when_all(Args&&... args) {
|
auto when_all(Args&&... args) {
|
||||||
return detail::composition::apply_composition(
|
return detail::connection::apply_connection(
|
||||||
detail::composition::composition_strategy_all_tag{},
|
detail::connection::connection_strategy_all_tag{},
|
||||||
std::forward<Args>(args)...);
|
std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +146,8 @@ auto when_all(Iterator begin, Iterator end) {
|
|||||||
/// \since 1.1.0
|
/// \since 1.1.0
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto when_seq(Args&&... args) {
|
auto when_seq(Args&&... args) {
|
||||||
return detail::composition::apply_composition(
|
return detail::connection::apply_connection(
|
||||||
detail::composition::composition_strategy_seq_tag{},
|
detail::connection::connection_strategy_seq_tag{},
|
||||||
std::forward<Args>(args)...);
|
std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,8 +214,8 @@ auto when_seq(Iterator begin, Iterator end) {
|
|||||||
/// \since 1.1.0
|
/// \since 1.1.0
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto when_any(Args&&... args) {
|
auto when_any(Args&&... args) {
|
||||||
return detail::composition::apply_composition(
|
return detail::connection::apply_connection(
|
||||||
detail::composition::composition_strategy_any_tag{},
|
detail::connection::connection_strategy_any_tag{},
|
||||||
std::forward<Args>(args)...);
|
std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,14 +43,14 @@
|
|||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
namespace composition {
|
namespace connection {
|
||||||
/// This namespace provides utilities for performing compound
|
/// This namespace provides utilities for performing compound
|
||||||
/// connections between deeply nested continuables and values.
|
/// connections between deeply nested continuables and values.
|
||||||
///
|
///
|
||||||
/// We create the result pack from the provides values and
|
/// We create the result pack from the provides values and
|
||||||
/// the async values if those are default constructible,
|
/// the async values if those are default constructible,
|
||||||
/// otherwise use a lazy initialization wrapper and unwrap
|
/// otherwise use a lazy initialization wrapper and unwrap
|
||||||
/// the whole pack when the composition is finished.
|
/// the whole pack when the connection is finished.
|
||||||
/// - value -> value
|
/// - value -> value
|
||||||
/// - single async value -> single value
|
/// - single async value -> single value
|
||||||
/// - multiple async value -> tuple of async values.
|
/// - multiple async value -> tuple of async values.
|
||||||
@ -68,7 +68,7 @@ decltype(auto) unpack_lazy(T&& value) {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
T&& unpack_lazy(container::flat_variant<T>&& value) {
|
T&& unpack_lazy(container::flat_variant<T>&& value) {
|
||||||
assert(value.template is<T>() &&
|
assert(value.template is<T>() &&
|
||||||
"The composition was finalized before all values were present!");
|
"The connection was finalized before all values were present!");
|
||||||
|
|
||||||
return std::move(value.template cast<T>());
|
return std::move(value.template cast<T>());
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ constexpr auto hint_of_data() {
|
|||||||
return decltype(finalize_data(detail::hint_mapper{}, std::declval<Data>())){};
|
return decltype(finalize_data(detail::hint_mapper{}, std::declval<Data>())){};
|
||||||
}
|
}
|
||||||
} // namespace aggregated
|
} // namespace aggregated
|
||||||
} // namespace composition
|
} // namespace connection
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
|
|||||||
@ -39,15 +39,15 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <continuable/detail/base.hpp>
|
#include <continuable/detail/base.hpp>
|
||||||
#include <continuable/detail/composition-aggregated.hpp>
|
#include <continuable/detail/connection-aggregated.hpp>
|
||||||
#include <continuable/detail/composition.hpp>
|
#include <continuable/detail/connection.hpp>
|
||||||
#include <continuable/detail/hints.hpp>
|
#include <continuable/detail/hints.hpp>
|
||||||
#include <continuable/detail/traits.hpp>
|
#include <continuable/detail/traits.hpp>
|
||||||
#include <continuable/detail/types.hpp>
|
#include <continuable/detail/types.hpp>
|
||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
namespace composition {
|
namespace connection {
|
||||||
namespace all {
|
namespace all {
|
||||||
/// Caches the partial results and invokes the callback when all results
|
/// Caches the partial results and invokes the callback when all results
|
||||||
/// are arrived. This class is thread safe.
|
/// are arrived. This class is thread safe.
|
||||||
@ -100,7 +100,7 @@ class result_submitter
|
|||||||
|
|
||||||
template <typename... PartialArgs>
|
template <typename... PartialArgs>
|
||||||
void operator()(types::dispatch_error_tag tag, types::error_type error) && {
|
void operator()(types::dispatch_error_tag tag, types::error_type error) && {
|
||||||
// We never complete the composition, but we forward the first error
|
// We never complete the connection, but we forward the first error
|
||||||
// which was raised.
|
// which was raised.
|
||||||
std::call_once(me->flag_, std::move(me->callback_), tag,
|
std::call_once(me->flag_, std::move(me->callback_), tag,
|
||||||
std::move(error));
|
std::move(error));
|
||||||
@ -121,7 +121,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Initially the counter is created with an initial count of 1 in order
|
/// Initially the counter is created with an initial count of 1 in order
|
||||||
/// to prevent that the composition is finished before all callbacks
|
/// to prevent that the connection is finished before all callbacks
|
||||||
/// were registered.
|
/// were registered.
|
||||||
void accept() {
|
void accept() {
|
||||||
complete_one();
|
complete_one();
|
||||||
@ -145,20 +145,20 @@ struct continuable_dispatcher {
|
|||||||
};
|
};
|
||||||
} // namespace all
|
} // namespace all
|
||||||
|
|
||||||
struct composition_strategy_all_tag {};
|
struct connection_strategy_all_tag {};
|
||||||
template <>
|
template <>
|
||||||
struct is_composition_strategy<composition_strategy_all_tag> // ...
|
struct is_connection_strategy<connection_strategy_all_tag> // ...
|
||||||
: std::true_type {};
|
: std::true_type {};
|
||||||
|
|
||||||
/// Finalizes the all logic of a given composition
|
/// Finalizes the all logic of a given connection
|
||||||
template <>
|
template <>
|
||||||
struct composition_finalizer<composition_strategy_all_tag> {
|
struct connection_finalizer<connection_strategy_all_tag> {
|
||||||
/// Finalizes the all logic of a given composition
|
/// Finalizes the all logic of a given connection
|
||||||
template <typename Composition>
|
template <typename Connection>
|
||||||
static auto finalize(Composition&& composition, util::ownership ownership) {
|
static auto finalize(Connection&& connection, util::ownership ownership) {
|
||||||
// Create the target result from the composition
|
// Create the target result from the connection
|
||||||
auto result =
|
auto result =
|
||||||
aggregated::box_continuables(std::forward<Composition>(composition));
|
aggregated::box_continuables(std::forward<Connection>(connection));
|
||||||
|
|
||||||
auto signature = aggregated::hint_of_data<decltype(result)>();
|
auto signature = aggregated::hint_of_data<decltype(result)>();
|
||||||
|
|
||||||
@ -179,13 +179,13 @@ struct composition_finalizer<composition_strategy_all_tag> {
|
|||||||
traverse_pack(all::continuable_dispatcher<submitter_t>{state},
|
traverse_pack(all::continuable_dispatcher<submitter_t>{state},
|
||||||
state->head());
|
state->head());
|
||||||
|
|
||||||
// Finalize the composition if all results arrived in-place
|
// Finalize the connection if all results arrived in-place
|
||||||
state->accept();
|
state->accept();
|
||||||
},
|
},
|
||||||
signature, std::move(ownership));
|
signature, std::move(ownership));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace composition
|
} // namespace connection
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
namespace composition {
|
namespace connection {
|
||||||
namespace any {
|
namespace any {
|
||||||
/// Invokes the callback with the first arriving result
|
/// Invokes the callback with the first arriving result
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -160,23 +160,23 @@ struct continuable_dispatcher {
|
|||||||
};
|
};
|
||||||
} // namespace any
|
} // namespace any
|
||||||
|
|
||||||
struct composition_strategy_any_tag {};
|
struct connection_strategy_any_tag {};
|
||||||
template <>
|
template <>
|
||||||
struct is_composition_strategy<composition_strategy_any_tag> // ...
|
struct is_connection_strategy<connection_strategy_any_tag> // ...
|
||||||
: std::true_type {};
|
: std::true_type {};
|
||||||
|
|
||||||
/// Finalizes the any logic of a given composition
|
/// Finalizes the any logic of a given connection
|
||||||
template <>
|
template <>
|
||||||
struct composition_finalizer<composition_strategy_any_tag> {
|
struct connection_finalizer<connection_strategy_any_tag> {
|
||||||
template <typename Composition>
|
template <typename Connection>
|
||||||
static auto finalize(Composition&& composition, util::ownership ownership) {
|
static auto finalize(Connection&& connection, util::ownership ownership) {
|
||||||
auto signature = decltype(any::result_deducer::deduce(
|
auto signature = decltype(any::result_deducer::deduce(
|
||||||
traversal::container_category_of_t<std::decay_t<Composition>>{},
|
traversal::container_category_of_t<std::decay_t<Connection>>{},
|
||||||
traits::identity<std::decay_t<Composition>>{})){};
|
traits::identity<std::decay_t<Connection>>{})){};
|
||||||
|
|
||||||
return base::attorney::create(
|
return base::attorney::create(
|
||||||
[composition =
|
[connection =
|
||||||
std::forward<Composition>(composition)](auto&& callback) mutable {
|
std::forward<Connection>(connection)](auto&& callback) mutable {
|
||||||
|
|
||||||
using submitter_t =
|
using submitter_t =
|
||||||
any::any_result_submitter<std::decay_t<decltype(callback)>>;
|
any::any_result_submitter<std::decay_t<decltype(callback)>>;
|
||||||
@ -187,12 +187,12 @@ struct composition_finalizer<composition_strategy_any_tag> {
|
|||||||
std::forward<decltype(callback)>(callback));
|
std::forward<decltype(callback)>(callback));
|
||||||
|
|
||||||
traverse_pack(any::continuable_dispatcher<submitter_t>{submitter},
|
traverse_pack(any::continuable_dispatcher<submitter_t>{submitter},
|
||||||
std::move(composition));
|
std::move(connection));
|
||||||
},
|
},
|
||||||
signature, std::move(ownership));
|
signature, std::move(ownership));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace composition
|
} // namespace connection
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
|
|||||||
@ -39,13 +39,13 @@
|
|||||||
|
|
||||||
#include <continuable/continuable-traverse-async.hpp>
|
#include <continuable/continuable-traverse-async.hpp>
|
||||||
#include <continuable/detail/base.hpp>
|
#include <continuable/detail/base.hpp>
|
||||||
#include <continuable/detail/composition-aggregated.hpp>
|
#include <continuable/detail/connection-aggregated.hpp>
|
||||||
#include <continuable/detail/traits.hpp>
|
#include <continuable/detail/traits.hpp>
|
||||||
#include <continuable/detail/util.hpp>
|
#include <continuable/detail/util.hpp>
|
||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
namespace composition {
|
namespace connection {
|
||||||
namespace seq {
|
namespace seq {
|
||||||
/// Connects the left and the right continuable to a sequence
|
/// Connects the left and the right continuable to a sequence
|
||||||
///
|
///
|
||||||
@ -126,20 +126,20 @@ public:
|
|||||||
};
|
};
|
||||||
} // namespace seq
|
} // namespace seq
|
||||||
|
|
||||||
struct composition_strategy_seq_tag {};
|
struct connection_strategy_seq_tag {};
|
||||||
template <>
|
template <>
|
||||||
struct is_composition_strategy<composition_strategy_seq_tag> // ...
|
struct is_connection_strategy<connection_strategy_seq_tag> // ...
|
||||||
: std::true_type {};
|
: std::true_type {};
|
||||||
|
|
||||||
/// Finalizes the seq logic of a given composition
|
/// Finalizes the seq logic of a given connection
|
||||||
template <>
|
template <>
|
||||||
struct composition_finalizer<composition_strategy_seq_tag> {
|
struct connection_finalizer<connection_strategy_seq_tag> {
|
||||||
/// Finalizes the all logic of a given composition
|
/// Finalizes the all logic of a given connection
|
||||||
template <typename Composition>
|
template <typename Connection>
|
||||||
static auto finalize(Composition&& composition, util::ownership ownership) {
|
static auto finalize(Connection&& connection, util::ownership ownership) {
|
||||||
|
|
||||||
auto result =
|
auto result =
|
||||||
aggregated::box_continuables(std::forward<Composition>(composition));
|
aggregated::box_continuables(std::forward<Connection>(connection));
|
||||||
|
|
||||||
auto signature = aggregated::hint_of_data<decltype(result)>();
|
auto signature = aggregated::hint_of_data<decltype(result)>();
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ struct composition_finalizer<composition_strategy_seq_tag> {
|
|||||||
signature, std::move(ownership));
|
signature, std::move(ownership));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace composition
|
} // namespace connection
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
|
|||||||
@ -44,17 +44,17 @@
|
|||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
/// The namespace `composition` offers methods to chain continuations together
|
/// The namespace `connection` offers methods to chain continuations together
|
||||||
/// with `all`, `any` or `seq` logic.
|
/// with `all`, `any` or `seq` logic.
|
||||||
namespace composition {
|
namespace connection {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_composition_strategy // ...
|
struct is_connection_strategy // ...
|
||||||
: std::false_type {};
|
: std::false_type {};
|
||||||
|
|
||||||
/// Adds the given continuation tuple to the left composition
|
/// Adds the given continuation tuple to the left connection
|
||||||
template <typename... LeftArgs, typename... RightArgs>
|
template <typename... LeftArgs, typename... RightArgs>
|
||||||
auto chain_composition(std::tuple<LeftArgs...> leftPack,
|
auto chain_connection(std::tuple<LeftArgs...> leftPack,
|
||||||
std::tuple<RightArgs...> rightPack) {
|
std::tuple<RightArgs...> rightPack) {
|
||||||
|
|
||||||
return traits::merge(std::move(leftPack), std::move(rightPack));
|
return traits::merge(std::move(leftPack), std::move(rightPack));
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ auto chain_composition(std::tuple<LeftArgs...> leftPack,
|
|||||||
/// -> make a tuple containing the continuable as only element
|
/// -> make a tuple containing the continuable as only element
|
||||||
template <
|
template <
|
||||||
typename Strategy, typename Data, typename Annotation,
|
typename Strategy, typename Data, typename Annotation,
|
||||||
std::enable_if_t<!is_composition_strategy<Annotation>::value>* = nullptr>
|
std::enable_if_t<!is_connection_strategy<Annotation>::value>* = nullptr>
|
||||||
auto normalize(Strategy /*strategy*/,
|
auto normalize(Strategy /*strategy*/,
|
||||||
continuable_base<Data, Annotation>&& continuation) {
|
continuable_base<Data, Annotation>&& continuation) {
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ auto normalize(Strategy /*strategy*/,
|
|||||||
/// -> materialize it
|
/// -> materialize it
|
||||||
template <
|
template <
|
||||||
typename Strategy, typename Data, typename Annotation,
|
typename Strategy, typename Data, typename Annotation,
|
||||||
std::enable_if_t<is_composition_strategy<Annotation>::value>* = nullptr>
|
std::enable_if_t<is_connection_strategy<Annotation>::value>* = nullptr>
|
||||||
auto normalize(Strategy /*strategy*/,
|
auto normalize(Strategy /*strategy*/,
|
||||||
continuable_base<Data, Annotation>&& continuation) {
|
continuable_base<Data, Annotation>&& continuation) {
|
||||||
|
|
||||||
@ -110,8 +110,8 @@ auto connect(Strategy strategy, continuable_base<LData, LAnnotation>&& left,
|
|||||||
|
|
||||||
// Make the new data which consists of a tuple containing
|
// Make the new data which consists of a tuple containing
|
||||||
// all connected continuables.
|
// all connected continuables.
|
||||||
auto data = chain_composition(normalize(strategy, std::move(left)),
|
auto data = chain_connection(normalize(strategy, std::move(left)),
|
||||||
normalize(strategy, std::move(right)));
|
normalize(strategy, std::move(right)));
|
||||||
|
|
||||||
// Return a new continuable containing the tuple and holding
|
// Return a new continuable containing the tuple and holding
|
||||||
// the current strategy as annotation.
|
// the current strategy as annotation.
|
||||||
@ -120,21 +120,21 @@ auto connect(Strategy strategy, continuable_base<LData, LAnnotation>&& left,
|
|||||||
|
|
||||||
/// All strategies should specialize this class in order to provide:
|
/// All strategies should specialize this class in order to provide:
|
||||||
/// - A finalize static method that creates the callable object which
|
/// - A finalize static method that creates the callable object which
|
||||||
/// is invoked with the callback to call when the composition is finished.
|
/// is invoked with the callback to call when the connection is finished.
|
||||||
/// - A static method hint that returns the new signature hint.
|
/// - A static method hint that returns the new signature hint.
|
||||||
template <typename Strategy>
|
template <typename Strategy>
|
||||||
struct composition_finalizer;
|
struct connection_finalizer;
|
||||||
|
|
||||||
/// Finalizes the connection logic of a given composition
|
/// Finalizes the connection logic of a given connection
|
||||||
template <typename Data, typename Strategy>
|
template <typename Data, typename Strategy>
|
||||||
auto finalize_composition(continuable_base<Data, Strategy>&& continuation) {
|
auto finalize_connection(continuable_base<Data, Strategy>&& continuation) {
|
||||||
using finalizer = composition_finalizer<Strategy>;
|
using finalizer = connection_finalizer<Strategy>;
|
||||||
|
|
||||||
util::ownership ownership = base::attorney::ownership_of(continuation);
|
util::ownership ownership = base::attorney::ownership_of(continuation);
|
||||||
auto composition = base::attorney::consume_data(std::move(continuation));
|
auto connection = base::attorney::consume_data(std::move(continuation));
|
||||||
|
|
||||||
// Return a new continuable which
|
// Return a new continuable which
|
||||||
return finalizer::finalize(std::move(composition), std::move(ownership));
|
return finalizer::finalize(std::move(connection), std::move(ownership));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A base class from which the continuable may inherit in order to
|
/// A base class from which the continuable may inherit in order to
|
||||||
@ -146,12 +146,11 @@ struct materializer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename Data, typename Strategy>
|
template <typename Data, typename Strategy>
|
||||||
struct materializer<
|
struct materializer<continuable_base<Data, Strategy>,
|
||||||
continuable_base<Data, Strategy>,
|
std::enable_if_t<is_connection_strategy<Strategy>::value>> {
|
||||||
std::enable_if_t<is_composition_strategy<Strategy>::value>> {
|
|
||||||
|
|
||||||
static constexpr auto apply(continuable_base<Data, Strategy>&& continuable) {
|
static constexpr auto apply(continuable_base<Data, Strategy>&& continuable) {
|
||||||
return finalize_composition(std::move(continuable));
|
return finalize_connection(std::move(continuable));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -186,8 +185,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Strategy, typename... Args>
|
template <typename Strategy, typename... Args>
|
||||||
auto apply_composition(Strategy, Args&&... args) {
|
auto apply_connection(Strategy, Args&&... args) {
|
||||||
using finalizer = composition_finalizer<Strategy>;
|
using finalizer = connection_finalizer<Strategy>;
|
||||||
|
|
||||||
// Freeze every continuable inside the given arguments,
|
// Freeze every continuable inside the given arguments,
|
||||||
// and freeze the ownership if one of the continuables
|
// and freeze the ownership if one of the continuables
|
||||||
@ -195,12 +194,12 @@ auto apply_composition(Strategy, Args&&... args) {
|
|||||||
// Additionally test whether every continuable is acquired.
|
// Additionally test whether every continuable is acquired.
|
||||||
// Also materialize every continuable.
|
// Also materialize every continuable.
|
||||||
util::ownership ownership;
|
util::ownership ownership;
|
||||||
auto composition = map_pack(prepare_continuables{ownership},
|
auto connection = map_pack(prepare_continuables{ownership},
|
||||||
std::make_tuple(std::forward<Args>(args)...));
|
std::make_tuple(std::forward<Args>(args)...));
|
||||||
|
|
||||||
return finalizer::finalize(std::move(composition), std::move(ownership));
|
return finalizer::finalize(std::move(connection), std::move(ownership));
|
||||||
}
|
}
|
||||||
} // namespace composition
|
} // namespace connection
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user