Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:03

0001 //
0002 // any_completion_executor.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_ANY_COMPLETION_EXECUTOR_HPP
0012 #define BOOST_ASIO_ANY_COMPLETION_EXECUTOR_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0020 # include <boost/asio/executor.hpp>
0021 #else // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0022 # include <boost/asio/execution.hpp>
0023 #endif // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0024 
0025 #include <boost/asio/detail/push_options.hpp>
0026 
0027 namespace boost {
0028 namespace asio {
0029 
0030 #if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0031 
0032 typedef executor any_completion_executor;
0033 
0034 #else // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0035 
0036 /// Polymorphic executor type for use with I/O objects.
0037 /**
0038  * The @c any_completion_executor type is a polymorphic executor that supports
0039  * the set of properties required for the execution of completion handlers. It
0040  * is defined as the execution::any_executor class template parameterised as
0041  * follows:
0042  * @code execution::any_executor<
0043  *   execution::prefer_only<execution::outstanding_work_t::tracked_t>,
0044  *   execution::prefer_only<execution::outstanding_work_t::untracked_t>
0045  *   execution::prefer_only<execution::relationship_t::fork_t>,
0046  *   execution::prefer_only<execution::relationship_t::continuation_t>
0047  * > @endcode
0048  */
0049 class any_completion_executor :
0050 #if defined(GENERATING_DOCUMENTATION)
0051   public execution::any_executor<...>
0052 #else // defined(GENERATING_DOCUMENTATION)
0053   public execution::any_executor<
0054       execution::prefer_only<execution::outstanding_work_t::tracked_t>,
0055       execution::prefer_only<execution::outstanding_work_t::untracked_t>,
0056       execution::prefer_only<execution::relationship_t::fork_t>,
0057       execution::prefer_only<execution::relationship_t::continuation_t>
0058     >
0059 #endif // defined(GENERATING_DOCUMENTATION)
0060 {
0061 public:
0062 #if !defined(GENERATING_DOCUMENTATION)
0063   typedef execution::any_executor<
0064       execution::prefer_only<execution::outstanding_work_t::tracked_t>,
0065       execution::prefer_only<execution::outstanding_work_t::untracked_t>,
0066       execution::prefer_only<execution::relationship_t::fork_t>,
0067       execution::prefer_only<execution::relationship_t::continuation_t>
0068     > base_type;
0069 
0070   typedef void supportable_properties_type(
0071       execution::prefer_only<execution::outstanding_work_t::tracked_t>,
0072       execution::prefer_only<execution::outstanding_work_t::untracked_t>,
0073       execution::prefer_only<execution::relationship_t::fork_t>,
0074       execution::prefer_only<execution::relationship_t::continuation_t>
0075     );
0076 #endif // !defined(GENERATING_DOCUMENTATION)
0077 
0078   /// Default constructor.
0079   BOOST_ASIO_DECL any_completion_executor() noexcept;
0080 
0081   /// Construct in an empty state. Equivalent effects to default constructor.
0082   BOOST_ASIO_DECL any_completion_executor(nullptr_t) noexcept;
0083 
0084   /// Copy constructor.
0085   BOOST_ASIO_DECL any_completion_executor(
0086       const any_completion_executor& e) noexcept;
0087 
0088   /// Move constructor.
0089   BOOST_ASIO_DECL any_completion_executor(
0090       any_completion_executor&& e) noexcept;
0091 
0092   /// Construct to point to the same target as another any_executor.
0093 #if defined(GENERATING_DOCUMENTATION)
0094   template <class... OtherSupportableProperties>
0095     any_completion_executor(
0096         execution::any_executor<OtherSupportableProperties...> e);
0097 #else // defined(GENERATING_DOCUMENTATION)
0098   template <typename OtherAnyExecutor>
0099   any_completion_executor(OtherAnyExecutor e,
0100       constraint_t<
0101         conditional<
0102           !is_same<OtherAnyExecutor, any_completion_executor>::value
0103             && is_base_of<execution::detail::any_executor_base,
0104               OtherAnyExecutor>::value,
0105           typename execution::detail::supportable_properties<
0106             0, supportable_properties_type>::template
0107               is_valid_target<OtherAnyExecutor>,
0108           false_type
0109         >::type::value
0110       > = 0)
0111     : base_type(static_cast<OtherAnyExecutor&&>(e))
0112   {
0113   }
0114 #endif // defined(GENERATING_DOCUMENTATION)
0115 
0116   /// Construct to point to the same target as another any_executor.
0117 #if defined(GENERATING_DOCUMENTATION)
0118   template <class... OtherSupportableProperties>
0119     any_completion_executor(std::nothrow_t,
0120       execution::any_executor<OtherSupportableProperties...> e);
0121 #else // defined(GENERATING_DOCUMENTATION)
0122   template <typename OtherAnyExecutor>
0123   any_completion_executor(std::nothrow_t, OtherAnyExecutor e,
0124       constraint_t<
0125         conditional<
0126           !is_same<OtherAnyExecutor, any_completion_executor>::value
0127             && is_base_of<execution::detail::any_executor_base,
0128               OtherAnyExecutor>::value,
0129           typename execution::detail::supportable_properties<
0130             0, supportable_properties_type>::template
0131               is_valid_target<OtherAnyExecutor>,
0132           false_type
0133         >::type::value
0134       > = 0) noexcept
0135     : base_type(std::nothrow, static_cast<OtherAnyExecutor&&>(e))
0136   {
0137   }
0138 #endif // defined(GENERATING_DOCUMENTATION)
0139 
0140   /// Construct to point to the same target as another any_executor.
0141   BOOST_ASIO_DECL any_completion_executor(std::nothrow_t,
0142       const any_completion_executor& e) noexcept;
0143 
0144   /// Construct to point to the same target as another any_executor.
0145   BOOST_ASIO_DECL any_completion_executor(std::nothrow_t,
0146       any_completion_executor&& e) noexcept;
0147 
0148   /// Construct a polymorphic wrapper for the specified executor.
0149 #if defined(GENERATING_DOCUMENTATION)
0150   template <BOOST_ASIO_EXECUTION_EXECUTOR Executor>
0151   any_completion_executor(Executor e);
0152 #else // defined(GENERATING_DOCUMENTATION)
0153   template <BOOST_ASIO_EXECUTION_EXECUTOR Executor>
0154   any_completion_executor(Executor e,
0155       constraint_t<
0156         conditional<
0157           !is_same<Executor, any_completion_executor>::value
0158             && !is_base_of<execution::detail::any_executor_base,
0159               Executor>::value,
0160           execution::detail::is_valid_target_executor<
0161             Executor, supportable_properties_type>,
0162           false_type
0163         >::type::value
0164       > = 0)
0165     : base_type(static_cast<Executor&&>(e))
0166   {
0167   }
0168 #endif // defined(GENERATING_DOCUMENTATION)
0169 
0170   /// Construct a polymorphic wrapper for the specified executor.
0171 #if defined(GENERATING_DOCUMENTATION)
0172   template <BOOST_ASIO_EXECUTION_EXECUTOR Executor>
0173   any_completion_executor(std::nothrow_t, Executor e);
0174 #else // defined(GENERATING_DOCUMENTATION)
0175   template <BOOST_ASIO_EXECUTION_EXECUTOR Executor>
0176   any_completion_executor(std::nothrow_t, Executor e,
0177       constraint_t<
0178         conditional<
0179           !is_same<Executor, any_completion_executor>::value
0180             && !is_base_of<execution::detail::any_executor_base,
0181               Executor>::value,
0182           execution::detail::is_valid_target_executor<
0183             Executor, supportable_properties_type>,
0184           false_type
0185         >::type::value
0186       > = 0) noexcept
0187     : base_type(std::nothrow, static_cast<Executor&&>(e))
0188   {
0189   }
0190 #endif // defined(GENERATING_DOCUMENTATION)
0191 
0192   /// Assignment operator.
0193   BOOST_ASIO_DECL any_completion_executor& operator=(
0194       const any_completion_executor& e) noexcept;
0195 
0196   /// Move assignment operator.
0197   BOOST_ASIO_DECL any_completion_executor& operator=(
0198       any_completion_executor&& e) noexcept;
0199 
0200   /// Assignment operator that sets the polymorphic wrapper to the empty state.
0201   BOOST_ASIO_DECL any_completion_executor& operator=(nullptr_t);
0202 
0203   /// Destructor.
0204   BOOST_ASIO_DECL ~any_completion_executor();
0205 
0206   /// Swap targets with another polymorphic wrapper.
0207   BOOST_ASIO_DECL void swap(any_completion_executor& other) noexcept;
0208 
0209   /// Obtain a polymorphic wrapper with the specified property.
0210   /**
0211    * Do not call this function directly. It is intended for use with the
0212    * boost::asio::require and boost::asio::prefer customisation points.
0213    *
0214    * For example:
0215    * @code any_completion_executor ex = ...;
0216    * auto ex2 = boost::asio::require(ex, execution::relationship.fork); @endcode
0217    */
0218   template <typename Property>
0219   any_completion_executor require(const Property& p,
0220       constraint_t<
0221         traits::require_member<const base_type&, const Property&>::is_valid
0222       > = 0) const
0223   {
0224     return static_cast<const base_type&>(*this).require(p);
0225   }
0226 
0227   /// Obtain a polymorphic wrapper with the specified property.
0228   /**
0229    * Do not call this function directly. It is intended for use with the
0230    * boost::asio::prefer customisation point.
0231    *
0232    * For example:
0233    * @code any_completion_executor ex = ...;
0234    * auto ex2 = boost::asio::prefer(ex, execution::relationship.fork); @endcode
0235    */
0236   template <typename Property>
0237   any_completion_executor prefer(const Property& p,
0238       constraint_t<
0239         traits::prefer_member<const base_type&, const Property&>::is_valid
0240       > = 0) const
0241   {
0242     return static_cast<const base_type&>(*this).prefer(p);
0243   }
0244 };
0245 
0246 #if !defined(GENERATING_DOCUMENTATION)
0247 
0248 template <>
0249 BOOST_ASIO_DECL any_completion_executor any_completion_executor::prefer(
0250     const execution::outstanding_work_t::tracked_t&, int) const;
0251 
0252 template <>
0253 BOOST_ASIO_DECL any_completion_executor any_completion_executor::prefer(
0254     const execution::outstanding_work_t::untracked_t&, int) const;
0255 
0256 template <>
0257 BOOST_ASIO_DECL any_completion_executor any_completion_executor::prefer(
0258     const execution::relationship_t::fork_t&, int) const;
0259 
0260 template <>
0261 BOOST_ASIO_DECL any_completion_executor any_completion_executor::prefer(
0262     const execution::relationship_t::continuation_t&, int) const;
0263 
0264 namespace traits {
0265 
0266 #if !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
0267 
0268 template <>
0269 struct equality_comparable<any_completion_executor>
0270 {
0271   static const bool is_valid = true;
0272   static const bool is_noexcept = true;
0273 };
0274 
0275 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
0276 
0277 #if !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
0278 
0279 template <typename F>
0280 struct execute_member<any_completion_executor, F>
0281 {
0282   static const bool is_valid = true;
0283   static const bool is_noexcept = false;
0284   typedef void result_type;
0285 };
0286 
0287 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
0288 
0289 #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
0290 
0291 template <typename Prop>
0292 struct query_member<any_completion_executor, Prop> :
0293   query_member<any_completion_executor::base_type, Prop>
0294 {
0295 };
0296 
0297 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
0298 
0299 #if !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
0300 
0301 template <typename Prop>
0302 struct require_member<any_completion_executor, Prop> :
0303   require_member<any_completion_executor::base_type, Prop>
0304 {
0305   typedef any_completion_executor result_type;
0306 };
0307 
0308 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
0309 
0310 #if !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
0311 
0312 template <typename Prop>
0313 struct prefer_member<any_completion_executor, Prop> :
0314   prefer_member<any_completion_executor::base_type, Prop>
0315 {
0316   typedef any_completion_executor result_type;
0317 };
0318 
0319 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
0320 
0321 } // namespace traits
0322 
0323 #endif // !defined(GENERATING_DOCUMENTATION)
0324 
0325 #endif // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0326 
0327 } // namespace asio
0328 } // namespace boost
0329 
0330 #include <boost/asio/detail/pop_options.hpp>
0331 
0332 #if defined(BOOST_ASIO_HEADER_ONLY) \
0333   && !defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0334 # include <boost/asio/impl/any_completion_executor.ipp>
0335 #endif // defined(BOOST_ASIO_HEADER_ONLY)
0336        //   && !defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0337 
0338 #endif // BOOST_ASIO_ANY_COMPLETION_EXECUTOR_HPP