From 9ab9b5e7fb4e86657d4f58080cc07c8977dddd73 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Mon, 12 Mar 2018 08:35:19 +0100 Subject: [PATCH] Rename composition to connection --- include/continuable/continuable-base.hpp | 24 ++++----- .../continuable/continuable-connections.hpp | 20 +++---- .../detail/connection-aggregated.hpp | 8 +-- include/continuable/detail/connection-all.hpp | 32 +++++------ include/continuable/detail/connection-any.hpp | 26 ++++----- include/continuable/detail/connection-seq.hpp | 22 ++++---- include/continuable/detail/connection.hpp | 53 +++++++++---------- 7 files changed, 92 insertions(+), 93 deletions(-) diff --git a/include/continuable/continuable-base.hpp b/include/continuable/continuable-base.hpp index 7b7cba5..e33e12a 100644 --- a/include/continuable/continuable-base.hpp +++ b/include/continuable/continuable-base.hpp @@ -37,14 +37,14 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include -#include #ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE #include @@ -490,8 +490,8 @@ public: /// \since 1.0.0 template auto operator&&(continuable_base&& right) && { - return detail::composition::connect( - detail::composition::composition_strategy_all_tag{}, std::move(*this), + return detail::connection::connect( + detail::connection::connection_strategy_all_tag{}, std::move(*this), std::move(right)); } @@ -528,8 +528,8 @@ public: /// \since 1.0.0 template auto operator||(continuable_base&& right) && { - return detail::composition::connect( - detail::composition::composition_strategy_any_tag{}, std::move(*this), + return detail::connection::connect( + detail::connection::connection_strategy_any_tag{}, std::move(*this), std::move(right)); } @@ -557,8 +557,8 @@ public: /// \since 1.0.0 template auto operator>>(continuable_base&& right) && { - return detail::composition::seq::sequential_connect(std::move(*this), - std::move(right)); + return detail::connection::seq::sequential_connect(std::move(*this), + std::move(right)); } /// Invokes the continuation chain manually even before the @@ -695,7 +695,7 @@ private: } auto materialize() && { - return detail::composition::materializer::apply( + return detail::connection::materializer::apply( std::move(*this)); } diff --git a/include/continuable/continuable-connections.hpp b/include/continuable/continuable-connections.hpp index e35ccb5..c8957c9 100644 --- a/include/continuable/continuable-connections.hpp +++ b/include/continuable/continuable-connections.hpp @@ -36,10 +36,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include namespace cti { @@ -77,8 +77,8 @@ namespace cti { /// \since 1.1.0 template auto when_all(Args&&... args) { - return detail::composition::apply_composition( - detail::composition::composition_strategy_all_tag{}, + return detail::connection::apply_connection( + detail::connection::connection_strategy_all_tag{}, std::forward(args)...); } @@ -146,8 +146,8 @@ auto when_all(Iterator begin, Iterator end) { /// \since 1.1.0 template auto when_seq(Args&&... args) { - return detail::composition::apply_composition( - detail::composition::composition_strategy_seq_tag{}, + return detail::connection::apply_connection( + detail::connection::connection_strategy_seq_tag{}, std::forward(args)...); } @@ -214,8 +214,8 @@ auto when_seq(Iterator begin, Iterator end) { /// \since 1.1.0 template auto when_any(Args&&... args) { - return detail::composition::apply_composition( - detail::composition::composition_strategy_any_tag{}, + return detail::connection::apply_connection( + detail::connection::connection_strategy_any_tag{}, std::forward(args)...); } diff --git a/include/continuable/detail/connection-aggregated.hpp b/include/continuable/detail/connection-aggregated.hpp index a94dbe1..45bda22 100644 --- a/include/continuable/detail/connection-aggregated.hpp +++ b/include/continuable/detail/connection-aggregated.hpp @@ -43,14 +43,14 @@ namespace cti { namespace detail { -namespace composition { +namespace connection { /// This namespace provides utilities for performing compound /// connections between deeply nested continuables and values. /// /// We create the result pack from the provides values and /// the async values if those are default constructible, /// 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 /// - single async value -> single value /// - multiple async value -> tuple of async values. @@ -68,7 +68,7 @@ decltype(auto) unpack_lazy(T&& value) { template T&& unpack_lazy(container::flat_variant&& value) { assert(value.template is() && - "The composition was finalized before all values were present!"); + "The connection was finalized before all values were present!"); return std::move(value.template cast()); } @@ -234,7 +234,7 @@ constexpr auto hint_of_data() { return decltype(finalize_data(detail::hint_mapper{}, std::declval())){}; } } // namespace aggregated -} // namespace composition +} // namespace connection } // namespace detail } // namespace cti diff --git a/include/continuable/detail/connection-all.hpp b/include/continuable/detail/connection-all.hpp index 2c570c6..c80c1c4 100644 --- a/include/continuable/detail/connection-all.hpp +++ b/include/continuable/detail/connection-all.hpp @@ -39,15 +39,15 @@ #include #include -#include -#include +#include +#include #include #include #include namespace cti { namespace detail { -namespace composition { +namespace connection { namespace all { /// Caches the partial results and invokes the callback when all results /// are arrived. This class is thread safe. @@ -100,7 +100,7 @@ class result_submitter template 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. std::call_once(me->flag_, std::move(me->callback_), tag, std::move(error)); @@ -121,7 +121,7 @@ public: } /// 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. void accept() { complete_one(); @@ -145,20 +145,20 @@ struct continuable_dispatcher { }; } // namespace all -struct composition_strategy_all_tag {}; +struct connection_strategy_all_tag {}; template <> -struct is_composition_strategy // ... +struct is_connection_strategy // ... : std::true_type {}; -/// Finalizes the all logic of a given composition +/// Finalizes the all logic of a given connection template <> -struct composition_finalizer { - /// Finalizes the all logic of a given composition - template - static auto finalize(Composition&& composition, util::ownership ownership) { - // Create the target result from the composition +struct connection_finalizer { + /// Finalizes the all logic of a given connection + template + static auto finalize(Connection&& connection, util::ownership ownership) { + // Create the target result from the connection auto result = - aggregated::box_continuables(std::forward(composition)); + aggregated::box_continuables(std::forward(connection)); auto signature = aggregated::hint_of_data(); @@ -179,13 +179,13 @@ struct composition_finalizer { traverse_pack(all::continuable_dispatcher{state}, state->head()); - // Finalize the composition if all results arrived in-place + // Finalize the connection if all results arrived in-place state->accept(); }, signature, std::move(ownership)); } }; -} // namespace composition +} // namespace connection } // namespace detail } // namespace cti diff --git a/include/continuable/detail/connection-any.hpp b/include/continuable/detail/connection-any.hpp index 961346c..0f711d0 100644 --- a/include/continuable/detail/connection-any.hpp +++ b/include/continuable/detail/connection-any.hpp @@ -48,7 +48,7 @@ namespace cti { namespace detail { -namespace composition { +namespace connection { namespace any { /// Invokes the callback with the first arriving result template @@ -160,23 +160,23 @@ struct continuable_dispatcher { }; } // namespace any -struct composition_strategy_any_tag {}; +struct connection_strategy_any_tag {}; template <> -struct is_composition_strategy // ... +struct is_connection_strategy // ... : std::true_type {}; -/// Finalizes the any logic of a given composition +/// Finalizes the any logic of a given connection template <> -struct composition_finalizer { - template - static auto finalize(Composition&& composition, util::ownership ownership) { +struct connection_finalizer { + template + static auto finalize(Connection&& connection, util::ownership ownership) { auto signature = decltype(any::result_deducer::deduce( - traversal::container_category_of_t>{}, - traits::identity>{})){}; + traversal::container_category_of_t>{}, + traits::identity>{})){}; return base::attorney::create( - [composition = - std::forward(composition)](auto&& callback) mutable { + [connection = + std::forward(connection)](auto&& callback) mutable { using submitter_t = any::any_result_submitter>; @@ -187,12 +187,12 @@ struct composition_finalizer { std::forward(callback)); traverse_pack(any::continuable_dispatcher{submitter}, - std::move(composition)); + std::move(connection)); }, signature, std::move(ownership)); } }; -} // namespace composition +} // namespace connection } // namespace detail } // namespace cti diff --git a/include/continuable/detail/connection-seq.hpp b/include/continuable/detail/connection-seq.hpp index f3e782c..72bb2bb 100644 --- a/include/continuable/detail/connection-seq.hpp +++ b/include/continuable/detail/connection-seq.hpp @@ -39,13 +39,13 @@ #include #include -#include +#include #include #include namespace cti { namespace detail { -namespace composition { +namespace connection { namespace seq { /// Connects the left and the right continuable to a sequence /// @@ -126,20 +126,20 @@ public: }; } // namespace seq -struct composition_strategy_seq_tag {}; +struct connection_strategy_seq_tag {}; template <> -struct is_composition_strategy // ... +struct is_connection_strategy // ... : std::true_type {}; -/// Finalizes the seq logic of a given composition +/// Finalizes the seq logic of a given connection template <> -struct composition_finalizer { - /// Finalizes the all logic of a given composition - template - static auto finalize(Composition&& composition, util::ownership ownership) { +struct connection_finalizer { + /// Finalizes the all logic of a given connection + template + static auto finalize(Connection&& connection, util::ownership ownership) { auto result = - aggregated::box_continuables(std::forward(composition)); + aggregated::box_continuables(std::forward(connection)); auto signature = aggregated::hint_of_data(); @@ -161,7 +161,7 @@ struct composition_finalizer { signature, std::move(ownership)); } }; -} // namespace composition +} // namespace connection } // namespace detail } // namespace cti diff --git a/include/continuable/detail/connection.hpp b/include/continuable/detail/connection.hpp index eaabaf3..c0f5af1 100644 --- a/include/continuable/detail/connection.hpp +++ b/include/continuable/detail/connection.hpp @@ -44,17 +44,17 @@ namespace cti { 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. -namespace composition { +namespace connection { template -struct is_composition_strategy // ... +struct is_connection_strategy // ... : std::false_type {}; -/// Adds the given continuation tuple to the left composition +/// Adds the given continuation tuple to the left connection template -auto chain_composition(std::tuple leftPack, - std::tuple rightPack) { +auto chain_connection(std::tuple leftPack, + std::tuple rightPack) { return traits::merge(std::move(leftPack), std::move(rightPack)); } @@ -67,7 +67,7 @@ auto chain_composition(std::tuple leftPack, /// -> make a tuple containing the continuable as only element template < typename Strategy, typename Data, typename Annotation, - std::enable_if_t::value>* = nullptr> + std::enable_if_t::value>* = nullptr> auto normalize(Strategy /*strategy*/, continuable_base&& continuation) { @@ -78,7 +78,7 @@ auto normalize(Strategy /*strategy*/, /// -> materialize it template < typename Strategy, typename Data, typename Annotation, - std::enable_if_t::value>* = nullptr> + std::enable_if_t::value>* = nullptr> auto normalize(Strategy /*strategy*/, continuable_base&& continuation) { @@ -110,8 +110,8 @@ auto connect(Strategy strategy, continuable_base&& left, // Make the new data which consists of a tuple containing // all connected continuables. - auto data = chain_composition(normalize(strategy, std::move(left)), - normalize(strategy, std::move(right))); + auto data = chain_connection(normalize(strategy, std::move(left)), + normalize(strategy, std::move(right))); // Return a new continuable containing the tuple and holding // the current strategy as annotation. @@ -120,21 +120,21 @@ auto connect(Strategy strategy, continuable_base&& left, /// All strategies should specialize this class in order to provide: /// - 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. template -struct composition_finalizer; +struct connection_finalizer; -/// Finalizes the connection logic of a given composition +/// Finalizes the connection logic of a given connection template -auto finalize_composition(continuable_base&& continuation) { - using finalizer = composition_finalizer; +auto finalize_connection(continuable_base&& continuation) { + using finalizer = connection_finalizer; 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 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 @@ -146,12 +146,11 @@ struct materializer { } }; template -struct materializer< - continuable_base, - std::enable_if_t::value>> { +struct materializer, + std::enable_if_t::value>> { static constexpr auto apply(continuable_base&& continuable) { - return finalize_composition(std::move(continuable)); + return finalize_connection(std::move(continuable)); } }; @@ -186,8 +185,8 @@ public: }; template -auto apply_composition(Strategy, Args&&... args) { - using finalizer = composition_finalizer; +auto apply_connection(Strategy, Args&&... args) { + using finalizer = connection_finalizer; // Freeze every continuable inside the given arguments, // 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. // Also materialize every continuable. util::ownership ownership; - auto composition = map_pack(prepare_continuables{ownership}, - std::make_tuple(std::forward(args)...)); + auto connection = map_pack(prepare_continuables{ownership}, + std::make_tuple(std::forward(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 cti