diff --git a/include/asyncpp/core.h b/include/asyncpp/core.h index 60e76d1..1a4db45 100644 --- a/include/asyncpp/core.h +++ b/include/asyncpp/core.h @@ -5,14 +5,3 @@ #include "core/result.h" #include "core/stream.h" #include "core/task.h" - -#include "core/result.inl" -#include "core/stream.inl" - -#include "core/future/map.inl" -#include "core/future/lazy.inl" -#include "core/future/and_then.inl" - -#ifdef asyncpp_timing -#include "core/future/timeout.inl" -#endif diff --git a/include/asyncpp/core/future.h b/include/asyncpp/core/future.h index 50fd9fd..13b1ae8 100644 --- a/include/asyncpp/core/future.h +++ b/include/asyncpp/core/future.h @@ -1,90 +1,11 @@ #pragma once -#include +#include "future/future.h" -#include "misc.h" -#include "result.h" -#include "future.pre.h" +#include "future/map.inl" +#include "future/lazy.inl" +#include "future/and_then.inl" -#include "future/map.h" -#include "future/lazy.h" -#include "future/and_then.h" - -namespace asyncpp -{ - - template< - typename T_value, - typename T_derived> - struct base_future - : public tag_future - { - public: - using value_type = T_value; - using result_type = future_result; - using derived_type = T_derived; - using this_type = base_future; - - public: - /** - * @brief Transform the result of this future. - */ - template< - chaining_mode X_mode = copy, - typename X_lambda> - inline auto map(X_lambda&& p_lambda) &; - - /** - * @brief Transform the result of this future. - */ - template< - chaining_mode X_mode = move, - typename X_lambda> - inline auto map(X_lambda&& p_lambda) &&; - - public: - /** - * @brief Execute the given lambda after the future is finished and - * wait for the future returned by the lambda. - */ - template< - chaining_mode X_mode = copy, - typename X_lambda> - inline auto and_then(X_lambda&& p_lambda) &; - - /** - * @brief Execute the given lambda after the future is finished and - * wait for the future returned by the lambda. - */ - template< - chaining_mode X_mode = move, - typename X_lambda> - inline auto and_then(X_lambda&& p_lambda) &&; - - #ifdef asyncpp_timing - public: - /** - * @brief Throw an execption if the timeout has passed. - * - * This method is only enabled if timer.h is included before. - */ - template< - chaining_mode X_mode = copy, - typename X_base, - typename X_ratio> - inline auto timeout(const duration& p_timeout) &; - - /** - * @brief Throw an execption if the timeout has passed. - * - * This method is only enabled if timer.h is included before. - */ - template< - chaining_mode X_mode = move, - typename X_base, - typename X_ratio> - inline auto timeout(const duration& p_timeout) &&; - #endif - }; - -} +#ifdef asyncpp_timing +#include "future/timeout.inl" +#endif diff --git a/include/asyncpp/core/future/and_then.h b/include/asyncpp/core/future/and_then.h deleted file mode 100644 index e9ed584..0000000 --- a/include/asyncpp/core/future/and_then.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -#include - -#include "../future.pre.h" - -namespace asyncpp { -namespace __future { - - template< - typename T_future, - typename T_lambda> - struct and_then_future final : - public base_future< - decltype(std::declval()(std::declval::value_type>())), - and_then_future - > - { - public: - using lambda_type = T_lambda; - using first_future_type = T_future; - using first_value_type = typename std::decay_t::value_type; - using second_future_type = decltype(std::declval()(std::declval())); - using second_future_type_ptr = std::unique_ptr; - using value_type = typename second_future_type::value_type; - using this_type = and_then_future; - using base_future_type = base_future; - using result_type = typename base_future_type::result_type; - - private: - lambda_type _lambda; - first_future_type _first; - second_future_type_ptr _second; - - public: - /** - * @brief Constructor. - */ - template< - typename X_future, - typename X_lambda> - inline and_then_future( - X_future&& p_outer, - X_lambda&& p_lambda); - - inline and_then_future(and_then_future &&) = default; - inline and_then_future(and_then_future const &) = default; - - public: /* future */ - /** - * @brief Poll the result from the future. - */ - inline result_type poll(); - }; - -} } diff --git a/include/asyncpp/core/future/and_then.inl b/include/asyncpp/core/future/and_then.inl index 2a611a0..ee31a54 100644 --- a/include/asyncpp/core/future/and_then.inl +++ b/include/asyncpp/core/future/and_then.inl @@ -1,50 +1,77 @@ #pragma once -#include "and_then.h" -#include "../future.h" +#include + +#include "future.h" namespace asyncpp { namespace __future { - /* and_then_future */ - template< typename T_future, typename T_lambda> - template< - typename X_future, - typename X_lambda> - and_then_future - ::and_then_future( + struct and_then_future final : + public base_future< + decltype(std::declval()(std::declval::value_type>())), + and_then_future + > + { + public: + using lambda_type = T_lambda; + using first_future_type = T_future; + using first_value_type = typename std::decay_t::value_type; + using second_future_type = decltype(std::declval()(std::declval())); + using second_future_type_ptr = std::unique_ptr; + using value_type = typename second_future_type::value_type; + using this_type = and_then_future; + using base_future_type = base_future; + using result_type = typename base_future_type::result_type; + + private: + lambda_type _lambda; + first_future_type _first; + second_future_type_ptr _second; + + public: + /** + * @brief Constructor. + */ + template< + typename X_future, + typename X_lambda> + inline and_then_future( X_future&& p_first, X_lambda&& p_lambda) - : _first (std::forward(p_first)) - , _lambda(std::forward(p_lambda)) - { } - - template< - typename T_future, - typename T_lambda> - typename and_then_future::result_type - and_then_future - ::poll() - { - while (true) + : _first (std::forward(p_first)) + , _lambda(std::forward(p_lambda)) + { } + + inline and_then_future(and_then_future &&) = default; + inline and_then_future(and_then_future const &) = default; + + public: /* future */ + /** + * @brief Poll the result from the future. + */ + inline result_type poll() { - if (_second) - { - return _second->poll(); - } - else + while (true) { - auto r = _first.poll(); - if (!r) - return result_type::not_ready(); - - _second = std::make_unique(r.call(_lambda)); + if (_second) + { + return _second->poll(); + } + else + { + auto r = _first.poll(); + if (!r) + return result_type::not_ready(); + + _second = std::make_unique(r.call(_lambda)); + } } } - } + }; /* and_then_impl */ @@ -65,10 +92,6 @@ namespace __future { using derived_forward_type = forward_type_t; using and_then_future_type = __future::and_then_future; - static_assert( - X_mode != ref || !std::is_rvalue_reference_v, - "Can not store rvalue reference as lvalue reference!"); - auto& self = static_cast(p_self); return and_then_future_type( @@ -91,7 +114,9 @@ namespace asyncpp typename X_lambda> auto base_future ::and_then(X_lambda&& p_lambda) & - { return __future::and_then_impl(*this, std::forward(p_lambda)); } + { + return __future::and_then_impl(*this, std::forward(p_lambda)); + } template< typename T_value, @@ -101,6 +126,12 @@ namespace asyncpp typename X_lambda> auto base_future ::and_then(X_lambda&& p_lambda) && - { return __future::and_then_impl(std::move(*this), std::forward(p_lambda)); } + { + static_assert( + X_mode != ref, + "Can not store rvalue reference as lvalue reference!"); + + return __future::and_then_impl(std::move(*this), std::forward(p_lambda)); + } } diff --git a/include/asyncpp/core/future/future.h b/include/asyncpp/core/future/future.h new file mode 100644 index 0000000..2862d39 --- /dev/null +++ b/include/asyncpp/core/future/future.h @@ -0,0 +1,92 @@ +#pragma once + +#include + +#include "future.pre.h" +#include "../misc.h" +#include "../result.h" + +namespace asyncpp +{ + + template< + typename T_value, + typename T_derived> + struct base_future + : public tag_future + { + public: + using value_type = T_value; + using result_type = future_result; + using derived_type = T_derived; + using this_type = base_future; + + public: + /** + * @brief Transform the result of this future. + */ + template< + chaining_mode X_mode = copy, + typename X_lambda> + inline auto map(X_lambda&& p_lambda) &; + + /** + * @brief Transform the result of this future. + */ + template< + chaining_mode X_mode = move, + typename X_lambda> + inline auto map(X_lambda&& p_lambda) &&; + + public: + /** + * @brief Execute the given lambda after the future is finished and + * wait for the future returned by the lambda. + */ + template< + chaining_mode X_mode = copy, + typename X_lambda> + inline auto and_then(X_lambda&& p_lambda) &; + + /** + * @brief Execute the given lambda after the future is finished and + * wait for the future returned by the lambda. + */ + template< + chaining_mode X_mode = move, + typename X_lambda> + inline auto and_then(X_lambda&& p_lambda) &&; + + #ifdef asyncpp_timing + public: + /** + * @brief Throw an execption if the timeout has passed. + * + * This method is only enabled if timer.h is included before. + */ + template< + chaining_mode X_mode = copy, + typename X_base, + typename X_ratio> + inline auto timeout(const duration& p_timeout) &; + + /** + * @brief Throw an execption if the timeout has passed. + * + * This method is only enabled if timer.h is included before. + */ + template< + chaining_mode X_mode = move, + typename X_base, + typename X_ratio> + inline auto timeout(const duration& p_timeout) &&; + #endif + }; + + /** + * @brief Create a lazy evaluated future. + */ + template + inline auto lazy(X_lambda&& p_lambda); + +} diff --git a/include/asyncpp/core/future.pre.h b/include/asyncpp/core/future/future.pre.h similarity index 95% rename from include/asyncpp/core/future.pre.h rename to include/asyncpp/core/future/future.pre.h index 8902d35..d1a992d 100644 --- a/include/asyncpp/core/future.pre.h +++ b/include/asyncpp/core/future/future.pre.h @@ -1,7 +1,5 @@ #pragma once -#include "misc.h" - namespace asyncpp { diff --git a/include/asyncpp/core/future/lazy.h b/include/asyncpp/core/future/lazy.h deleted file mode 100644 index ca50eab..0000000 --- a/include/asyncpp/core/future/lazy.h +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -#include "../future.pre.h" - -namespace asyncpp -{ - - namespace __future - { - - template - struct lazy_future final : - public base_future< - decltype(std::declval()()), - lazy_future - > - { - public: - using lambda_type = T_lambda; - using value_type = decltype(std::declval()()); - using this_type = lazy_future; - using base_future_type = base_future; - using result_type = typename base_future_type::result_type; - - private: - lambda_type _lambda; - - public: - /** - * @brief Constructor. - */ - template - inline lazy_future( - X_lambda&& p_lambda); - - inline lazy_future(lazy_future &&) = default; - inline lazy_future(lazy_future const &) = default; - - public: /* future */ - /** - * @brief Poll the result from the future. - */ - template - inline auto poll() - -> std::enable_if_t< - std::is_void_v, - result_type>; - - /** - * @brief Poll the result from the future. - */ - template - inline auto poll() - -> std::enable_if_t< - !std::is_void_v, - result_type>; - }; - - } - - /** - * @brief Create a lazy evaluated future. - */ - template - inline auto lazy(X_lambda&& p_lambda); - -} diff --git a/include/asyncpp/core/future/lazy.inl b/include/asyncpp/core/future/lazy.inl index 4747e67..8d984b5 100644 --- a/include/asyncpp/core/future/lazy.inl +++ b/include/asyncpp/core/future/lazy.inl @@ -1,45 +1,71 @@ #pragma once -#include "lazy.h" +#include "future.h" -namespace asyncpp -{ +namespace asyncpp { +namespace __future { - namespace __future + template + struct lazy_future final : + public base_future< + decltype(std::declval()()), + lazy_future + > { + public: + using lambda_type = T_lambda; + using value_type = decltype(std::declval()()); + using this_type = lazy_future; + using base_future_type = base_future; + using result_type = typename base_future_type::result_type; - /* lazy_future */ + private: + lambda_type _lambda; - template + public: + /** + * @brief Constructor. + */ template - lazy_future::lazy_future( + inline lazy_future( X_lambda&& p_lambda) : _lambda(std::forward(p_lambda)) { } - template - template - inline auto lazy_future - ::poll() - -> std::enable_if_t< - std::is_void_v, - result_type> + inline lazy_future(lazy_future &&) = default; + inline lazy_future(lazy_future const &) = default; + + public: /* future */ + /** + * @brief Poll the result from the future. + */ + template + inline auto poll() + -> std::enable_if_t< + std::is_void_v, + result_type> { _lambda(); return result_type::ready(); } - template - template - inline auto lazy_future - ::poll() - -> std::enable_if_t< - !std::is_void_v, - result_type> + /** + * @brief Poll the result from the future. + */ + template + inline auto poll() + -> std::enable_if_t< + !std::is_void_v, + result_type> { return result_type::ready(_lambda()); } - } + }; + +} } + +namespace asyncpp +{ template inline auto lazy(X_lambda&& p_lambda) diff --git a/include/asyncpp/core/future/map.h b/include/asyncpp/core/future/map.h deleted file mode 100644 index 9a72f97..0000000 --- a/include/asyncpp/core/future/map.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "../future.pre.h" - -namespace asyncpp { -namespace __future { - - template< - typename T_future, - typename T_lambda> - struct map_future final : - public base_future< - typename std::decay_t::value_type, - map_future - > - { - public: - using future_type = T_future; - using lambda_type = T_lambda; - using future_value_type = typename std::decay_t::value_type; - using value_type = decltype(std::declval()(std::declval())); - using this_type = map_future; - using base_future_type = base_future; - using result_type = typename base_future_type::result_type; - - private: - future_type _future; - lambda_type _lambda; - - public: - /** - * @brief Constructor. - */ - template< - typename X_future, - typename X_lambda> - inline map_future( - X_future&& p_future, - X_lambda&& p_lambda); - - inline map_future(map_future &&) = default; - inline map_future(map_future const &) = default; - - public: /* future */ - /** - * @brief Poll the result from the future. - */ - inline result_type poll(); - }; - -} } diff --git a/include/asyncpp/core/future/map.inl b/include/asyncpp/core/future/map.inl index 9e67dd0..78b372f 100644 --- a/include/asyncpp/core/future/map.inl +++ b/include/asyncpp/core/future/map.inl @@ -1,38 +1,61 @@ #pragma once -#include "map.h" +#include "future.h" namespace asyncpp { namespace __future { - /* map_future */ - template< typename T_future, typename T_lambda> - template< - typename X_future, - typename X_lambda> - map_future - ::map_future( + struct map_future final : + public base_future< + typename std::decay_t::value_type, + map_future + > + { + public: + using future_type = T_future; + using lambda_type = T_lambda; + using future_value_type = typename std::decay_t::value_type; + using value_type = decltype(std::declval()(std::declval())); + using this_type = map_future; + using base_future_type = base_future; + using result_type = typename base_future_type::result_type; + + private: + future_type _future; + lambda_type _lambda; + + public: + /** + * @brief Constructor. + */ + template< + typename X_future, + typename X_lambda> + inline map_future( X_future&& p_future, X_lambda&& p_lambda) - : _future(std::forward(p_future)) - , _lambda(std::forward(p_lambda)) - { } - - template< - typename T_future, - typename T_lambda> - typename map_future::result_type - map_future - ::poll() - { - auto r = _future.poll(); - return r - ? result_type::ready(r.call(_lambda)) - : result_type::not_ready(); - } + : _future(std::forward(p_future)) + , _lambda(std::forward(p_lambda)) + { } + + inline map_future(map_future &&) = default; + inline map_future(map_future const &) = default; + + public: /* future */ + /** + * @brief Poll the result from the future. + */ + inline result_type poll() + { + auto r = _future.poll(); + return r + ? result_type::ready(r.call(_lambda)) + : result_type::not_ready(); + } + }; /* map_impl */ @@ -53,10 +76,6 @@ namespace __future { using derived_forward_type = forward_type_t; using map_future_type = __future::map_future; - static_assert( - X_mode != ref || !std::is_rvalue_reference_v, - "Can not store rvalue reference as lvalue reference!"); - auto& self = static_cast(p_self); return map_future_type( @@ -79,7 +98,9 @@ namespace asyncpp typename X_lambda> auto base_future ::map(X_lambda&& p_lambda) & - { return __future::map_impl(*this, std::forward(p_lambda)); } + { + return __future::map_impl(*this, std::forward(p_lambda)); + } template< typename T_value, @@ -89,6 +110,12 @@ namespace asyncpp typename X_lambda> auto base_future ::map(X_lambda&& p_lambda) && - { return __future::map_impl(std::move(*this), std::forward(p_lambda)); } + { + static_assert( + X_mode != ref, + "Can not store rvalue reference as lvalue reference!"); + + return __future::map_impl(std::move(*this), std::forward(p_lambda)); + } } diff --git a/include/asyncpp/core/future/timeout.inl b/include/asyncpp/core/future/timeout.inl index b324da5..d9a72ad 100644 --- a/include/asyncpp/core/future/timeout.inl +++ b/include/asyncpp/core/future/timeout.inl @@ -1,6 +1,6 @@ #pragma once -#include "../future.h" +#include "future.h" namespace asyncpp { namespace __future { @@ -10,7 +10,7 @@ namespace __future { typename X_self, typename X_base, typename X_ratio> - auto helper_timeout( + auto timeout_impl( X_self&& p_self, const duration& p_timeout) { @@ -22,7 +22,7 @@ namespace __future { derived_type const &, derived_type &>; using derived_forward_type = forward_type_t; - using timeout_type = timing::timeout; + using timeout_type = asyncpp::timing::timeout; auto& self = static_cast(p_self); @@ -47,7 +47,9 @@ namespace asyncpp typename X_ratio> auto base_future ::timeout(const duration& p_timeout) & - { return __future::helper_timeout(*this, p_timeout); } + { + return __future::timeout_impl(*this, p_timeout); + } template< typename T_value, @@ -58,6 +60,12 @@ namespace asyncpp typename X_ratio> auto base_future ::timeout(const duration& p_timeout) && - { return __future::helper_timeout(std::move(*this), p_timeout); } + { + static_assert( + X_mode != ref, + "Can not store rvalue reference as lvalue reference!"); + + return __future::timeout_impl(std::move(*this), p_timeout); + } } diff --git a/include/asyncpp/core/result.h b/include/asyncpp/core/result.h index 330aec2..bae1570 100644 --- a/include/asyncpp/core/result.h +++ b/include/asyncpp/core/result.h @@ -1,139 +1,5 @@ #pragma once -#include +#include "result/result.h" -#include "result.pre.h" - -namespace asyncpp -{ - - namespace __impl - { - - struct result_not_ready - { }; - - struct result_done - { }; - - template - struct result_ready - { - using value_type = T_value; - - value_type value; - - template - inline result_ready(T_args&&... p_args); - }; - - template - struct result - { - public: - using value_type = T_value; - using not_ready_type = result_not_ready; - using ready_type = result_ready; - using done_type = result_done; - using storage_type = std::conditional_t< - for_stream, - std::variant, - std::variant>; - using clean_value_type = std::remove_reference_t; - using pointer_type = clean_value_type*; - using reference_type = clean_value_type&; - using const_pointer_type = clean_value_type const *; - using const_reference_type = clean_value_type const &; - - private: - storage_type _storage; //!< Stores the actual result. - - private: - /** - * @brief Constructor. - */ - inline result(storage_type&& p_storage); - - public: - /** - * @brief returns a result that is not ready. - */ - static inline auto& not_ready(); - - /** - * @brief returns a result that is not ready. - */ - template - static inline auto ready(X_args&&... p_args); - - /** - * @brief returns a result that is not ready. - */ - template< - bool X = for_stream, - typename = std::enable_if_t> - static inline auto& done(); - - public: - /** - * @brief Get the status of the result. - */ - template< - bool X = for_stream, - typename = std::enable_if_t> - inline result_status status() const; - - /** - * @brief Check if the result is not ready (is pending). - */ - inline bool is_not_ready() const; - - /** - * @brief Check if the result is ready (has a value). - */ - inline bool is_ready() const; - - /** - * @brief Check if the result is done (stream is finished). - */ - template< - bool X = for_stream, - typename = std::enable_if_t> - inline bool is_done() const; - - /** - * @brief Get the value of the result. - */ - inline reference_type value(); - - /** - * @brief Get the value of the result. - */ - inline const_reference_type value() const; - - /** - * @brief Call the passed closure with the value stored in the result. - */ - template - inline auto call(const X_lambda& p_lambda); - - /** - * @brief Call the passed closure with the value stored in the result. - */ - template - inline auto call(const X_lambda& p_lambda) const; - - public: - inline operator bool() const; - inline pointer_type operator-> (); - inline reference_type operator* (); - inline const_pointer_type operator-> () const; - inline const_reference_type operator* () const; - }; - - template - struct result; - - } - -} +#include "result/result.inl" diff --git a/include/asyncpp/core/result/result.h b/include/asyncpp/core/result/result.h new file mode 100644 index 0000000..330aec2 --- /dev/null +++ b/include/asyncpp/core/result/result.h @@ -0,0 +1,139 @@ +#pragma once + +#include + +#include "result.pre.h" + +namespace asyncpp +{ + + namespace __impl + { + + struct result_not_ready + { }; + + struct result_done + { }; + + template + struct result_ready + { + using value_type = T_value; + + value_type value; + + template + inline result_ready(T_args&&... p_args); + }; + + template + struct result + { + public: + using value_type = T_value; + using not_ready_type = result_not_ready; + using ready_type = result_ready; + using done_type = result_done; + using storage_type = std::conditional_t< + for_stream, + std::variant, + std::variant>; + using clean_value_type = std::remove_reference_t; + using pointer_type = clean_value_type*; + using reference_type = clean_value_type&; + using const_pointer_type = clean_value_type const *; + using const_reference_type = clean_value_type const &; + + private: + storage_type _storage; //!< Stores the actual result. + + private: + /** + * @brief Constructor. + */ + inline result(storage_type&& p_storage); + + public: + /** + * @brief returns a result that is not ready. + */ + static inline auto& not_ready(); + + /** + * @brief returns a result that is not ready. + */ + template + static inline auto ready(X_args&&... p_args); + + /** + * @brief returns a result that is not ready. + */ + template< + bool X = for_stream, + typename = std::enable_if_t> + static inline auto& done(); + + public: + /** + * @brief Get the status of the result. + */ + template< + bool X = for_stream, + typename = std::enable_if_t> + inline result_status status() const; + + /** + * @brief Check if the result is not ready (is pending). + */ + inline bool is_not_ready() const; + + /** + * @brief Check if the result is ready (has a value). + */ + inline bool is_ready() const; + + /** + * @brief Check if the result is done (stream is finished). + */ + template< + bool X = for_stream, + typename = std::enable_if_t> + inline bool is_done() const; + + /** + * @brief Get the value of the result. + */ + inline reference_type value(); + + /** + * @brief Get the value of the result. + */ + inline const_reference_type value() const; + + /** + * @brief Call the passed closure with the value stored in the result. + */ + template + inline auto call(const X_lambda& p_lambda); + + /** + * @brief Call the passed closure with the value stored in the result. + */ + template + inline auto call(const X_lambda& p_lambda) const; + + public: + inline operator bool() const; + inline pointer_type operator-> (); + inline reference_type operator* (); + inline const_pointer_type operator-> () const; + inline const_reference_type operator* () const; + }; + + template + struct result; + + } + +} diff --git a/include/asyncpp/core/result.inl b/include/asyncpp/core/result/result.inl similarity index 100% rename from include/asyncpp/core/result.inl rename to include/asyncpp/core/result/result.inl diff --git a/include/asyncpp/core/result.pre.h b/include/asyncpp/core/result/result.pre.h similarity index 100% rename from include/asyncpp/core/result.pre.h rename to include/asyncpp/core/result/result.pre.h diff --git a/include/asyncpp/core/stream.h b/include/asyncpp/core/stream.h index 8271f14..f70b0c4 100644 --- a/include/asyncpp/core/stream.h +++ b/include/asyncpp/core/stream.h @@ -1,114 +1,11 @@ #pragma once -#include +#include "stream/stream.h" -#include "result.h" -#include "stream.pre.h" +#include "stream/map.inl" +#include "stream/flatten.inl" +#include "stream/for_each.inl" -namespace asyncpp -{ - - template< - typename T_value, - typename T_derived> - struct base_stream - : public tag_stream - { - public: - using value_type = T_value; - using result_type = stream_result; - using derived_type = T_derived; - using this_type = base_stream; - - public: - /** - * @brief Execute the given lambda for each element in the stream. - * - * @return Returns a future that completes once the stream is finished. - */ - template - inline auto for_each(X_lambda&& p_lambda) const &; - - /** - * @brief Execute the given lambda for each element in the stream. - * - * @return Returns a future that completes once the stream is finished. - */ - template - inline auto for_each(X_lambda&& p_lambda) &; - - /** - * @brief Execute the given lambda for each element in the stream. - * - * @return Returns a future that completes once the stream is finished. - */ - template - inline auto for_each(X_lambda&& p_lambda) &&; - - public: - /** - * @brief Transforms the stream from one type to another type - * by executing the passed lambda for each value. - */ - template - inline auto map(X_lambda&& p_lambda) const &; - - /** - * @brief Transforms the stream from one type to another type - * by executing the passed lambda for each value. - */ - template - inline auto map(X_lambda&& p_lambda) &; - - /** - * @brief Transforms the stream from one type to another type - * by executing the passed lambda for each value. - */ - template - inline auto map(X_lambda&& p_lambda) &&; - - public: - /** - * @brief Flatten the stream of streams to a single stream. - */ - inline auto flatten() const &; - - /** - * @brief Flatten the stream of streams to a single stream. - */ - inline auto flatten() &; - - /** - * @brief Flatten the stream of streams to a single stream. - */ - inline auto flatten() &&; - - #ifdef asyncpp_timing - public: - /** - * @brief Throw an execption if the timeout has passed. - * - * This method is only enabled if timer.h is included before. - */ - template - inline auto timeout(const duration& p_timeout) const &; - - /** - * @brief Throw an execption if the timeout has passed. - * - * This method is only enabled if timer.h is included before. - */ - template - inline auto timeout(const duration& p_timeout) &; - - /** - * @brief Throw an execption if the timeout has passed. - * - * This method is only enabled if timer.h is included before. - */ - template - inline auto timeout(const duration& p_timeout) &&; - #endif - }; - -} +#ifdef asyncpp_timing +#include "stream/timeout.inl" +#endif diff --git a/include/asyncpp/core/stream.inl b/include/asyncpp/core/stream.inl deleted file mode 100644 index 17996e9..0000000 --- a/include/asyncpp/core/stream.inl +++ /dev/null @@ -1,230 +0,0 @@ -#pragma once - -#include "stream.h" - -#include "stream/map.inl" -#include "stream/flatten.inl" -#include "stream/for_each.inl" - -#ifdef asyncpp_timing -#include -#endif - -namespace asyncpp -{ - - /* base_stream::for_each */ - - template< - typename T_value, - typename T_derived> - template< - typename X_lambda> - auto base_stream - ::for_each(X_lambda&& p_lambda) const & - { - using lambda_type = X_lambda; - using for_each_type = __stream::for_each_impl; - - auto& self = static_cast(*this); - - return for_each_type( - std::forward(self), - std::forward(p_lambda)); - } - - template< - typename T_value, - typename T_derived> - template< - typename X_lambda> - auto base_stream - ::for_each(X_lambda&& p_lambda) & - { - using lambda_type = X_lambda; - using for_each_type = __stream::for_each_impl; - - auto& self = static_cast(*this); - - return for_each_type( - std::forward(self), - std::forward(p_lambda)); - } - - template< - typename T_value, - typename T_derived> - template< - typename X_lambda> - auto base_stream - ::for_each(X_lambda&& p_lambda) && - { - using lambda_type = X_lambda; - using for_each_type = __stream::for_each_impl; - - auto& self = static_cast(*this); - - return for_each_type( - std::forward(self), - std::forward(p_lambda)); - } - - /* base_stream::map */ - - template< - typename T_value, - typename T_derived> - template< - typename X_lambda> - auto base_stream - ::map(X_lambda&& p_lambda) const & - { - using lambda_type = X_lambda; - using map_type = __stream::map_future; - - auto& self = static_cast(*this); - - return map_type( - std::forward(self), - std::forward(p_lambda)); - } - - template< - typename T_value, - typename T_derived> - template< - typename X_lambda> - auto base_stream - ::map(X_lambda&& p_lambda) & - { - using lambda_type = X_lambda; - using map_type = __stream::map_future; - - auto& self = static_cast(*this); - - return map_type( - std::forward(self), - std::forward(p_lambda)); - } - - template< - typename T_value, - typename T_derived> - template< - typename X_lambda> - auto base_stream - ::map(X_lambda&& p_lambda) && - { - using lambda_type = X_lambda; - using map_type = __stream::map_future; - - auto& self = static_cast(*this); - - return map_type( - std::forward(self), - std::forward(p_lambda)); - } - - /* base_stream::flatten */ - - template< - typename T_value, - typename T_derived> - auto base_stream - ::flatten() const & - { - using flatten_type = __stream::flatten_impl; - - auto& self = static_cast(*this); - - return flatten_type( - std::forward(self)); - } - - template< - typename T_value, - typename T_derived> - auto base_stream - ::flatten() & - { - using flatten_type = __stream::flatten_impl; - - auto& self = static_cast(*this); - - return flatten_type( - std::forward(self)); - } - - template< - typename T_value, - typename T_derived> - auto base_stream - ::flatten() && - { - using flatten_type = __stream::flatten_impl; - - auto& self = static_cast(*this); - - return flatten_type( - std::forward(self)); - } - - /* base_stream::timeout */ - - #ifdef asyncpp_timing - template< - typename T_value, - typename T_derived> - template< - typename X_base, - typename X_ratio> - auto base_stream - ::timeout(const duration& p_timeout) const & - { - using timeout_type = timing::timeout; - - auto& self = static_cast(*this); - - return timeout_type( - std::forward(self), - p_timeout); - } - - template< - typename T_value, - typename T_derived> - template< - typename X_base, - typename X_ratio> - auto base_stream - ::timeout(const duration& p_timeout) & - { - using timeout_type = timing::timeout; - - auto& self = static_cast(*this); - - return timeout_type( - std::forward(self), - p_timeout); - } - - template< - typename T_value, - typename T_derived> - template< - typename X_base, - typename X_ratio> - auto base_stream - ::timeout(const duration& p_timeout) && - { - using timeout_type = timing::timeout; - - auto& self = static_cast(*this); - - return timeout_type( - std::forward(self), - p_timeout); - } - #endif - -} diff --git a/include/asyncpp/core/stream/flatten.h b/include/asyncpp/core/stream/flatten.h deleted file mode 100644 index 9c61190..0000000 --- a/include/asyncpp/core/stream/flatten.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include - -#include - -namespace asyncpp { -namespace __stream { - - template< - typename T_stream> - struct flatten_impl final : - public base_stream< - typename T_stream::value_type::value_type, - flatten_impl - > - { - public: - using stream_type = T_stream; - using inner_stream_type = typename stream_type::value_type; - using inner_stream_ptr_u = std::unique_ptr; - using value_type = typename inner_stream_type::value_type; - using this_type = flatten_impl; - using base_stream_type = base_stream; - using result_type = typename base_stream_type::result_type; - - private: - stream_type _stream; - inner_stream_ptr_u _inner; - - public: - /** - * @brief Constructor. - */ - template< - typename X_stream> - inline flatten_impl( - X_stream&& p_stream); - - public: /* future */ - /** - * @brief Poll the result from the future. - */ - inline result_type poll(); - }; - -} } diff --git a/include/asyncpp/core/stream/flatten.inl b/include/asyncpp/core/stream/flatten.inl index aa1b6d5..13eb428 100644 --- a/include/asyncpp/core/stream/flatten.inl +++ b/include/asyncpp/core/stream/flatten.inl @@ -1,49 +1,130 @@ #pragma once -#include "flatten.h" +#include + +#include "stream.h" namespace asyncpp { namespace __stream { - /* flatten_impl */ - template< typename T_stream> - template< - typename X_stream> - flatten_impl::flatten_impl( - X_stream&& p_stream) - : _stream (std::forward(p_stream)) - , _inner () - { } - - template< - typename T_stream> - typename flatten_impl::result_type - flatten_impl - ::poll() + struct flatten_stream final : + public base_stream< + typename T_stream::value_type::value_type, + flatten_stream + > { - while (true) + public: + using stream_type = T_stream; + using inner_stream_type = typename stream_type::value_type; + using inner_stream_ptr_u = std::unique_ptr; + using value_type = typename inner_stream_type::value_type; + using this_type = flatten_stream; + using base_stream_type = base_stream; + using result_type = typename base_stream_type::result_type; + + private: + stream_type _stream; + inner_stream_ptr_u _inner; + + public: + /** + * @brief Constructor. + */ + template< + typename X_stream> + inline flatten_stream( + X_stream&& p_stream) + : _stream (std::forward(p_stream)) + , _inner () + { } + + inline flatten_stream(flatten_stream &&) = default; + inline flatten_stream(flatten_stream const &) = default; + + public: /* future */ + /** + * @brief Poll the result from the future. + */ + inline result_type poll() { - if (_inner) + while (true) { - auto r = _inner->poll(); + if (_inner) + { + auto r = _inner->poll(); - if (!r.is_done()) - return r; + if (!r.is_done()) + return r; - _inner.reset(); - } + _inner.reset(); + } - auto r = _stream.poll(); - if (r.is_done()) - return result_type::done(); + auto r = _stream.poll(); + if (r.is_done()) + return result_type::done(); - if (r.is_not_ready()) - return result_type::not_ready(); + if (r.is_not_ready()) + return result_type::not_ready(); - _inner = std::make_unique(std::move(*r)); + _inner = std::make_unique(std::move(*r)); + } } + }; + + /* flatten_impl */ + + template< + chaining_mode X_mode, + typename X_self> + auto map_impl(X_self&& p_self) + { + using self_type = X_self; + using derived_type = typename std::decay_t::derived_type; + using derived_storage_type = storage_type_t; + using derived_ref_type = std::conditional_t< + std::is_const_v>, + derived_type const &, + derived_type &>; + using derived_forward_type = forward_type_t; + using flatten_stream_type = __stream::flatten_stream; + + auto& self = static_cast(p_self); + + return flatten_stream_type( + std::forward(self)); } } } + +namespace asyncpp +{ + + template< + typename T_value, + typename T_derived> + template< + chaining_mode X_mode> + auto base_stream + ::flatten() & + { + return __stream::map_impl(*this); + } + + template< + typename T_value, + typename T_derived> + template< + chaining_mode X_mode> + auto base_stream + ::flatten() && + { + static_assert( + X_mode != ref, + "Can not store rvalue reference as lvalue reference!"); + + return __stream::map_impl(std::move(*this)); + } + +} diff --git a/include/asyncpp/core/stream/for_each.h b/include/asyncpp/core/stream/for_each.h deleted file mode 100644 index d31265e..0000000 --- a/include/asyncpp/core/stream/for_each.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include - -namespace asyncpp { -namespace __stream { - - template< - typename T_stream, - typename T_lambda> - struct for_each_impl final : - public base_future< - void, - for_each_impl - > - { - public: - using stream_type = T_stream; - using lambda_type = T_lambda; - using value_type = void; - using this_type = for_each_impl; - using base_future_type = base_future; - using result_type = typename base_future_type::result_type; - - private: - stream_type _stream; - lambda_type _lambda; - - public: - /** - * @brief Constructor. - */ - template< - typename X_stream, - typename X_lambda> - inline for_each_impl( - X_stream&& p_stream, - X_lambda&& p_lambda); - - public: /* future */ - /** - * @brief Poll the result from the future. - */ - inline result_type poll(); - }; - -} } diff --git a/include/asyncpp/core/stream/for_each.inl b/include/asyncpp/core/stream/for_each.inl index d4e2900..21e23d1 100644 --- a/include/asyncpp/core/stream/for_each.inl +++ b/include/asyncpp/core/stream/for_each.inl @@ -1,44 +1,123 @@ #pragma once -#include "for_each.h" +#include "stream.h" namespace asyncpp { namespace __stream { - /* for_each_impl */ - template< typename T_stream, typename T_lambda> - template< - typename X_stream, - typename X_lambda> - for_each_impl - ::for_each_impl( + struct for_each_future final : + public base_future< + void, + for_each_future + > + { + public: + using stream_type = T_stream; + using lambda_type = T_lambda; + using value_type = void; + using this_type = for_each_future; + using base_future_type = base_future; + using result_type = typename base_future_type::result_type; + + private: + stream_type _stream; + lambda_type _lambda; + + public: + /** + * @brief Constructor. + */ + template< + typename X_stream, + typename X_lambda> + inline for_each_future( X_stream&& p_stream, X_lambda&& p_lambda) - : _stream(std::forward(p_stream)) - , _lambda(std::forward(p_lambda)) - { } + : _stream(std::forward(p_stream)) + , _lambda(std::forward(p_lambda)) + { } - template< - typename T_stream, - typename T_lambda> - typename for_each_impl::result_type - for_each_impl - ::poll() - { - while (true) + inline for_each_future(for_each_future &&) = default; + inline for_each_future(for_each_future const &) = default; + + public: /* future */ + /** + * @brief Poll the result from the future. + */ + inline result_type poll() { - auto r = _stream.poll(); - if (r.is_done()) - return result_type::ready(); + while (true) + { + auto r = _stream.poll(); + if (r.is_done()) + return result_type::ready(); - if (r.is_not_ready()) - return result_type::not_ready(); + if (r.is_not_ready()) + return result_type::not_ready(); - r.call(_lambda); + r.call(_lambda); + } } + }; + + template< + chaining_mode X_mode, + typename X_self, + typename X_lambda> + auto for_each_impl(X_self&& p_self, X_lambda&& p_lambda) + { + using self_type = X_self; + using lambda_type = X_lambda; + using derived_type = typename std::decay_t::derived_type; + using derived_storage_type = storage_type_t; + using derived_ref_type = std::conditional_t< + std::is_const_v>, + derived_type const &, + derived_type &>; + using derived_forward_type = forward_type_t; + using for_each_future_type = __stream::for_each_future; + + auto& self = static_cast(p_self); + + return for_each_future_type( + std::forward(self), + std::forward(p_lambda)); } } } + +namespace asyncpp +{ + + template< + typename T_value, + typename T_derived> + template< + chaining_mode X_mode, + typename X_lambda> + auto base_stream + ::for_each(X_lambda&& p_lambda) & + { + return __stream::for_each_impl(*this, std::forward(p_lambda)); + } + + template< + typename T_value, + typename T_derived> + template< + chaining_mode X_mode, + typename X_lambda> + auto base_stream + ::for_each(X_lambda&& p_lambda) && + { + static_assert( + X_mode != ref, + "Can not store rvalue reference as lvalue reference!"); + + return __stream::for_each_impl(std::move(*this), std::forward(p_lambda)); + } + +} diff --git a/include/asyncpp/core/stream/map.h b/include/asyncpp/core/stream/map.h deleted file mode 100644 index ab69f49..0000000 --- a/include/asyncpp/core/stream/map.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include - -namespace asyncpp { -namespace __stream { - - template< - typename T_stream, - typename T_lambda> - struct map_future final : - public base_stream< - decltype(std::declval()(std::declval())), - map_future - > - { - public: - using stream_type = T_stream; - using lambda_type = T_lambda; - using inner_value_type = typename stream_type::value_type; - using value_type = decltype(std::declval()(std::declval())); - using this_type = map_future; - using base_stream_type = base_stream; - using result_type = typename base_stream_type::result_type; - - private: - stream_type _stream; - lambda_type _lambda; - - public: - /** - * @brief Constructor. - */ - template< - typename X_stream, - typename X_lambda> - inline map_future( - X_stream&& p_stream, - X_lambda&& p_lambda); - - public: /* future */ - /** - * @brief Poll the result from the future. - */ - inline result_type poll(); - }; - -} } diff --git a/include/asyncpp/core/stream/map.inl b/include/asyncpp/core/stream/map.inl index c39e3c5..02f61b5 100644 --- a/include/asyncpp/core/stream/map.inl +++ b/include/asyncpp/core/stream/map.inl @@ -1,40 +1,121 @@ #pragma once -#include "map.h" +#include "stream.h" namespace asyncpp { namespace __stream { - /* map_future */ - template< typename T_stream, typename T_lambda> + struct map_stream final : + public base_stream< + decltype(std::declval()(std::declval())), + map_stream + > + { + public: + using stream_type = T_stream; + using lambda_type = T_lambda; + using inner_value_type = typename stream_type::value_type; + using value_type = decltype(std::declval()(std::declval())); + using this_type = map_stream; + using base_stream_type = base_stream; + using result_type = typename base_stream_type::result_type; + + private: + stream_type _stream; + lambda_type _lambda; + + public: + /** + * @brief Constructor. + */ + template< + typename X_stream, + typename X_lambda> + inline map_stream( + X_stream&& p_stream, + X_lambda&& p_lambda) + : _stream(std::forward(p_stream)) + , _lambda(std::forward(p_lambda)) + { } + + inline map_stream(map_stream &&) = default; + inline map_stream(map_stream const &) = default; + + public: /* future */ + /** + * @brief Poll the result from the future. + */ + inline result_type poll() + { + auto r = _stream.poll(); + if (r.is_done()) + return result_type::done(); + + if (r.is_ready()) + return result_type::ready(r.call(_lambda)); + + return result_type::not_ready(); + } + }; + template< - typename X_stream, + chaining_mode X_mode, + typename X_self, typename X_lambda> - map_future::map_future( - X_stream&& p_stream, - X_lambda&& p_lambda) - : _stream(std::forward(p_stream)) - , _lambda(std::forward(p_lambda)) - { } + auto map_impl(X_self&& p_self, X_lambda&& p_lambda) + { + using self_type = X_self; + using lambda_type = X_lambda; + using derived_type = typename std::decay_t::derived_type; + using derived_storage_type = storage_type_t; + using derived_ref_type = std::conditional_t< + std::is_const_v>, + derived_type const &, + derived_type &>; + using derived_forward_type = forward_type_t; + using map_stream_type = __stream::map_stream; + + auto& self = static_cast(p_self); + + return map_stream_type( + std::forward(self), + std::forward(p_lambda)); + } + +} } + +namespace asyncpp +{ template< - typename T_stream, - typename T_lambda> - typename map_future::result_type - map_future - ::poll() + typename T_value, + typename T_derived> + template< + chaining_mode X_mode, + typename X_lambda> + auto base_stream + ::map(X_lambda&& p_lambda) & { - auto r = _stream.poll(); - if (r.is_done()) - return result_type::done(); + return __stream::map_impl(*this, std::forward(p_lambda)); + } - if (r.is_ready()) - return result_type::ready(r.call(_lambda)); + template< + typename T_value, + typename T_derived> + template< + chaining_mode X_mode, + typename X_lambda> + auto base_stream + ::map(X_lambda&& p_lambda) && + { + static_assert( + X_mode != ref, + "Can not store rvalue reference as lvalue reference!"); - return result_type::not_ready(); + return __stream::map_impl(std::move(*this), std::forward(p_lambda)); } -} } +} diff --git a/include/asyncpp/core/stream/stream.h b/include/asyncpp/core/stream/stream.h new file mode 100644 index 0000000..038e98d --- /dev/null +++ b/include/asyncpp/core/stream/stream.h @@ -0,0 +1,104 @@ +#pragma once + +#include + +#include "stream.pre.h" +#include "../result.h" + +namespace asyncpp +{ + + template< + typename T_value, + typename T_derived> + struct base_stream + : public tag_stream + { + public: + using value_type = T_value; + using result_type = stream_result; + using derived_type = T_derived; + using this_type = base_stream; + + public: + /** + * @brief Execute the given lambda for each element in the stream. + * + * @return Returns a future that completes once the stream is finished. + */ + template< + chaining_mode X_mode = copy, + typename X_lambda> + inline auto for_each(X_lambda&& p_lambda) &; + + /** + * @brief Execute the given lambda for each element in the stream. + * + * @return Returns a future that completes once the stream is finished. + */ + template< + chaining_mode X_mode = move, + typename X_lambda> + inline auto for_each(X_lambda&& p_lambda) &&; + + public: + /** + * @brief Transforms the stream from one type to another type + * by executing the passed lambda for each value. + */ + template< + chaining_mode X_mode = copy, + typename X_lambda> + inline auto map(X_lambda&& p_lambda) &; + + /** + * @brief Transforms the stream from one type to another type + * by executing the passed lambda for each value. + */ + template< + chaining_mode X_mode = move, + typename X_lambda> + inline auto map(X_lambda&& p_lambda) &&; + + public: + /** + * @brief Flatten the stream of streams to a single stream. + */ + template< + chaining_mode X_mode = copy> + inline auto flatten() &; + + /** + * @brief Flatten the stream of streams to a single stream. + */ + template< + chaining_mode X_mode = move> + inline auto flatten() &&; + + #ifdef asyncpp_timing + public: + /** + * @brief Throw an execption if the timeout has passed. + * + * This method is only enabled if timer.h is included before. + */ + template< + chaining_mode X_mode = copy, + typename X_base, + typename X_ratio> + inline auto timeout(const duration& p_timeout) &; + + /** + * @brief Throw an execption if the timeout has passed. + * + * This method is only enabled if timer.h is included before. + */ + template< + chaining_mode X_mode = move, + typename X_base, + typename X_ratio> + inline auto timeout(const duration& p_timeout) &&; + #endif + }; + +} diff --git a/include/asyncpp/core/stream.pre.h b/include/asyncpp/core/stream/stream.pre.h similarity index 100% rename from include/asyncpp/core/stream.pre.h rename to include/asyncpp/core/stream/stream.pre.h diff --git a/include/asyncpp/core/stream/timeout.inl b/include/asyncpp/core/stream/timeout.inl new file mode 100644 index 0000000..8b9159f --- /dev/null +++ b/include/asyncpp/core/stream/timeout.inl @@ -0,0 +1,69 @@ +#pragma once + +#include "stream.h" + +namespace asyncpp { +namespace __stream { + + template< + chaining_mode X_mode, + typename X_self, + typename X_base, + typename X_ratio> + auto timeout_impl( + X_self&& p_self, + const duration& p_timeout) + { + using self_type = X_self; + using derived_type = typename std::decay_t::derived_type; + using derived_storage_type = storage_type_t; + using derived_ref_type = std::conditional_t< + std::is_const_v>, + derived_type const &, + derived_type &>; + using derived_forward_type = forward_type_t; + using timeout_type = timing::timeout; + + auto& self = static_cast(p_self); + + return timeout_type( + std::forward(self), + p_timeout); + } + +} } + +namespace asyncpp +{ + + template< + typename T_value, + typename T_derived> + template< + chaining_mode X_mode, + typename X_base, + typename X_ratio> + auto base_stream + ::timeout(const duration& p_timeout) & + { + return __stream::timeout_impl(std::move(*this), p_timeout); + } + + template< + typename T_value, + typename T_derived> + template< + chaining_mode X_mode, + typename X_base, + typename X_ratio> + auto base_stream + ::timeout(const duration& p_timeout) && + { + static_assert( + X_mode != ref, + "Can not store rvalue reference as lvalue reference!"); + + return __stream::timeout_impl(std::move(*this), p_timeout); + } + +} diff --git a/include/asyncpp/fs/directory.h b/include/asyncpp/fs/directory.h index 88e6c0c..7749920 100644 --- a/include/asyncpp/fs/directory.h +++ b/include/asyncpp/fs/directory.h @@ -4,8 +4,7 @@ #include -#include -#include +#include namespace asyncpp { namespace fs { diff --git a/include/asyncpp/timing/delay.h b/include/asyncpp/timing/delay.h index fda6241..83609d2 100644 --- a/include/asyncpp/timing/delay.h +++ b/include/asyncpp/timing/delay.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include "timer.h" #include "delay.pre.h" diff --git a/include/asyncpp/timing/delay.inl b/include/asyncpp/timing/delay.inl index 95d158e..3ead3de 100644 --- a/include/asyncpp/timing/delay.inl +++ b/include/asyncpp/timing/delay.inl @@ -1,8 +1,7 @@ #pragma once -#include -#include -#include +#include +#include #include "delay.h" diff --git a/include/asyncpp/timing/interval.h b/include/asyncpp/timing/interval.h index 8d2f06e..f2a055d 100644 --- a/include/asyncpp/timing/interval.h +++ b/include/asyncpp/timing/interval.h @@ -1,8 +1,8 @@ #pragma once #include -#include -#include +#include +#include #include "delay.h" diff --git a/include/asyncpp/timing/timeout.h b/include/asyncpp/timing/timeout.h index 4fdc92b..cda3839 100644 --- a/include/asyncpp/timing/timeout.h +++ b/include/asyncpp/timing/timeout.h @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include #include "delay.h" diff --git a/test/asyncpp/timing/timeout_tests.cpp b/test/asyncpp/timing/timeout_tests.cpp index 15204a5..c8d9792 100644 --- a/test/asyncpp/timing/timeout_tests.cpp +++ b/test/asyncpp/timing/timeout_tests.cpp @@ -141,7 +141,7 @@ TEST(timeout_tests, poll_stream_no_timeout) auto t = test_stream { 0 }; auto f = t - .timeout(std::chrono::seconds(5)); + .timeout(std::chrono::seconds(5)); EXPECT_CALL(m, now()) .WillOnce(Return(time_point(std::chrono::seconds(0)))); @@ -191,7 +191,7 @@ TEST(timeout_tests, poll_stream_timeout) auto t = test_stream { 0 }; auto f = t - .timeout(std::chrono::seconds(5)); + .timeout(std::chrono::seconds(5)); EXPECT_CALL(m, now()) .WillOnce(Return(time_point(std::chrono::seconds(0))));