early-access version 3088

This commit is contained in:
pineappleEA
2022-11-05 15:35:56 +01:00
parent 4e4fc25ce3
commit b601909c6d
35519 changed files with 5996896 additions and 860 deletions

View File

@@ -0,0 +1,339 @@
//
// execution/allocator.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_ALLOCATOR_HPP
#define BOOST_ASIO_EXECUTION_ALLOCATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/scheduler.hpp>
#include <boost/asio/execution/sender.hpp>
#include <boost/asio/is_applicable_property.hpp>
#include <boost/asio/traits/query_static_constexpr_member.hpp>
#include <boost/asio/traits/static_query.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
#if defined(GENERATING_DOCUMENTATION)
namespace execution {
/// A property to describe which allocator an executor will use to allocate the
/// memory required to store a submitted function object.
template <typename ProtoAllocator>
struct allocator_t
{
/// The allocator_t property applies to executors, senders, and schedulers.
template <typename T>
static constexpr bool is_applicable_property_v =
is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
/// The allocator_t property can be required.
static constexpr bool is_requirable = true;
/// The allocator_t property can be preferred.
static constexpr bool is_preferable = true;
/// Default constructor.
constexpr allocator_t();
/// Obtain the allocator stored in the allocator_t property object.
/**
* Present only if @c ProtoAllocator is non-void.
*/
constexpr ProtoAllocator value() const;
/// Create an allocator_t object with a different allocator.
/**
* Present only if @c ProtoAllocator is void.
*/
template <typename OtherAllocator>
allocator_t<OtherAllocator operator()(const OtherAllocator& a);
};
/// A special value used for accessing the allocator_t property.
constexpr allocator_t<void> allocator;
} // namespace execution
#else // defined(GENERATING_DOCUMENTATION)
namespace execution {
template <typename ProtoAllocator>
struct allocator_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<T>::value
|| conditional<
is_executor<T>::value,
false_type,
is_sender<T>
>::type::value
|| conditional<
is_executor<T>::value,
false_type,
is_scheduler<T>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = true);
template <typename T>
struct static_proxy
{
#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
struct type
{
template <typename P>
static constexpr auto query(BOOST_ASIO_MOVE_ARG(P) p)
noexcept(
noexcept(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
)
-> decltype(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
{
return T::query(BOOST_ASIO_MOVE_CAST(P)(p));
}
};
#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
typedef T type;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename static_proxy<T>::type, allocator_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
query_static_constexpr_member<T>::is_noexcept))
{
return query_static_constexpr_member<T>::value();
}
template <typename E, typename T = decltype(allocator_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= allocator_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
BOOST_ASIO_CONSTEXPR ProtoAllocator value() const
{
return a_;
}
private:
friend struct allocator_t<void>;
explicit BOOST_ASIO_CONSTEXPR allocator_t(const ProtoAllocator& a)
: a_(a)
{
}
ProtoAllocator a_;
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename ProtoAllocator> template <typename E, typename T>
const T allocator_t<ProtoAllocator>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <>
struct allocator_t<void>
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<T>::value
|| conditional<
is_executor<T>::value,
false_type,
is_sender<T>
>::type::value
|| conditional<
is_executor<T>::value,
false_type,
is_scheduler<T>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = true);
BOOST_ASIO_CONSTEXPR allocator_t()
{
}
template <typename T>
struct static_proxy
{
#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
struct type
{
template <typename P>
static constexpr auto query(BOOST_ASIO_MOVE_ARG(P) p)
noexcept(
noexcept(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
)
-> decltype(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
{
return T::query(BOOST_ASIO_MOVE_CAST(P)(p));
}
};
#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
typedef T type;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename static_proxy<T>::type, allocator_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
query_static_constexpr_member<T>::is_noexcept))
{
return query_static_constexpr_member<T>::value();
}
template <typename E, typename T = decltype(allocator_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= allocator_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename OtherProtoAllocator>
BOOST_ASIO_CONSTEXPR allocator_t<OtherProtoAllocator> operator()(
const OtherProtoAllocator& a) const
{
return allocator_t<OtherProtoAllocator>(a);
}
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename E, typename T>
const T allocator_t<void>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
constexpr allocator_t<void> allocator;
#else // defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
template <typename T>
struct allocator_instance
{
static allocator_t<T> instance;
};
template <typename T>
allocator_t<T> allocator_instance<T>::instance;
namespace {
static const allocator_t<void>& allocator = allocator_instance<void>::instance;
} // namespace
#endif
} // namespace execution
#if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T, typename ProtoAllocator>
struct is_applicable_property<T, execution::allocator_t<ProtoAllocator> >
: integral_constant<bool,
execution::is_executor<T>::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_sender<T>
>::type::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_scheduler<T>
>::type::value>
{
};
#endif // !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|| !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T, typename ProtoAllocator>
struct static_query<T, execution::allocator_t<ProtoAllocator>,
typename enable_if<
execution::allocator_t<ProtoAllocator>::template
query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename execution::allocator_t<ProtoAllocator>::template
query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return execution::allocator_t<ProtoAllocator>::template
query_static_constexpr_member<T>::value();
}
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
} // namespace traits
#endif // defined(GENERATING_DOCUMENTATION)
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_ALLOCATOR_HPP

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
//
// execution/bad_executor.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_BAD_EXECUTOR_HPP
#define BOOST_ASIO_EXECUTION_BAD_EXECUTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <exception>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
/// Exception thrown when trying to access an empty polymorphic executor.
class bad_executor
: public std::exception
{
public:
/// Constructor.
BOOST_ASIO_DECL bad_executor() BOOST_ASIO_NOEXCEPT;
/// Obtain message associated with exception.
BOOST_ASIO_DECL virtual const char* what() const
BOOST_ASIO_NOEXCEPT_OR_NOTHROW;
};
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#if defined(BOOST_ASIO_HEADER_ONLY)
# include <boost/asio/execution/impl/bad_executor.ipp>
#endif // defined(BOOST_ASIO_HEADER_ONLY)
#endif // BOOST_ASIO_EXECUTION_BAD_EXECUTOR_HPP

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,401 @@
//
// execution/bulk_execute.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_BULK_EXECUTE_HPP
#define BOOST_ASIO_EXECUTION_BULK_EXECUTE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/bulk_guarantee.hpp>
#include <boost/asio/execution/detail/bulk_sender.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/sender.hpp>
#include <boost/asio/traits/bulk_execute_member.hpp>
#include <boost/asio/traits/bulk_execute_free.hpp>
#include <boost/asio/detail/push_options.hpp>
#if defined(GENERATING_DOCUMENTATION)
namespace boost {
namespace asio {
namespace execution {
/// A customisation point that creates a bulk sender.
/**
* The name <tt>execution::bulk_execute</tt> denotes a customisation point
* object. If <tt>is_convertible_v<N, size_t></tt> is true, then the expression
* <tt>execution::bulk_execute(S, F, N)</tt> for some subexpressions
* <tt>S</tt>, <tt>F</tt>, and <tt>N</tt> is expression-equivalent to:
*
* @li <tt>S.bulk_execute(F, N)</tt>, if that expression is valid. If the
* function selected does not execute <tt>N</tt> invocations of the function
* object <tt>F</tt> on the executor <tt>S</tt> in bulk with forward progress
* guarantee <tt>boost::asio::query(S, execution::bulk_guarantee)</tt>, and
* the result of that function does not model <tt>sender<void></tt>, the
* program is ill-formed with no diagnostic required.
*
* @li Otherwise, <tt>bulk_execute(S, F, N)</tt>, if that expression is valid,
* with overload resolution performed in a context that includes the
* declaration <tt>void bulk_execute();</tt> and that does not include a
* declaration of <tt>execution::bulk_execute</tt>. If the function selected
* by overload resolution does not execute <tt>N</tt> invocations of the
* function object <tt>F</tt> on the executor <tt>S</tt> in bulk with forward
* progress guarantee <tt>boost::asio::query(E,
* execution::bulk_guarantee)</tt>, and the result of that function does not
* model <tt>sender<void></tt>, the program is ill-formed with no diagnostic
* required.
*
* @li Otherwise, if the types <tt>F</tt> and
* <tt>executor_index_t<remove_cvref_t<S>></tt> model <tt>invocable</tt> and
* if <tt>boost::asio::query(S, execution::bulk_guarantee)</tt> equals
* <tt>execution::bulk_guarantee.unsequenced</tt>, then
*
* - Evaluates <tt>DECAY_COPY(std::forward<decltype(F)>(F))</tt> on the
* calling thread to create a function object <tt>cf</tt>. [Note:
* Additional copies of <tt>cf</tt> may subsequently be created. --end
* note.]
*
* - For each value of <tt>i</tt> in <tt>N</tt>, <tt>cf(i)</tt> (or copy of
* <tt>cf</tt>)) will be invoked at most once by an execution agent that is
* unique for each value of <tt>i</tt>.
*
* - May block pending completion of one or more invocations of <tt>cf</tt>.
*
* - Synchronizes with (C++Std [intro.multithread]) the invocations of
* <tt>cf</tt>.
*
* @li Otherwise, <tt>execution::bulk_execute(S, F, N)</tt> is ill-formed.
*/
inline constexpr unspecified bulk_execute = unspecified;
/// A type trait that determines whether a @c bulk_execute expression is
/// well-formed.
/**
* Class template @c can_bulk_execute is a trait that is derived from @c
* true_type if the expression <tt>execution::bulk_execute(std::declval<S>(),
* std::declval<F>(), std::declval<N>)</tt> is well formed; otherwise @c
* false_type.
*/
template <typename S, typename F, typename N>
struct can_bulk_execute :
integral_constant<bool, automatically_determined>
{
};
} // namespace execution
} // namespace asio
} // namespace boost
#else // defined(GENERATING_DOCUMENTATION)
namespace boost_asio_execution_bulk_execute_fn {
using boost::asio::declval;
using boost::asio::enable_if;
using boost::asio::execution::bulk_guarantee_t;
using boost::asio::execution::detail::bulk_sender;
using boost::asio::execution::executor_index;
using boost::asio::execution::is_sender;
using boost::asio::is_convertible;
using boost::asio::is_same;
using boost::asio::remove_cvref;
using boost::asio::result_of;
using boost::asio::traits::bulk_execute_free;
using boost::asio::traits::bulk_execute_member;
using boost::asio::traits::static_require;
void bulk_execute();
enum overload_type
{
call_member,
call_free,
adapter,
ill_formed
};
template <typename S, typename Args, typename = void, typename = void,
typename = void, typename = void, typename = void, typename = void>
struct call_traits
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = ill_formed);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
template <typename S, typename F, typename N>
struct call_traits<S, void(F, N),
typename enable_if<
is_convertible<N, std::size_t>::value
>::type,
typename enable_if<
bulk_execute_member<S, F, N>::is_valid
>::type,
typename enable_if<
is_sender<
typename bulk_execute_member<S, F, N>::result_type
>::value
>::type> :
bulk_execute_member<S, F, N>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_member);
};
template <typename S, typename F, typename N>
struct call_traits<S, void(F, N),
typename enable_if<
is_convertible<N, std::size_t>::value
>::type,
typename enable_if<
!bulk_execute_member<S, F, N>::is_valid
>::type,
typename enable_if<
bulk_execute_free<S, F, N>::is_valid
>::type,
typename enable_if<
is_sender<
typename bulk_execute_free<S, F, N>::result_type
>::value
>::type> :
bulk_execute_free<S, F, N>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_free);
};
template <typename S, typename F, typename N>
struct call_traits<S, void(F, N),
typename enable_if<
is_convertible<N, std::size_t>::value
>::type,
typename enable_if<
!bulk_execute_member<S, F, N>::is_valid
>::type,
typename enable_if<
!bulk_execute_free<S, F, N>::is_valid
>::type,
typename enable_if<
is_sender<S>::value
>::type,
typename enable_if<
is_same<
typename result_of<
F(typename executor_index<typename remove_cvref<S>::type>::type)
>::type,
typename result_of<
F(typename executor_index<typename remove_cvref<S>::type>::type)
>::type
>::value
>::type,
typename enable_if<
static_require<S, bulk_guarantee_t::unsequenced_t>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = adapter);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef bulk_sender<S, F, N> result_type;
};
struct impl
{
#if defined(BOOST_ASIO_HAS_MOVE)
template <typename S, typename F, typename N>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(F, N)>::overload == call_member,
typename call_traits<S, void(F, N)>::result_type
>::type
operator()(S&& s, F&& f, N&& n) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(F, N)>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(S)(s).bulk_execute(
BOOST_ASIO_MOVE_CAST(F)(f), BOOST_ASIO_MOVE_CAST(N)(n));
}
template <typename S, typename F, typename N>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(F, N)>::overload == call_free,
typename call_traits<S, void(F, N)>::result_type
>::type
operator()(S&& s, F&& f, N&& n) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(F, N)>::is_noexcept))
{
return bulk_execute(BOOST_ASIO_MOVE_CAST(S)(s),
BOOST_ASIO_MOVE_CAST(F)(f), BOOST_ASIO_MOVE_CAST(N)(n));
}
template <typename S, typename F, typename N>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(F, N)>::overload == adapter,
typename call_traits<S, void(F, N)>::result_type
>::type
operator()(S&& s, F&& f, N&& n) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(F, N)>::is_noexcept))
{
return typename call_traits<S, void(F, N)>::result_type(
BOOST_ASIO_MOVE_CAST(S)(s), BOOST_ASIO_MOVE_CAST(F)(f),
BOOST_ASIO_MOVE_CAST(N)(n));
}
#else // defined(BOOST_ASIO_HAS_MOVE)
template <typename S, typename F, typename N>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(const F&, const N&)>::overload == call_member,
typename call_traits<S, void(const F&, const N&)>::result_type
>::type
operator()(S& s, const F& f, const N& n) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(const F&, const N&)>::is_noexcept))
{
return s.bulk_execute(BOOST_ASIO_MOVE_CAST(F)(f),
BOOST_ASIO_MOVE_CAST(N)(n));
}
template <typename S, typename F, typename N>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(const F&, const N&)>::overload == call_member,
typename call_traits<S, void(const F&, const N&)>::result_type
>::type
operator()(const S& s, const F& f, const N& n) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(const F&, const N&)>::is_noexcept))
{
return s.bulk_execute(BOOST_ASIO_MOVE_CAST(F)(f),
BOOST_ASIO_MOVE_CAST(N)(n));
}
template <typename S, typename F, typename N>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(const F&, const N&)>::overload == call_free,
typename call_traits<S, void(const F&, const N&)>::result_type
>::type
operator()(S& s, const F& f, const N& n) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(const F&, const N&)>::is_noexcept))
{
return bulk_execute(s, BOOST_ASIO_MOVE_CAST(F)(f),
BOOST_ASIO_MOVE_CAST(N)(n));
}
template <typename S, typename F, typename N>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(const F&, const N&)>::overload == call_free,
typename call_traits<S, void(const F&, const N&)>::result_type
>::type
operator()(const S& s, const F& f, const N& n) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(const F&, const N&)>::is_noexcept))
{
return bulk_execute(s, BOOST_ASIO_MOVE_CAST(F)(f),
BOOST_ASIO_MOVE_CAST(N)(n));
}
template <typename S, typename F, typename N>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(const F&, const N&)>::overload == adapter,
typename call_traits<S, void(const F&, const N&)>::result_type
>::type
operator()(S& s, const F& f, const N& n) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(const F&, const N&)>::is_noexcept))
{
return typename call_traits<S, void(const F&, const N&)>::result_type(
s, BOOST_ASIO_MOVE_CAST(F)(f), BOOST_ASIO_MOVE_CAST(N)(n));
}
template <typename S, typename F, typename N>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(const F&, const N&)>::overload == adapter,
typename call_traits<S, void(const F&, const N&)>::result_type
>::type
operator()(const S& s, const F& f, const N& n) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(const F&, const N&)>::is_noexcept))
{
return typename call_traits<S, void(const F&, const N&)>::result_type(
s, BOOST_ASIO_MOVE_CAST(F)(f), BOOST_ASIO_MOVE_CAST(N)(n));
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
template <typename T = impl>
struct static_instance
{
static const T instance;
};
template <typename T>
const T static_instance<T>::instance = {};
} // namespace boost_asio_execution_bulk_execute_fn
namespace boost {
namespace asio {
namespace execution {
namespace {
static BOOST_ASIO_CONSTEXPR
const boost_asio_execution_bulk_execute_fn::impl& bulk_execute =
boost_asio_execution_bulk_execute_fn::static_instance<>::instance;
} // namespace
template <typename S, typename F, typename N>
struct can_bulk_execute :
integral_constant<bool,
boost_asio_execution_bulk_execute_fn::call_traits<
S, void(F, N)>::overload !=
boost_asio_execution_bulk_execute_fn::ill_formed>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename F, typename N>
constexpr bool can_bulk_execute_v = can_bulk_execute<S, F, N>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename F, typename N>
struct is_nothrow_bulk_execute :
integral_constant<bool,
boost_asio_execution_bulk_execute_fn::call_traits<
S, void(F, N)>::is_noexcept>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename F, typename N>
constexpr bool is_nothrow_bulk_execute_v
= is_nothrow_bulk_execute<S, F, N>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename F, typename N>
struct bulk_execute_result
{
typedef typename boost_asio_execution_bulk_execute_fn::call_traits<
S, void(F, N)>::result_type type;
};
} // namespace execution
} // namespace asio
} // namespace boost
#endif // defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_BULK_EXECUTE_HPP

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,493 @@
//
// execution/connect.hpp
// ~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_CONNECT_HPP
#define BOOST_ASIO_EXECUTION_CONNECT_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/detail/as_invocable.hpp>
#include <boost/asio/execution/detail/as_operation.hpp>
#include <boost/asio/execution/detail/as_receiver.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/operation_state.hpp>
#include <boost/asio/execution/receiver.hpp>
#include <boost/asio/execution/sender.hpp>
#include <boost/asio/traits/connect_member.hpp>
#include <boost/asio/traits/connect_free.hpp>
#include <boost/asio/detail/push_options.hpp>
#if defined(GENERATING_DOCUMENTATION)
namespace boost {
namespace asio {
namespace execution {
/// A customisation point that connects a sender to a receiver.
/**
* The name <tt>execution::connect</tt> denotes a customisation point object.
* For some subexpressions <tt>s</tt> and <tt>r</tt>, let <tt>S</tt> be a type
* such that <tt>decltype((s))</tt> is <tt>S</tt> and let <tt>R</tt> be a type
* such that <tt>decltype((r))</tt> is <tt>R</tt>. The expression
* <tt>execution::connect(s, r)</tt> is expression-equivalent to:
*
* @li <tt>s.connect(r)</tt>, if that expression is valid, if its type
* satisfies <tt>operation_state</tt>, and if <tt>S</tt> satisfies
* <tt>sender</tt>.
*
* @li Otherwise, <tt>connect(s, r)</tt>, if that expression is valid, if its
* type satisfies <tt>operation_state</tt>, and if <tt>S</tt> satisfies
* <tt>sender</tt>, with overload resolution performed in a context that
* includes the declaration <tt>void connect();</tt> and that does not include
* a declaration of <tt>execution::connect</tt>.
*
* @li Otherwise, <tt>as_operation{s, r}</tt>, if <tt>r</tt> is not an instance
* of <tt>as_receiver<F, S></tt> for some type <tt>F</tt>, and if
* <tt>receiver_of<R> && executor_of<remove_cvref_t<S>,
* as_invocable<remove_cvref_t<R>, S>></tt> is <tt>true</tt>, where
* <tt>as_operation</tt> is an implementation-defined class equivalent to
* @code template <class S, class R>
* struct as_operation
* {
* remove_cvref_t<S> e_;
* remove_cvref_t<R> r_;
* void start() noexcept try {
* execution::execute(std::move(e_),
* as_invocable<remove_cvref_t<R>, S>{r_});
* } catch(...) {
* execution::set_error(std::move(r_), current_exception());
* }
* }; @endcode
* and <tt>as_invocable</tt> is a class template equivalent to the following:
* @code template<class R>
* struct as_invocable
* {
* R* r_;
* explicit as_invocable(R& r) noexcept
* : r_(std::addressof(r)) {}
* as_invocable(as_invocable && other) noexcept
* : r_(std::exchange(other.r_, nullptr)) {}
* ~as_invocable() {
* if(r_)
* execution::set_done(std::move(*r_));
* }
* void operator()() & noexcept try {
* execution::set_value(std::move(*r_));
* r_ = nullptr;
* } catch(...) {
* execution::set_error(std::move(*r_), current_exception());
* r_ = nullptr;
* }
* };
* @endcode
*
* @li Otherwise, <tt>execution::connect(s, r)</tt> is ill-formed.
*/
inline constexpr unspecified connect = unspecified;
/// A type trait that determines whether a @c connect expression is
/// well-formed.
/**
* Class template @c can_connect is a trait that is derived from
* @c true_type if the expression <tt>execution::connect(std::declval<S>(),
* std::declval<R>())</tt> is well formed; otherwise @c false_type.
*/
template <typename S, typename R>
struct can_connect :
integral_constant<bool, automatically_determined>
{
};
/// A type trait to determine the result of a @c connect expression.
template <typename S, typename R>
struct connect_result
{
/// The type of the connect expression.
/**
* The type of the expression <tt>execution::connect(std::declval<S>(),
* std::declval<R>())</tt>.
*/
typedef automatically_determined type;
};
/// A type alis to determine the result of a @c connect expression.
template <typename S, typename R>
using connect_result_t = typename connect_result<S, R>::type;
} // namespace execution
} // namespace asio
} // namespace boost
#else // defined(GENERATING_DOCUMENTATION)
namespace boost_asio_execution_connect_fn {
using boost::asio::conditional;
using boost::asio::declval;
using boost::asio::enable_if;
using boost::asio::execution::detail::as_invocable;
using boost::asio::execution::detail::as_operation;
using boost::asio::execution::detail::is_as_receiver;
using boost::asio::execution::is_executor_of;
using boost::asio::execution::is_operation_state;
using boost::asio::execution::is_receiver;
using boost::asio::execution::is_sender;
using boost::asio::false_type;
using boost::asio::remove_cvref;
using boost::asio::traits::connect_free;
using boost::asio::traits::connect_member;
void connect();
enum overload_type
{
call_member,
call_free,
adapter,
ill_formed
};
template <typename S, typename R, typename = void,
typename = void, typename = void, typename = void>
struct call_traits
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = ill_formed);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
template <typename S, typename R>
struct call_traits<S, void(R),
typename enable_if<
connect_member<S, R>::is_valid
>::type,
typename enable_if<
is_operation_state<typename connect_member<S, R>::result_type>::value
>::type,
typename enable_if<
is_sender<typename remove_cvref<S>::type>::value
>::type> :
connect_member<S, R>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_member);
};
template <typename S, typename R>
struct call_traits<S, void(R),
typename enable_if<
!connect_member<S, R>::is_valid
>::type,
typename enable_if<
connect_free<S, R>::is_valid
>::type,
typename enable_if<
is_operation_state<typename connect_free<S, R>::result_type>::value
>::type,
typename enable_if<
is_sender<typename remove_cvref<S>::type>::value
>::type> :
connect_free<S, R>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_free);
};
template <typename S, typename R>
struct call_traits<S, void(R),
typename enable_if<
!connect_member<S, R>::is_valid
>::type,
typename enable_if<
!connect_free<S, R>::is_valid
>::type,
typename enable_if<
is_receiver<R>::value
>::type,
typename enable_if<
conditional<
!is_as_receiver<
typename remove_cvref<R>::type
>::value,
is_executor_of<
typename remove_cvref<S>::type,
as_invocable<typename remove_cvref<R>::type, S>
>,
false_type
>::type::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = adapter);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef as_operation<S, R> result_type;
};
struct impl
{
#if defined(BOOST_ASIO_HAS_MOVE)
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(R)>::overload == call_member,
typename call_traits<S, void(R)>::result_type
>::type
operator()(S&& s, R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(R)>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(S)(s).connect(BOOST_ASIO_MOVE_CAST(R)(r));
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(R)>::overload == call_free,
typename call_traits<S, void(R)>::result_type
>::type
operator()(S&& s, R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(R)>::is_noexcept))
{
return connect(BOOST_ASIO_MOVE_CAST(S)(s), BOOST_ASIO_MOVE_CAST(R)(r));
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(R)>::overload == adapter,
typename call_traits<S, void(R)>::result_type
>::type
operator()(S&& s, R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(R)>::is_noexcept))
{
return typename call_traits<S, void(R)>::result_type(
BOOST_ASIO_MOVE_CAST(S)(s), BOOST_ASIO_MOVE_CAST(R)(r));
}
#else // defined(BOOST_ASIO_HAS_MOVE)
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(R&)>::overload == call_member,
typename call_traits<S&, void(R&)>::result_type
>::type
operator()(S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(R&)>::is_noexcept))
{
return s.connect(r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(R&)>::overload == call_member,
typename call_traits<const S&, void(R&)>::result_type
>::type
operator()(const S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(R&)>::is_noexcept))
{
return s.connect(r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(R&)>::overload == call_free,
typename call_traits<S&, void(R&)>::result_type
>::type
operator()(S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(R&)>::is_noexcept))
{
return connect(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(R&)>::overload == call_free,
typename call_traits<const S&, void(R&)>::result_type
>::type
operator()(const S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(R&)>::is_noexcept))
{
return connect(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(R&)>::overload == adapter,
typename call_traits<S&, void(R&)>::result_type
>::type
operator()(S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(R&)>::is_noexcept))
{
return typename call_traits<S&, void(R&)>::result_type(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(R&)>::overload == adapter,
typename call_traits<const S&, void(R&)>::result_type
>::type
operator()(const S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(R&)>::is_noexcept))
{
return typename call_traits<const S&, void(R&)>::result_type(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(const R&)>::overload == call_member,
typename call_traits<S&, void(const R&)>::result_type
>::type
operator()(S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(const R&)>::is_noexcept))
{
return s.connect(r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(const R&)>::overload == call_member,
typename call_traits<const S&, void(const R&)>::result_type
>::type
operator()(const S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(const R&)>::is_noexcept))
{
return s.connect(r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(const R&)>::overload == call_free,
typename call_traits<S&, void(const R&)>::result_type
>::type
operator()(S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(const R&)>::is_noexcept))
{
return connect(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(const R&)>::overload == call_free,
typename call_traits<const S&, void(const R&)>::result_type
>::type
operator()(const S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(const R&)>::is_noexcept))
{
return connect(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(const R&)>::overload == adapter,
typename call_traits<S&, void(const R&)>::result_type
>::type
operator()(S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(const R&)>::is_noexcept))
{
return typename call_traits<S&, void(const R&)>::result_type(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(const R&)>::overload == adapter,
typename call_traits<const S&, void(const R&)>::result_type
>::type
operator()(const S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(const R&)>::is_noexcept))
{
return typename call_traits<const S&, void(const R&)>::result_type(s, r);
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
template <typename T = impl>
struct static_instance
{
static const T instance;
};
template <typename T>
const T static_instance<T>::instance = {};
} // namespace boost_asio_execution_connect_fn
namespace boost {
namespace asio {
namespace execution {
namespace {
static BOOST_ASIO_CONSTEXPR const boost_asio_execution_connect_fn::impl&
connect = boost_asio_execution_connect_fn::static_instance<>::instance;
} // namespace
template <typename S, typename R>
struct can_connect :
integral_constant<bool,
boost_asio_execution_connect_fn::call_traits<S, void(R)>::overload !=
boost_asio_execution_connect_fn::ill_formed>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename R>
constexpr bool can_connect_v = can_connect<S, R>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename R>
struct is_nothrow_connect :
integral_constant<bool,
boost_asio_execution_connect_fn::call_traits<S, void(R)>::is_noexcept>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename R>
constexpr bool is_nothrow_connect_v
= is_nothrow_connect<S, R>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename R>
struct connect_result
{
typedef typename boost_asio_execution_connect_fn::call_traits<
S, void(R)>::result_type type;
};
#if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
template <typename S, typename R>
using connect_result_t = typename connect_result<S, R>::type;
#endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
} // namespace execution
} // namespace asio
} // namespace boost
#endif // defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_CONNECT_HPP

View File

@@ -0,0 +1,235 @@
//
// execution/context.hpp
// ~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_CONTEXT2_HPP
#define BOOST_ASIO_EXECUTION_CONTEXT2_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/scheduler.hpp>
#include <boost/asio/execution/sender.hpp>
#include <boost/asio/is_applicable_property.hpp>
#include <boost/asio/traits/query_static_constexpr_member.hpp>
#include <boost/asio/traits/static_query.hpp>
#if defined(BOOST_ASIO_HAS_STD_ANY)
# include <any>
#endif // defined(BOOST_ASIO_HAS_STD_ANY)
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
#if defined(GENERATING_DOCUMENTATION)
namespace execution {
/// A property that is used to obtain the execution context that is associated
/// with an executor.
struct context_t
{
/// The context_t property applies to executors, senders, and schedulers.
template <typename T>
static constexpr bool is_applicable_property_v =
is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
/// The context_t property cannot be required.
static constexpr bool is_requirable = false;
/// The context_t property cannot be preferred.
static constexpr bool is_preferable = false;
/// The type returned by queries against an @c any_executor.
typedef std::any polymorphic_query_result_type;
};
/// A special value used for accessing the context_t property.
constexpr context_t context;
} // namespace execution
#else // defined(GENERATING_DOCUMENTATION)
namespace execution {
namespace detail {
template <int I = 0>
struct context_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<T>::value
|| conditional<
is_executor<T>::value,
false_type,
is_sender<T>
>::type::value
|| conditional<
is_executor<T>::value,
false_type,
is_scheduler<T>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = false);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = false);
#if defined(BOOST_ASIO_HAS_STD_ANY)
typedef std::any polymorphic_query_result_type;
#endif // defined(BOOST_ASIO_HAS_STD_ANY)
BOOST_ASIO_CONSTEXPR context_t()
{
}
template <typename T>
struct static_proxy
{
#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
struct type
{
template <typename P>
static constexpr auto query(BOOST_ASIO_MOVE_ARG(P) p)
noexcept(
noexcept(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
)
-> decltype(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
{
return T::query(BOOST_ASIO_MOVE_CAST(P)(p));
}
};
#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
typedef T type;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename static_proxy<T>::type, context_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
query_static_constexpr_member<T>::is_noexcept))
{
return query_static_constexpr_member<T>::value();
}
template <typename E, typename T = decltype(context_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= context_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_CONSTEXPR)
static const context_t instance;
#endif // !defined(BOOST_ASIO_HAS_CONSTEXPR)
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I> template <typename E, typename T>
const T context_t<I>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_CONSTEXPR)
template <int I>
const context_t<I> context_t<I>::instance;
#endif
} // namespace detail
typedef detail::context_t<> context_t;
#if defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
constexpr context_t context;
#else // defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
namespace { static const context_t& context = context_t::instance; }
#endif
} // namespace execution
#if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
struct is_applicable_property<T, execution::context_t>
: integral_constant<bool,
execution::is_executor<T>::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_sender<T>
>::type::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_scheduler<T>
>::type::value>
{
};
#endif // !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|| !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
struct static_query<T, execution::context_t,
typename enable_if<
execution::detail::context_t<0>::
query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename execution::detail::context_t<0>::
query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return execution::detail::context_t<0>::
query_static_constexpr_member<T>::value();
}
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
} // namespace traits
#endif // defined(GENERATING_DOCUMENTATION)
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_CONTEXT2_HPP

View File

@@ -0,0 +1,223 @@
//
// execution/context_as.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_CONTEXT_AS_HPP
#define BOOST_ASIO_EXECUTION_CONTEXT_AS_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/context.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/scheduler.hpp>
#include <boost/asio/execution/sender.hpp>
#include <boost/asio/is_applicable_property.hpp>
#include <boost/asio/query.hpp>
#include <boost/asio/traits/query_static_constexpr_member.hpp>
#include <boost/asio/traits/static_query.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
#if defined(GENERATING_DOCUMENTATION)
namespace execution {
/// A property that is used to obtain the execution context that is associated
/// with an executor.
template <typename U>
struct context_as_t
{
/// The context_as_t property applies to executors, senders, and schedulers.
template <typename T>
static constexpr bool is_applicable_property_v =
is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
/// The context_t property cannot be required.
static constexpr bool is_requirable = false;
/// The context_t property cannot be preferred.
static constexpr bool is_preferable = false;
/// The type returned by queries against an @c any_executor.
typedef T polymorphic_query_result_type;
};
/// A special value used for accessing the context_as_t property.
template <typename U>
constexpr context_as_t context_as;
} // namespace execution
#else // defined(GENERATING_DOCUMENTATION)
namespace execution {
template <typename T>
struct context_as_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename U>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<U>::value
|| conditional<
is_executor<U>::value,
false_type,
is_sender<U>
>::type::value
|| conditional<
is_executor<U>::value,
false_type,
is_scheduler<U>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = false);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = false);
typedef T polymorphic_query_result_type;
BOOST_ASIO_CONSTEXPR context_as_t()
{
}
BOOST_ASIO_CONSTEXPR context_as_t(context_t)
{
}
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename E>
static BOOST_ASIO_CONSTEXPR
typename context_t::query_static_constexpr_member<E>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
context_t::query_static_constexpr_member<E>::is_noexcept))
{
return context_t::query_static_constexpr_member<E>::value();
}
template <typename E, typename U = decltype(context_as_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const U static_query_v
= context_as_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename Executor, typename U>
friend BOOST_ASIO_CONSTEXPR U query(
const Executor& ex, const context_as_t<U>&,
typename enable_if<
is_same<T, U>::value
>::type* = 0,
typename enable_if<
can_query<const Executor&, const context_t&>::value
>::type* = 0)
#if !defined(__clang__) // Clang crashes if noexcept is used here.
#if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&, const context_t&>::value))
#else // defined(BOOST_ASIO_MSVC)
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&, const context_t&>::value))
#endif // defined(BOOST_ASIO_MSVC)
#endif // !defined(__clang__)
{
return boost::asio::query(ex, context);
}
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T> template <typename E, typename U>
const U context_as_t<T>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if (defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) \
&& defined(BOOST_ASIO_HAS_CONSTEXPR)) \
|| defined(GENERATING_DOCUMENTATION)
template <typename T>
constexpr context_as_t<T> context_as{};
#endif // (defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
// && defined(BOOST_ASIO_HAS_CONSTEXPR))
// || defined(GENERATING_DOCUMENTATION)
} // namespace execution
#if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T, typename U>
struct is_applicable_property<T, execution::context_as_t<U> >
: integral_constant<bool,
execution::is_executor<T>::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_sender<T>
>::type::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_scheduler<T>
>::type::value>
{
};
#endif // !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|| !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T, typename U>
struct static_query<T, execution::context_as_t<U>,
typename enable_if<
static_query<T, execution::context_t>::is_valid
>::type> : static_query<T, execution::context_t>
{
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
template <typename T, typename U>
struct query_free<T, execution::context_as_t<U>,
typename enable_if<
can_query<const T&, const execution::context_t&>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
(is_nothrow_query<const T&, const execution::context_t&>::value));
typedef U result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
} // namespace traits
#endif // defined(GENERATING_DOCUMENTATION)
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_CONTEXT_AS_HPP

View File

@@ -0,0 +1,154 @@
//
// execution/detail/as_invocable.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_DETAIL_AS_INVOCABLE_HPP
#define BOOST_ASIO_EXECUTION_DETAIL_AS_INVOCABLE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/atomic_count.hpp>
#include <boost/asio/detail/memory.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/receiver_invocation_error.hpp>
#include <boost/asio/execution/set_done.hpp>
#include <boost/asio/execution/set_error.hpp>
#include <boost/asio/execution/set_value.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
namespace detail {
#if defined(BOOST_ASIO_HAS_MOVE)
template <typename Receiver, typename>
struct as_invocable
{
Receiver* receiver_;
explicit as_invocable(Receiver& r) BOOST_ASIO_NOEXCEPT
: receiver_(boost::asio::detail::addressof(r))
{
}
as_invocable(as_invocable&& other) BOOST_ASIO_NOEXCEPT
: receiver_(other.receiver_)
{
other.receiver_ = 0;
}
~as_invocable()
{
if (receiver_)
execution::set_done(BOOST_ASIO_MOVE_OR_LVALUE(Receiver)(*receiver_));
}
void operator()() BOOST_ASIO_LVALUE_REF_QUAL BOOST_ASIO_NOEXCEPT
{
#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
try
{
#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
execution::set_value(BOOST_ASIO_MOVE_CAST(Receiver)(*receiver_));
receiver_ = 0;
#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
}
catch (...)
{
#if defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
execution::set_error(BOOST_ASIO_MOVE_CAST(Receiver)(*receiver_),
std::make_exception_ptr(receiver_invocation_error()));
receiver_ = 0;
#else // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
std::terminate();
#endif // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
}
#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
}
};
#else // defined(BOOST_ASIO_HAS_MOVE)
template <typename Receiver, typename>
struct as_invocable
{
Receiver* receiver_;
boost::asio::detail::shared_ptr<boost::asio::detail::atomic_count> ref_count_;
explicit as_invocable(Receiver& r,
const boost::asio::detail::shared_ptr<
boost::asio::detail::atomic_count>& c) BOOST_ASIO_NOEXCEPT
: receiver_(boost::asio::detail::addressof(r)),
ref_count_(c)
{
}
as_invocable(const as_invocable& other) BOOST_ASIO_NOEXCEPT
: receiver_(other.receiver_),
ref_count_(other.ref_count_)
{
++(*ref_count_);
}
~as_invocable()
{
if (--(*ref_count_) == 0)
execution::set_done(*receiver_);
}
void operator()() BOOST_ASIO_LVALUE_REF_QUAL BOOST_ASIO_NOEXCEPT
{
#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
try
{
#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
execution::set_value(*receiver_);
++(*ref_count_);
}
#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
catch (...)
{
#if defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
execution::set_error(*receiver_,
std::make_exception_ptr(receiver_invocation_error()));
++(*ref_count_);
#else // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
std::terminate();
#endif // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
}
#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
}
};
#endif // defined(BOOST_ASIO_HAS_MOVE)
template <typename T>
struct is_as_invocable : false_type
{
};
template <typename Function, typename T>
struct is_as_invocable<as_invocable<Function, T> > : true_type
{
};
} // namespace detail
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_DETAIL_AS_INVOCABLE_HPP

View File

@@ -0,0 +1,107 @@
//
// execution/detail/as_operation.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_DETAIL_AS_OPERATION_HPP
#define BOOST_ASIO_EXECUTION_DETAIL_AS_OPERATION_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/memory.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/detail/as_invocable.hpp>
#include <boost/asio/execution/execute.hpp>
#include <boost/asio/execution/set_error.hpp>
#include <boost/asio/traits/start_member.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
namespace detail {
template <typename Executor, typename Receiver>
struct as_operation
{
typename remove_cvref<Executor>::type ex_;
typename remove_cvref<Receiver>::type receiver_;
#if !defined(BOOST_ASIO_HAS_MOVE)
boost::asio::detail::shared_ptr<boost::asio::detail::atomic_count> ref_count_;
#endif // !defined(BOOST_ASIO_HAS_MOVE)
template <typename E, typename R>
explicit as_operation(BOOST_ASIO_MOVE_ARG(E) e, BOOST_ASIO_MOVE_ARG(R) r)
: ex_(BOOST_ASIO_MOVE_CAST(E)(e)),
receiver_(BOOST_ASIO_MOVE_CAST(R)(r))
#if !defined(BOOST_ASIO_HAS_MOVE)
, ref_count_(new boost::asio::detail::atomic_count(1))
#endif // !defined(BOOST_ASIO_HAS_MOVE)
{
}
void start() BOOST_ASIO_NOEXCEPT
{
#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
try
{
#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
execution::execute(
BOOST_ASIO_MOVE_CAST(typename remove_cvref<Executor>::type)(ex_),
as_invocable<typename remove_cvref<Receiver>::type,
Executor>(receiver_
#if !defined(BOOST_ASIO_HAS_MOVE)
, ref_count_
#endif // !defined(BOOST_ASIO_HAS_MOVE)
));
#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
}
catch (...)
{
#if defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
execution::set_error(
BOOST_ASIO_MOVE_OR_LVALUE(
typename remove_cvref<Receiver>::type)(
receiver_),
std::current_exception());
#else // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
std::terminate();
#endif // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
}
#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
}
};
} // namespace detail
} // namespace execution
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
template <typename Executor, typename Receiver>
struct start_member<
boost::asio::execution::detail::as_operation<Executor, Receiver> >
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
} // namespace traits
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_DETAIL_AS_OPERATION_HPP

View File

@@ -0,0 +1,130 @@
//
// execution/detail/as_receiver.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_DETAIL_AS_RECEIVER_HPP
#define BOOST_ASIO_EXECUTION_DETAIL_AS_RECEIVER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/traits/set_done_member.hpp>
#include <boost/asio/traits/set_error_member.hpp>
#include <boost/asio/traits/set_value_member.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
namespace detail {
template <typename Function, typename>
struct as_receiver
{
Function f_;
template <typename F>
explicit as_receiver(BOOST_ASIO_MOVE_ARG(F) f, int)
: f_(BOOST_ASIO_MOVE_CAST(F)(f))
{
}
#if defined(BOOST_ASIO_MSVC) && defined(BOOST_ASIO_HAS_MOVE)
as_receiver(as_receiver&& other)
: f_(BOOST_ASIO_MOVE_CAST(Function)(other.f_))
{
}
#endif // defined(BOOST_ASIO_MSVC) && defined(BOOST_ASIO_HAS_MOVE)
void set_value()
BOOST_ASIO_NOEXCEPT_IF(noexcept(declval<Function&>()()))
{
f_();
}
template <typename E>
void set_error(E) BOOST_ASIO_NOEXCEPT
{
std::terminate();
}
void set_done() BOOST_ASIO_NOEXCEPT
{
}
};
template <typename T>
struct is_as_receiver : false_type
{
};
template <typename Function, typename T>
struct is_as_receiver<as_receiver<Function, T> > : true_type
{
};
} // namespace detail
} // namespace execution
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
template <typename Function, typename T>
struct set_value_member<
boost::asio::execution::detail::as_receiver<Function, T>, void()>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
#if defined(BOOST_ASIO_HAS_NOEXCEPT)
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_noexcept = noexcept(declval<Function&>()()));
#else // defined(BOOST_ASIO_HAS_NOEXCEPT)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
#endif // defined(BOOST_ASIO_HAS_NOEXCEPT)
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
template <typename Function, typename T, typename E>
struct set_error_member<
boost::asio::execution::detail::as_receiver<Function, T>, E>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
template <typename Function, typename T>
struct set_done_member<
boost::asio::execution::detail::as_receiver<Function, T> >
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
} // namespace traits
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_DETAIL_AS_RECEIVER_HPP

View File

@@ -0,0 +1,263 @@
//
// execution/detail/bulk_sender.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_DETAIL_BULK_SENDER_HPP
#define BOOST_ASIO_EXECUTION_DETAIL_BULK_SENDER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/connect.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/set_done.hpp>
#include <boost/asio/execution/set_error.hpp>
#include <boost/asio/traits/connect_member.hpp>
#include <boost/asio/traits/set_done_member.hpp>
#include <boost/asio/traits/set_error_member.hpp>
#include <boost/asio/traits/set_value_member.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
namespace detail {
template <typename Receiver, typename Function, typename Number, typename Index>
struct bulk_receiver
{
typename remove_cvref<Receiver>::type receiver_;
typename decay<Function>::type f_;
typename decay<Number>::type n_;
template <typename R, typename F, typename N>
explicit bulk_receiver(BOOST_ASIO_MOVE_ARG(R) r,
BOOST_ASIO_MOVE_ARG(F) f, BOOST_ASIO_MOVE_ARG(N) n)
: receiver_(BOOST_ASIO_MOVE_CAST(R)(r)),
f_(BOOST_ASIO_MOVE_CAST(F)(f)),
n_(BOOST_ASIO_MOVE_CAST(N)(n))
{
}
void set_value()
{
for (Index i = 0; i < n_; ++i)
f_(i);
execution::set_value(
BOOST_ASIO_MOVE_OR_LVALUE(
typename remove_cvref<Receiver>::type)(receiver_));
}
template <typename Error>
void set_error(BOOST_ASIO_MOVE_ARG(Error) e) BOOST_ASIO_NOEXCEPT
{
execution::set_error(
BOOST_ASIO_MOVE_OR_LVALUE(
typename remove_cvref<Receiver>::type)(receiver_),
BOOST_ASIO_MOVE_CAST(Error)(e));
}
void set_done() BOOST_ASIO_NOEXCEPT
{
execution::set_done(
BOOST_ASIO_MOVE_OR_LVALUE(
typename remove_cvref<Receiver>::type)(receiver_));
}
};
template <typename Sender, typename Receiver,
typename Function, typename Number>
struct bulk_receiver_traits
{
typedef bulk_receiver<
Receiver, Function, Number,
typename execution::executor_index<
typename remove_cvref<Sender>::type
>::type
> type;
#if defined(BOOST_ASIO_HAS_MOVE)
typedef type arg_type;
#else // defined(BOOST_ASIO_HAS_MOVE)
typedef const type& arg_type;
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
template <typename Sender, typename Function, typename Number>
struct bulk_sender : sender_base
{
typename remove_cvref<Sender>::type sender_;
typename decay<Function>::type f_;
typename decay<Number>::type n_;
template <typename S, typename F, typename N>
explicit bulk_sender(BOOST_ASIO_MOVE_ARG(S) s,
BOOST_ASIO_MOVE_ARG(F) f, BOOST_ASIO_MOVE_ARG(N) n)
: sender_(BOOST_ASIO_MOVE_CAST(S)(s)),
f_(BOOST_ASIO_MOVE_CAST(F)(f)),
n_(BOOST_ASIO_MOVE_CAST(N)(n))
{
}
template <typename Receiver>
typename connect_result<
BOOST_ASIO_MOVE_OR_LVALUE_TYPE(typename remove_cvref<Sender>::type),
typename bulk_receiver_traits<
Sender, Receiver, Function, Number
>::arg_type
>::type connect(BOOST_ASIO_MOVE_ARG(Receiver) r,
typename enable_if<
can_connect<
typename remove_cvref<Sender>::type,
typename bulk_receiver_traits<
Sender, Receiver, Function, Number
>::arg_type
>::value
>::type* = 0) BOOST_ASIO_RVALUE_REF_QUAL BOOST_ASIO_NOEXCEPT
{
return execution::connect(
BOOST_ASIO_MOVE_OR_LVALUE(typename remove_cvref<Sender>::type)(sender_),
typename bulk_receiver_traits<Sender, Receiver, Function, Number>::type(
BOOST_ASIO_MOVE_CAST(Receiver)(r),
BOOST_ASIO_MOVE_CAST(typename decay<Function>::type)(f_),
BOOST_ASIO_MOVE_CAST(typename decay<Number>::type)(n_)));
}
template <typename Receiver>
typename connect_result<
const typename remove_cvref<Sender>::type&,
typename bulk_receiver_traits<
Sender, Receiver, Function, Number
>::arg_type
>::type connect(BOOST_ASIO_MOVE_ARG(Receiver) r,
typename enable_if<
can_connect<
const typename remove_cvref<Sender>::type&,
typename bulk_receiver_traits<
Sender, Receiver, Function, Number
>::arg_type
>::value
>::type* = 0) const BOOST_ASIO_LVALUE_REF_QUAL BOOST_ASIO_NOEXCEPT
{
return execution::connect(sender_,
typename bulk_receiver_traits<Sender, Receiver, Function, Number>::type(
BOOST_ASIO_MOVE_CAST(Receiver)(r), f_, n_));
}
};
} // namespace detail
} // namespace execution
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
template <typename Receiver, typename Function, typename Number, typename Index>
struct set_value_member<
execution::detail::bulk_receiver<Receiver, Function, Number, Index>,
void()>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
template <typename Receiver, typename Function,
typename Number, typename Index, typename Error>
struct set_error_member<
execution::detail::bulk_receiver<Receiver, Function, Number, Index>,
Error>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
template <typename Receiver, typename Function, typename Number, typename Index>
struct set_done_member<
execution::detail::bulk_receiver<Receiver, Function, Number, Index> >
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_CONNECT_MEMBER_TRAIT)
template <typename Sender, typename Function,
typename Number, typename Receiver>
struct connect_member<
execution::detail::bulk_sender<Sender, Function, Number>,
Receiver,
typename enable_if<
execution::can_connect<
BOOST_ASIO_MOVE_OR_LVALUE_TYPE(typename remove_cvref<Sender>::type),
typename execution::detail::bulk_receiver_traits<
Sender, Receiver, Function, Number
>::arg_type
>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef typename execution::connect_result<
BOOST_ASIO_MOVE_OR_LVALUE_TYPE(typename remove_cvref<Sender>::type),
typename execution::detail::bulk_receiver_traits<
Sender, Receiver, Function, Number
>::arg_type
>::type result_type;
};
template <typename Sender, typename Function,
typename Number, typename Receiver>
struct connect_member<
const execution::detail::bulk_sender<Sender, Function, Number>,
Receiver,
typename enable_if<
execution::can_connect<
const typename remove_cvref<Sender>::type&,
typename execution::detail::bulk_receiver_traits<
Sender, Receiver, Function, Number
>::arg_type
>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef typename execution::connect_result<
const typename remove_cvref<Sender>::type&,
typename execution::detail::bulk_receiver_traits<
Sender, Receiver, Function, Number
>::arg_type
>::type result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_CONNECT_MEMBER_TRAIT)
} // namespace traits
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_DETAIL_BULK_SENDER_HPP

View File

@@ -0,0 +1,235 @@
//
// execution/detail/submit_receiver.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_DETAIL_SUBMIT_RECEIVER_HPP
#define BOOST_ASIO_EXECUTION_DETAIL_SUBMIT_RECEIVER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/detail/variadic_templates.hpp>
#include <boost/asio/execution/connect.hpp>
#include <boost/asio/execution/receiver.hpp>
#include <boost/asio/execution/set_done.hpp>
#include <boost/asio/execution/set_error.hpp>
#include <boost/asio/execution/set_value.hpp>
#include <boost/asio/traits/set_done_member.hpp>
#include <boost/asio/traits/set_error_member.hpp>
#include <boost/asio/traits/set_value_member.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
namespace detail {
template <typename Sender, typename Receiver>
struct submit_receiver;
template <typename Sender, typename Receiver>
struct submit_receiver_wrapper
{
submit_receiver<Sender, Receiver>* p_;
explicit submit_receiver_wrapper(submit_receiver<Sender, Receiver>* p)
: p_(p)
{
}
#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename... Args>
typename enable_if<is_receiver_of<Receiver, Args...>::value>::type
set_value(BOOST_ASIO_MOVE_ARG(Args)... args) BOOST_ASIO_RVALUE_REF_QUAL
BOOST_ASIO_NOEXCEPT_IF((is_nothrow_receiver_of<Receiver, Args...>::value))
{
execution::set_value(
BOOST_ASIO_MOVE_OR_LVALUE(
typename remove_cvref<Receiver>::type)(p_->r_),
BOOST_ASIO_MOVE_CAST(Args)(args)...);
delete p_;
}
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
void set_value() BOOST_ASIO_RVALUE_REF_QUAL
BOOST_ASIO_NOEXCEPT_IF((is_nothrow_receiver_of<Receiver>::value))
{
execution::set_value(
BOOST_ASIO_MOVE_OR_LVALUE(
typename remove_cvref<Receiver>::type)(p_->r_));
delete p_;
}
#define BOOST_ASIO_PRIVATE_SUBMIT_RECEIVER_SET_VALUE_DEF(n) \
template <BOOST_ASIO_VARIADIC_TPARAMS(n)> \
typename enable_if<is_receiver_of<Receiver, \
BOOST_ASIO_VARIADIC_TARGS(n)>::value>::type \
set_value(BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) BOOST_ASIO_RVALUE_REF_QUAL \
BOOST_ASIO_NOEXCEPT_IF((is_nothrow_receiver_of< \
Receiver, BOOST_ASIO_VARIADIC_TARGS(n)>::value)) \
{ \
execution::set_value( \
BOOST_ASIO_MOVE_OR_LVALUE( \
typename remove_cvref<Receiver>::type)(p_->r_), \
BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
delete p_; \
} \
/**/
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SUBMIT_RECEIVER_SET_VALUE_DEF)
#undef BOOST_ASIO_PRIVATE_SUBMIT_RECEIVER_SET_VALUE_DEF
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename E>
void set_error(BOOST_ASIO_MOVE_ARG(E) e)
BOOST_ASIO_RVALUE_REF_QUAL BOOST_ASIO_NOEXCEPT
{
execution::set_error(
BOOST_ASIO_MOVE_OR_LVALUE(
typename remove_cvref<Receiver>::type)(p_->r_),
BOOST_ASIO_MOVE_CAST(E)(e));
delete p_;
}
void set_done() BOOST_ASIO_RVALUE_REF_QUAL BOOST_ASIO_NOEXCEPT
{
execution::set_done(
BOOST_ASIO_MOVE_OR_LVALUE(
typename remove_cvref<Receiver>::type)(p_->r_));
delete p_;
}
};
template <typename Sender, typename Receiver>
struct submit_receiver
{
typename remove_cvref<Receiver>::type r_;
#if defined(BOOST_ASIO_HAS_MOVE)
typename connect_result<Sender,
submit_receiver_wrapper<Sender, Receiver> >::type state_;
#else // defined(BOOST_ASIO_HAS_MOVE)
typename connect_result<Sender,
const submit_receiver_wrapper<Sender, Receiver>& >::type state_;
#endif // defined(BOOST_ASIO_HAS_MOVE)
#if defined(BOOST_ASIO_HAS_MOVE)
template <typename S, typename R>
explicit submit_receiver(BOOST_ASIO_MOVE_ARG(S) s, BOOST_ASIO_MOVE_ARG(R) r)
: r_(BOOST_ASIO_MOVE_CAST(R)(r)),
state_(execution::connect(BOOST_ASIO_MOVE_CAST(S)(s),
submit_receiver_wrapper<Sender, Receiver>(this)))
{
}
#else // defined(BOOST_ASIO_HAS_MOVE)
explicit submit_receiver(Sender s, Receiver r)
: r_(r),
state_(execution::connect(s,
submit_receiver_wrapper<Sender, Receiver>(this)))
{
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
} // namespace detail
} // namespace execution
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename Sender, typename Receiver, typename... Args>
struct set_value_member<
boost::asio::execution::detail::submit_receiver_wrapper<
Sender, Receiver>,
void(Args...)>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
(boost::asio::execution::is_nothrow_receiver_of<Receiver, Args...>::value));
typedef void result_type;
};
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename Sender, typename Receiver>
struct set_value_member<
boost::asio::execution::detail::submit_receiver_wrapper<
Sender, Receiver>,
void()>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
boost::asio::execution::is_nothrow_receiver_of<Receiver>::value);
typedef void result_type;
};
#define BOOST_ASIO_PRIVATE_SUBMIT_RECEIVER_TRAIT_DEF(n) \
template <typename Sender, typename Receiver, \
BOOST_ASIO_VARIADIC_TPARAMS(n)> \
struct set_value_member< \
boost::asio::execution::detail::submit_receiver_wrapper< \
Sender, Receiver>, \
void(BOOST_ASIO_VARIADIC_TARGS(n))> \
{ \
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); \
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = \
(boost::asio::execution::is_nothrow_receiver_of<Receiver, \
BOOST_ASIO_VARIADIC_TARGS(n)>::value)); \
typedef void result_type; \
}; \
/**/
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SUBMIT_RECEIVER_TRAIT_DEF)
#undef BOOST_ASIO_PRIVATE_SUBMIT_RECEIVER_TRAIT_DEF
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
template <typename Sender, typename Receiver, typename E>
struct set_error_member<
boost::asio::execution::detail::submit_receiver_wrapper<
Sender, Receiver>, E>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
template <typename Sender, typename Receiver>
struct set_done_member<
boost::asio::execution::detail::submit_receiver_wrapper<
Sender, Receiver> >
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
} // namespace traits
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_DETAIL_SUBMIT_RECEIVER_HPP

View File

@@ -0,0 +1,92 @@
//
// execution/detail/void_receiver.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_DETAIL_VOID_RECEIVER_HPP
#define BOOST_ASIO_EXECUTION_DETAIL_VOID_RECEIVER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/traits/set_done_member.hpp>
#include <boost/asio/traits/set_error_member.hpp>
#include <boost/asio/traits/set_value_member.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
namespace detail {
struct void_receiver
{
void set_value() BOOST_ASIO_NOEXCEPT
{
}
template <typename E>
void set_error(BOOST_ASIO_MOVE_ARG(E)) BOOST_ASIO_NOEXCEPT
{
}
void set_done() BOOST_ASIO_NOEXCEPT
{
}
};
} // namespace detail
} // namespace execution
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
template <>
struct set_value_member<boost::asio::execution::detail::void_receiver, void()>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
template <typename E>
struct set_error_member<boost::asio::execution::detail::void_receiver, E>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
template <>
struct set_done_member<boost::asio::execution::detail::void_receiver>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef void result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
} // namespace traits
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_DETAIL_VOID_RECEIVER_HPP

View File

@@ -0,0 +1,289 @@
//
// execution/execute.hpp
// ~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_EXECUTE_HPP
#define BOOST_ASIO_EXECUTION_EXECUTE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/detail/as_invocable.hpp>
#include <boost/asio/execution/detail/as_receiver.hpp>
#include <boost/asio/traits/execute_member.hpp>
#include <boost/asio/traits/execute_free.hpp>
#include <boost/asio/detail/push_options.hpp>
#if defined(GENERATING_DOCUMENTATION)
namespace boost {
namespace asio {
namespace execution {
/// A customisation point that executes a function on an executor.
/**
* The name <tt>execution::execute</tt> denotes a customisation point object.
*
* For some subexpressions <tt>e</tt> and <tt>f</tt>, let <tt>E</tt> be a type
* such that <tt>decltype((e))</tt> is <tt>E</tt> and let <tt>F</tt> be a type
* such that <tt>decltype((f))</tt> is <tt>F</tt>. The expression
* <tt>execution::execute(e, f)</tt> is ill-formed if <tt>F</tt> does not model
* <tt>invocable</tt>, or if <tt>E</tt> does not model either <tt>executor</tt>
* or <tt>sender</tt>. Otherwise, it is expression-equivalent to:
*
* @li <tt>e.execute(f)</tt>, if that expression is valid. If the function
* selected does not execute the function object <tt>f</tt> on the executor
* <tt>e</tt>, the program is ill-formed with no diagnostic required.
*
* @li Otherwise, <tt>execute(e, f)</tt>, if that expression is valid, with
* overload resolution performed in a context that includes the declaration
* <tt>void execute();</tt> and that does not include a declaration of
* <tt>execution::execute</tt>. If the function selected by overload
* resolution does not execute the function object <tt>f</tt> on the executor
* <tt>e</tt>, the program is ill-formed with no diagnostic required.
*/
inline constexpr unspecified execute = unspecified;
/// A type trait that determines whether a @c execute expression is well-formed.
/**
* Class template @c can_execute is a trait that is derived from
* @c true_type if the expression <tt>execution::execute(std::declval<T>(),
* std::declval<F>())</tt> is well formed; otherwise @c false_type.
*/
template <typename T, typename F>
struct can_execute :
integral_constant<bool, automatically_determined>
{
};
} // namespace execution
} // namespace asio
} // namespace boost
#else // defined(GENERATING_DOCUMENTATION)
namespace boost {
namespace asio {
namespace execution {
template <typename T, typename R>
struct is_sender_to;
namespace detail {
template <typename S, typename R>
void submit_helper(BOOST_ASIO_MOVE_ARG(S) s, BOOST_ASIO_MOVE_ARG(R) r);
} // namespace detail
} // namespace execution
} // namespace asio
} // namespace boost
namespace boost_asio_execution_execute_fn {
using boost::asio::conditional;
using boost::asio::decay;
using boost::asio::declval;
using boost::asio::enable_if;
using boost::asio::execution::detail::as_receiver;
using boost::asio::execution::detail::is_as_invocable;
using boost::asio::execution::is_sender_to;
using boost::asio::false_type;
using boost::asio::result_of;
using boost::asio::traits::execute_free;
using boost::asio::traits::execute_member;
using boost::asio::true_type;
using boost::asio::void_type;
void execute();
enum overload_type
{
call_member,
call_free,
adapter,
ill_formed
};
template <typename Impl, typename T, typename F, typename = void,
typename = void, typename = void, typename = void, typename = void>
struct call_traits
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = ill_formed);
};
template <typename Impl, typename T, typename F>
struct call_traits<Impl, T, void(F),
typename enable_if<
execute_member<typename Impl::template proxy<T>::type, F>::is_valid
>::type> :
execute_member<typename Impl::template proxy<T>::type, F>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_member);
};
template <typename Impl, typename T, typename F>
struct call_traits<Impl, T, void(F),
typename enable_if<
!execute_member<typename Impl::template proxy<T>, F>::is_valid
>::type,
typename enable_if<
execute_free<T, F>::is_valid
>::type> :
execute_free<T, F>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_free);
};
template <typename Impl, typename T, typename F>
struct call_traits<Impl, T, void(F),
typename enable_if<
!execute_member<typename Impl::template proxy<T>::type, F>::is_valid
>::type,
typename enable_if<
!execute_free<T, F>::is_valid
>::type,
typename void_type<
typename result_of<typename decay<F>::type&()>::type
>::type,
typename enable_if<
!is_as_invocable<typename decay<F>::type>::value
>::type,
typename enable_if<
is_sender_to<T, as_receiver<typename decay<F>::type, T> >::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = adapter);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
struct impl
{
template <typename T>
struct proxy
{
#if defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
struct type
{
template <typename F>
auto execute(BOOST_ASIO_MOVE_ARG(F) f)
noexcept(
noexcept(
declval<typename conditional<true, T, F>::type>().execute(
BOOST_ASIO_MOVE_CAST(F)(f))
)
)
-> decltype(
declval<typename conditional<true, T, F>::type>().execute(
BOOST_ASIO_MOVE_CAST(F)(f))
);
};
#else // defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
typedef T type;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
};
template <typename T, typename F>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<impl, T, void(F)>::overload == call_member,
typename call_traits<impl, T, void(F)>::result_type
>::type
operator()(
BOOST_ASIO_MOVE_ARG(T) t,
BOOST_ASIO_MOVE_ARG(F) f) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<impl, T, void(F)>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(T)(t).execute(BOOST_ASIO_MOVE_CAST(F)(f));
}
template <typename T, typename F>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<impl, T, void(F)>::overload == call_free,
typename call_traits<impl, T, void(F)>::result_type
>::type
operator()(
BOOST_ASIO_MOVE_ARG(T) t,
BOOST_ASIO_MOVE_ARG(F) f) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<impl, T, void(F)>::is_noexcept))
{
return execute(BOOST_ASIO_MOVE_CAST(T)(t), BOOST_ASIO_MOVE_CAST(F)(f));
}
template <typename T, typename F>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<impl, T, void(F)>::overload == adapter,
typename call_traits<impl, T, void(F)>::result_type
>::type
operator()(
BOOST_ASIO_MOVE_ARG(T) t,
BOOST_ASIO_MOVE_ARG(F) f) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<impl, T, void(F)>::is_noexcept))
{
return boost::asio::execution::detail::submit_helper(
BOOST_ASIO_MOVE_CAST(T)(t),
as_receiver<typename decay<F>::type, T>(
BOOST_ASIO_MOVE_CAST(F)(f), 0));
}
};
template <typename T = impl>
struct static_instance
{
static const T instance;
};
template <typename T>
const T static_instance<T>::instance = {};
} // namespace boost_asio_execution_execute_fn
namespace boost {
namespace asio {
namespace execution {
namespace {
static BOOST_ASIO_CONSTEXPR const boost_asio_execution_execute_fn::impl&
execute = boost_asio_execution_execute_fn::static_instance<>::instance;
} // namespace
typedef boost_asio_execution_execute_fn::impl execute_t;
template <typename T, typename F>
struct can_execute :
integral_constant<bool,
boost_asio_execution_execute_fn::call_traits<
execute_t, T, void(F)>::overload !=
boost_asio_execution_execute_fn::ill_formed>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T, typename F>
constexpr bool can_execute_v = can_execute<T, F>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
} // namespace execution
} // namespace asio
} // namespace boost
#endif // defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_EXECUTE_HPP

View File

@@ -0,0 +1,254 @@
//
// execution/executor.hpp
// ~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_EXECUTOR_HPP
#define BOOST_ASIO_EXECUTION_EXECUTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/execute.hpp>
#include <boost/asio/execution/invocable_archetype.hpp>
#include <boost/asio/traits/equality_comparable.hpp>
#if defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_FREE_TRAIT) \
&& defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) \
&& defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
# define BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT 1
#endif // defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_FREE_TRAIT)
// && defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
// && defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
namespace detail {
template <typename T, typename F,
typename = void, typename = void, typename = void, typename = void,
typename = void, typename = void, typename = void, typename = void>
struct is_executor_of_impl : false_type
{
};
template <typename T, typename F>
struct is_executor_of_impl<T, F,
typename enable_if<
can_execute<typename add_const<T>::type, F>::value
>::type,
typename void_type<
typename result_of<typename decay<F>::type&()>::type
>::type,
typename enable_if<
is_constructible<typename decay<F>::type, F>::value
>::type,
typename enable_if<
is_move_constructible<typename decay<F>::type>::value
>::type,
#if defined(BOOST_ASIO_HAS_NOEXCEPT)
typename enable_if<
is_nothrow_copy_constructible<T>::value
>::type,
typename enable_if<
is_nothrow_destructible<T>::value
>::type,
#else // defined(BOOST_ASIO_HAS_NOEXCEPT)
typename enable_if<
is_copy_constructible<T>::value
>::type,
typename enable_if<
is_destructible<T>::value
>::type,
#endif // defined(BOOST_ASIO_HAS_NOEXCEPT)
typename enable_if<
traits::equality_comparable<T>::is_valid
>::type,
typename enable_if<
traits::equality_comparable<T>::is_noexcept
>::type> : true_type
{
};
template <typename T, typename = void>
struct executor_shape
{
typedef std::size_t type;
};
template <typename T>
struct executor_shape<T,
typename void_type<
typename T::shape_type
>::type>
{
typedef typename T::shape_type type;
};
template <typename T, typename Default, typename = void>
struct executor_index
{
typedef Default type;
};
template <typename T, typename Default>
struct executor_index<T, Default,
typename void_type<
typename T::index_type
>::type>
{
typedef typename T::index_type type;
};
} // namespace detail
/// The is_executor trait detects whether a type T satisfies the
/// execution::executor concept.
/**
* Class template @c is_executor is a UnaryTypeTrait that is derived from @c
* true_type if the type @c T meets the concept definition for an executor,
* otherwise @c false_type.
*/
template <typename T>
struct is_executor :
#if defined(GENERATING_DOCUMENTATION)
integral_constant<bool, automatically_determined>
#else // defined(GENERATING_DOCUMENTATION)
detail::is_executor_of_impl<T, invocable_archetype>
#endif // defined(GENERATING_DOCUMENTATION)
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_CONSTEXPR const bool is_executor_v = is_executor<T>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#if defined(BOOST_ASIO_HAS_CONCEPTS)
template <typename T>
BOOST_ASIO_CONCEPT executor = is_executor<T>::value;
#define BOOST_ASIO_EXECUTION_EXECUTOR ::boost::asio::execution::executor
#else // defined(BOOST_ASIO_HAS_CONCEPTS)
#define BOOST_ASIO_EXECUTION_EXECUTOR typename
#endif // defined(BOOST_ASIO_HAS_CONCEPTS)
/// The is_executor_of trait detects whether a type T satisfies the
/// execution::executor_of concept for some set of value arguments.
/**
* Class template @c is_executor_of is a type trait that is derived from @c
* true_type if the type @c T meets the concept definition for an executor
* that is invocable with a function object of type @c F, otherwise @c
* false_type.
*/
template <typename T, typename F>
struct is_executor_of :
#if defined(GENERATING_DOCUMENTATION)
integral_constant<bool, automatically_determined>
#else // defined(GENERATING_DOCUMENTATION)
integral_constant<bool,
is_executor<T>::value && detail::is_executor_of_impl<T, F>::value
>
#endif // defined(GENERATING_DOCUMENTATION)
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T, typename F>
BOOST_ASIO_CONSTEXPR const bool is_executor_of_v =
is_executor_of<T, F>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#if defined(BOOST_ASIO_HAS_CONCEPTS)
template <typename T, typename F>
BOOST_ASIO_CONCEPT executor_of = is_executor_of<T, F>::value;
#define BOOST_ASIO_EXECUTION_EXECUTOR_OF(f) \
::boost::asio::execution::executor_of<f>
#else // defined(BOOST_ASIO_HAS_CONCEPTS)
#define BOOST_ASIO_EXECUTION_EXECUTOR_OF typename
#endif // defined(BOOST_ASIO_HAS_CONCEPTS)
/// The executor_shape trait detects the type used by an executor to represent
/// the shape of a bulk operation.
/**
* Class template @c executor_shape is a type trait with a nested type alias
* @c type whose type is @c T::shape_type if @c T::shape_type is valid,
* otherwise @c std::size_t.
*/
template <typename T>
struct executor_shape
#if !defined(GENERATING_DOCUMENTATION)
: detail::executor_shape<T>
#endif // !defined(GENERATING_DOCUMENTATION)
{
#if defined(GENERATING_DOCUMENTATION)
/// @c T::shape_type if @c T::shape_type is valid, otherwise @c std::size_t.
typedef automatically_determined type;
#endif // defined(GENERATING_DOCUMENTATION)
};
#if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
template <typename T>
using executor_shape_t = typename executor_shape<T>::type;
#endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
/// The executor_index trait detects the type used by an executor to represent
/// an index within a bulk operation.
/**
* Class template @c executor_index is a type trait with a nested type alias
* @c type whose type is @c T::index_type if @c T::index_type is valid,
* otherwise @c executor_shape_t<T>.
*/
template <typename T>
struct executor_index
#if !defined(GENERATING_DOCUMENTATION)
: detail::executor_index<T, typename executor_shape<T>::type>
#endif // !defined(GENERATING_DOCUMENTATION)
{
#if defined(GENERATING_DOCUMENTATION)
/// @c T::index_type if @c T::index_type is valid, otherwise
/// @c executor_shape_t<T>.
typedef automatically_determined type;
#endif // defined(GENERATING_DOCUMENTATION)
};
#if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
template <typename T>
using executor_index_t = typename executor_index<T>::type;
#endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_EXECUTOR_HPP

View File

@@ -0,0 +1,42 @@
//
// exection/impl/bad_executor.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_IMPL_BAD_EXECUTOR_IPP
#define BOOST_ASIO_EXECUTION_IMPL_BAD_EXECUTOR_IPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/execution/bad_executor.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
bad_executor::bad_executor() BOOST_ASIO_NOEXCEPT
{
}
const char* bad_executor::what() const BOOST_ASIO_NOEXCEPT_OR_NOTHROW
{
return "bad executor";
}
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_IMPL_BAD_EXECUTOR_IPP

View File

@@ -0,0 +1,38 @@
//
// exection/impl/receiver_invocation_error.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_IMPL_RECEIVER_INVOCATION_ERROR_IPP
#define BOOST_ASIO_EXECUTION_IMPL_RECEIVER_INVOCATION_ERROR_IPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/execution/receiver_invocation_error.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
receiver_invocation_error::receiver_invocation_error()
: std::runtime_error("receiver invocation error")
{
}
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_IMPL_RECEIVER_INVOCATION_ERROR_IPP

View File

@@ -0,0 +1,73 @@
//
// execution/invocable_archetype.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_INVOCABLE_ARCHETYPE_HPP
#define BOOST_ASIO_EXECUTION_INVOCABLE_ARCHETYPE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/detail/variadic_templates.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
/// An archetypal function object used for determining adherence to the
/// execution::executor concept.
struct invocable_archetype
{
#if !defined(GENERATING_DOCUMENTATION)
// Necessary for compatibility with a C++03 implementation of result_of.
typedef void result_type;
#endif // !defined(GENERATING_DOCUMENTATION)
#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) \
|| defined(GENERATING_DOCUMENTATION)
/// Function call operator.
template <typename... Args>
void operator()(BOOST_ASIO_MOVE_ARG(Args)...)
{
}
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
// || defined(GENERATING_DOCUMENTATION)
void operator()()
{
}
#define BOOST_ASIO_PRIVATE_INVOCABLE_ARCHETYPE_CALL_DEF(n) \
template <BOOST_ASIO_VARIADIC_TPARAMS(n)> \
void operator()(BOOST_ASIO_VARIADIC_UNNAMED_MOVE_PARAMS(n)) \
{ \
} \
/**/
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_INVOCABLE_ARCHETYPE_CALL_DEF)
#undef BOOST_ASIO_PRIVATE_INVOCABLE_ARCHETYPE_CALL_DEF
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
// || defined(GENERATING_DOCUMENTATION)
};
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_INVOCABLE_ARCHETYPE_HPP

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,228 @@
//
// execution/occupancy.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_OCCUPANCY_HPP
#define BOOST_ASIO_EXECUTION_OCCUPANCY_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/scheduler.hpp>
#include <boost/asio/execution/sender.hpp>
#include <boost/asio/is_applicable_property.hpp>
#include <boost/asio/traits/query_static_constexpr_member.hpp>
#include <boost/asio/traits/static_query.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
#if defined(GENERATING_DOCUMENTATION)
namespace execution {
/// A property that gives an estimate of the number of execution agents that
/// should occupy the associated execution context.
struct occupancy_t
{
/// The occupancy_t property applies to executors, senders, and schedulers.
template <typename T>
static constexpr bool is_applicable_property_v =
is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
/// The occupancy_t property cannot be required.
static constexpr bool is_requirable = false;
/// The occupancy_t property cannot be preferred.
static constexpr bool is_preferable = false;
/// The type returned by queries against an @c any_executor.
typedef std::size_t polymorphic_query_result_type;
};
/// A special value used for accessing the occupancy_t property.
constexpr occupancy_t occupancy;
} // namespace execution
#else // defined(GENERATING_DOCUMENTATION)
namespace execution {
namespace detail {
template <int I = 0>
struct occupancy_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<T>::value
|| conditional<
is_executor<T>::value,
false_type,
is_sender<T>
>::type::value
|| conditional<
is_executor<T>::value,
false_type,
is_scheduler<T>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = false);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = false);
typedef std::size_t polymorphic_query_result_type;
BOOST_ASIO_CONSTEXPR occupancy_t()
{
}
template <typename T>
struct static_proxy
{
#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
struct type
{
template <typename P>
static constexpr auto query(BOOST_ASIO_MOVE_ARG(P) p)
noexcept(
noexcept(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
)
-> decltype(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
{
return T::query(BOOST_ASIO_MOVE_CAST(P)(p));
}
};
#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
typedef T type;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename static_proxy<T>::type, occupancy_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
query_static_constexpr_member<T>::is_noexcept))
{
return query_static_constexpr_member<T>::value();
}
template <typename E, typename T = decltype(occupancy_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= occupancy_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_CONSTEXPR)
static const occupancy_t instance;
#endif // !defined(BOOST_ASIO_HAS_CONSTEXPR)
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I> template <typename E, typename T>
const T occupancy_t<I>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_CONSTEXPR)
template <int I>
const occupancy_t<I> occupancy_t<I>::instance;
#endif
} // namespace detail
typedef detail::occupancy_t<> occupancy_t;
#if defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
constexpr occupancy_t occupancy;
#else // defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
namespace { static const occupancy_t& occupancy = occupancy_t::instance; }
#endif
} // namespace execution
#if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
struct is_applicable_property<T, execution::occupancy_t>
: integral_constant<bool,
execution::is_executor<T>::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_sender<T>
>::type::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_scheduler<T>
>::type::value>
{
};
#endif // !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|| !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
struct static_query<T, execution::occupancy_t,
typename enable_if<
execution::detail::occupancy_t<0>::
query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename execution::detail::occupancy_t<0>::
query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return execution::detail::occupancy_t<0>::
query_static_constexpr_member<T>::value();
}
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
} // namespace traits
#endif // defined(GENERATING_DOCUMENTATION)
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_OCCUPANCY_HPP

View File

@@ -0,0 +1,96 @@
//
// execution/operation_state.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_OPERATION_STATE_HPP
#define BOOST_ASIO_EXECUTION_OPERATION_STATE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/start.hpp>
#if defined(BOOST_ASIO_HAS_DEDUCED_START_FREE_TRAIT) \
&& defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
# define BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_OPERATION_STATE_TRAIT 1
#endif // defined(BOOST_ASIO_HAS_DEDUCED_START_FREE_TRAIT)
// && defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
namespace detail {
template <typename T>
struct is_operation_state_base :
integral_constant<bool,
is_destructible<T>::value
&& is_object<T>::value
>
{
};
} // namespace detail
/// The is_operation_state trait detects whether a type T satisfies the
/// execution::operation_state concept.
/**
* Class template @c is_operation_state is a type trait that is derived from
* @c true_type if the type @c T meets the concept definition for an
* @c operation_state, otherwise @c false_type.
*/
template <typename T>
struct is_operation_state :
#if defined(GENERATING_DOCUMENTATION)
integral_constant<bool, automatically_determined>
#else // defined(GENERATING_DOCUMENTATION)
conditional<
can_start<typename add_lvalue_reference<T>::type>::value
&& is_nothrow_start<typename add_lvalue_reference<T>::type>::value,
detail::is_operation_state_base<T>,
false_type
>::type
#endif // defined(GENERATING_DOCUMENTATION)
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_CONSTEXPR const bool is_operation_state_v =
is_operation_state<T>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#if defined(BOOST_ASIO_HAS_CONCEPTS)
template <typename T>
BOOST_ASIO_CONCEPT operation_state = is_operation_state<T>::value;
#define BOOST_ASIO_EXECUTION_OPERATION_STATE \
::boost::asio::execution::operation_state
#else // defined(BOOST_ASIO_HAS_CONCEPTS)
#define BOOST_ASIO_EXECUTION_OPERATION_STATE typename
#endif // defined(BOOST_ASIO_HAS_CONCEPTS)
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_OPERATION_STATE_HPP

View File

@@ -0,0 +1,869 @@
//
// execution/outstanding_work.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_OUTSTANDING_WORK_HPP
#define BOOST_ASIO_EXECUTION_OUTSTANDING_WORK_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/scheduler.hpp>
#include <boost/asio/execution/sender.hpp>
#include <boost/asio/is_applicable_property.hpp>
#include <boost/asio/query.hpp>
#include <boost/asio/traits/query_free.hpp>
#include <boost/asio/traits/query_member.hpp>
#include <boost/asio/traits/query_static_constexpr_member.hpp>
#include <boost/asio/traits/static_query.hpp>
#include <boost/asio/traits/static_require.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
#if defined(GENERATING_DOCUMENTATION)
namespace execution {
/// A property to describe whether task submission is likely in the future.
struct outstanding_work_t
{
/// The outstanding_work_t property applies to executors, senders, and
/// schedulers.
template <typename T>
static constexpr bool is_applicable_property_v =
is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
/// The top-level outstanding_work_t property cannot be required.
static constexpr bool is_requirable = false;
/// The top-level outstanding_work_t property cannot be preferred.
static constexpr bool is_preferable = false;
/// The type returned by queries against an @c any_executor.
typedef outstanding_work_t polymorphic_query_result_type;
/// A sub-property that indicates that the executor does not represent likely
/// future submission of a function object.
struct untracked_t
{
/// The outstanding_work_t::untracked_t property applies to executors,
/// senders, and schedulers.
template <typename T>
static constexpr bool is_applicable_property_v =
is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
/// The outstanding_work_t::untracked_t property can be required.
static constexpr bool is_requirable = true;
/// The outstanding_work_t::untracked_t property can be preferred.
static constexpr bool is_preferable = true;
/// The type returned by queries against an @c any_executor.
typedef outstanding_work_t polymorphic_query_result_type;
/// Default constructor.
constexpr untracked_t();
/// Get the value associated with a property object.
/**
* @returns untracked_t();
*/
static constexpr outstanding_work_t value();
};
/// A sub-property that indicates that the executor represents likely
/// future submission of a function object.
struct tracked_t
{
/// The outstanding_work_t::untracked_t property applies to executors,
/// senders, and schedulers.
template <typename T>
static constexpr bool is_applicable_property_v =
is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
/// The outstanding_work_t::tracked_t property can be required.
static constexpr bool is_requirable = true;
/// The outstanding_work_t::tracked_t property can be preferred.
static constexpr bool is_preferable = true;
/// The type returned by queries against an @c any_executor.
typedef outstanding_work_t polymorphic_query_result_type;
/// Default constructor.
constexpr tracked_t();
/// Get the value associated with a property object.
/**
* @returns tracked_t();
*/
static constexpr outstanding_work_t value();
};
/// A special value used for accessing the outstanding_work_t::untracked_t
/// property.
static constexpr untracked_t untracked;
/// A special value used for accessing the outstanding_work_t::tracked_t
/// property.
static constexpr tracked_t tracked;
/// Default constructor.
constexpr outstanding_work_t();
/// Construct from a sub-property value.
constexpr outstanding_work_t(untracked_t);
/// Construct from a sub-property value.
constexpr outstanding_work_t(tracked_t);
/// Compare property values for equality.
friend constexpr bool operator==(
const outstanding_work_t& a, const outstanding_work_t& b) noexcept;
/// Compare property values for inequality.
friend constexpr bool operator!=(
const outstanding_work_t& a, const outstanding_work_t& b) noexcept;
};
/// A special value used for accessing the outstanding_work_t property.
constexpr outstanding_work_t outstanding_work;
} // namespace execution
#else // defined(GENERATING_DOCUMENTATION)
namespace execution {
namespace detail {
namespace outstanding_work {
template <int I> struct untracked_t;
template <int I> struct tracked_t;
} // namespace outstanding_work
template <int I = 0>
struct outstanding_work_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<T>::value
|| conditional<
is_executor<T>::value,
false_type,
is_sender<T>
>::type::value
|| conditional<
is_executor<T>::value,
false_type,
is_scheduler<T>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = false);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = false);
typedef outstanding_work_t polymorphic_query_result_type;
typedef detail::outstanding_work::untracked_t<I> untracked_t;
typedef detail::outstanding_work::tracked_t<I> tracked_t;
BOOST_ASIO_CONSTEXPR outstanding_work_t()
: value_(-1)
{
}
BOOST_ASIO_CONSTEXPR outstanding_work_t(untracked_t)
: value_(0)
{
}
BOOST_ASIO_CONSTEXPR outstanding_work_t(tracked_t)
: value_(1)
{
}
template <typename T>
struct proxy
{
#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
struct type
{
template <typename P>
auto query(BOOST_ASIO_MOVE_ARG(P) p) const
noexcept(
noexcept(
declval<typename conditional<true, T, P>::type>().query(
BOOST_ASIO_MOVE_CAST(P)(p))
)
)
-> decltype(
declval<typename conditional<true, T, P>::type>().query(
BOOST_ASIO_MOVE_CAST(P)(p))
);
};
#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
typedef T type;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
};
template <typename T>
struct static_proxy
{
#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
struct type
{
template <typename P>
static constexpr auto query(BOOST_ASIO_MOVE_ARG(P) p)
noexcept(
noexcept(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
)
-> decltype(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
{
return T::query(BOOST_ASIO_MOVE_CAST(P)(p));
}
};
#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
typedef T type;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
};
template <typename T>
struct query_member :
traits::query_member<typename proxy<T>::type, outstanding_work_t> {};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename static_proxy<T>::type, outstanding_work_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
query_static_constexpr_member<T>::is_noexcept))
{
return query_static_constexpr_member<T>::value();
}
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename traits::static_query<T, untracked_t>::result_type
static_query(
typename enable_if<
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
traits::static_query<T, untracked_t>::is_valid
>::type* = 0) BOOST_ASIO_NOEXCEPT
{
return traits::static_query<T, untracked_t>::value();
}
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename traits::static_query<T, tracked_t>::result_type
static_query(
typename enable_if<
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::static_query<T, untracked_t>::is_valid
>::type* = 0,
typename enable_if<
traits::static_query<T, tracked_t>::is_valid
>::type* = 0) BOOST_ASIO_NOEXCEPT
{
return traits::static_query<T, tracked_t>::value();
}
template <typename E,
typename T = decltype(outstanding_work_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= outstanding_work_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
friend BOOST_ASIO_CONSTEXPR bool operator==(
const outstanding_work_t& a, const outstanding_work_t& b)
{
return a.value_ == b.value_;
}
friend BOOST_ASIO_CONSTEXPR bool operator!=(
const outstanding_work_t& a, const outstanding_work_t& b)
{
return a.value_ != b.value_;
}
struct convertible_from_outstanding_work_t
{
BOOST_ASIO_CONSTEXPR convertible_from_outstanding_work_t(outstanding_work_t)
{
}
};
template <typename Executor>
friend BOOST_ASIO_CONSTEXPR outstanding_work_t query(
const Executor& ex, convertible_from_outstanding_work_t,
typename enable_if<
can_query<const Executor&, untracked_t>::value
>::type* = 0)
#if !defined(__clang__) // Clang crashes if noexcept is used here.
#if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&,
outstanding_work_t<>::untracked_t>::value))
#else // defined(BOOST_ASIO_MSVC)
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&, untracked_t>::value))
#endif // defined(BOOST_ASIO_MSVC)
#endif // !defined(__clang__)
{
return boost::asio::query(ex, untracked_t());
}
template <typename Executor>
friend BOOST_ASIO_CONSTEXPR outstanding_work_t query(
const Executor& ex, convertible_from_outstanding_work_t,
typename enable_if<
!can_query<const Executor&, untracked_t>::value
>::type* = 0,
typename enable_if<
can_query<const Executor&, tracked_t>::value
>::type* = 0)
#if !defined(__clang__) // Clang crashes if noexcept is used here.
#if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&,
outstanding_work_t<>::tracked_t>::value))
#else // defined(BOOST_ASIO_MSVC)
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&, tracked_t>::value))
#endif // defined(BOOST_ASIO_MSVC)
#endif // !defined(__clang__)
{
return boost::asio::query(ex, tracked_t());
}
BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(untracked_t, untracked);
BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(tracked_t, tracked);
#if !defined(BOOST_ASIO_HAS_CONSTEXPR)
static const outstanding_work_t instance;
#endif // !defined(BOOST_ASIO_HAS_CONSTEXPR)
private:
int value_;
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I> template <typename E, typename T>
const T outstanding_work_t<I>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_CONSTEXPR)
template <int I>
const outstanding_work_t<I> outstanding_work_t<I>::instance;
#endif
template <int I>
const typename outstanding_work_t<I>::untracked_t
outstanding_work_t<I>::untracked;
template <int I>
const typename outstanding_work_t<I>::tracked_t
outstanding_work_t<I>::tracked;
namespace outstanding_work {
template <int I = 0>
struct untracked_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<T>::value
|| conditional<
is_executor<T>::value,
false_type,
is_sender<T>
>::type::value
|| conditional<
is_executor<T>::value,
false_type,
is_scheduler<T>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = true);
typedef outstanding_work_t<I> polymorphic_query_result_type;
BOOST_ASIO_CONSTEXPR untracked_t()
{
}
template <typename T>
struct query_member :
traits::query_member<
typename outstanding_work_t<I>::template proxy<T>::type, untracked_t> {};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename outstanding_work_t<I>::template static_proxy<T>::type,
untracked_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
query_static_constexpr_member<T>::is_noexcept))
{
return query_static_constexpr_member<T>::value();
}
template <typename T>
static BOOST_ASIO_CONSTEXPR untracked_t static_query(
typename enable_if<
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_free<T, untracked_t>::is_valid
>::type* = 0,
typename enable_if<
!can_query<T, tracked_t<I> >::value
>::type* = 0) BOOST_ASIO_NOEXCEPT
{
return untracked_t();
}
template <typename E, typename T = decltype(untracked_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= untracked_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
static BOOST_ASIO_CONSTEXPR outstanding_work_t<I> value()
{
return untracked_t();
}
friend BOOST_ASIO_CONSTEXPR bool operator==(
const untracked_t&, const untracked_t&)
{
return true;
}
friend BOOST_ASIO_CONSTEXPR bool operator!=(
const untracked_t&, const untracked_t&)
{
return false;
}
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I> template <typename E, typename T>
const T untracked_t<I>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I = 0>
struct tracked_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<T>::value
|| conditional<
is_executor<T>::value,
false_type,
is_sender<T>
>::type::value
|| conditional<
is_executor<T>::value,
false_type,
is_scheduler<T>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = true);
typedef outstanding_work_t<I> polymorphic_query_result_type;
BOOST_ASIO_CONSTEXPR tracked_t()
{
}
template <typename T>
struct query_member :
traits::query_member<
typename outstanding_work_t<I>::template proxy<T>::type, tracked_t> {};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename outstanding_work_t<I>::template static_proxy<T>::type,
tracked_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
query_static_constexpr_member<T>::is_noexcept))
{
return query_static_constexpr_member<T>::value();
}
template <typename E, typename T = decltype(tracked_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= tracked_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
static BOOST_ASIO_CONSTEXPR outstanding_work_t<I> value()
{
return tracked_t();
}
friend BOOST_ASIO_CONSTEXPR bool operator==(
const tracked_t&, const tracked_t&)
{
return true;
}
friend BOOST_ASIO_CONSTEXPR bool operator!=(
const tracked_t&, const tracked_t&)
{
return false;
}
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I> template <typename E, typename T>
const T tracked_t<I>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
} // namespace outstanding_work
} // namespace detail
typedef detail::outstanding_work_t<> outstanding_work_t;
#if defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
constexpr outstanding_work_t outstanding_work;
#else // defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
namespace { static const outstanding_work_t&
outstanding_work = outstanding_work_t::instance; }
#endif
} // namespace execution
#if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
struct is_applicable_property<T, execution::outstanding_work_t>
: integral_constant<bool,
execution::is_executor<T>::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_sender<T>
>::type::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_scheduler<T>
>::type::value>
{
};
template <typename T>
struct is_applicable_property<T, execution::outstanding_work_t::untracked_t>
: integral_constant<bool,
execution::is_executor<T>::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_sender<T>
>::type::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_scheduler<T>
>::type::value>
{
};
template <typename T>
struct is_applicable_property<T, execution::outstanding_work_t::tracked_t>
: integral_constant<bool,
execution::is_executor<T>::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_sender<T>
>::type::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_scheduler<T>
>::type::value>
{
};
#endif // !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
template <typename T>
struct query_free_default<T, execution::outstanding_work_t,
typename enable_if<
can_query<T, execution::outstanding_work_t::untracked_t>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
(is_nothrow_query<T, execution::outstanding_work_t::untracked_t>::value));
typedef execution::outstanding_work_t result_type;
};
template <typename T>
struct query_free_default<T, execution::outstanding_work_t,
typename enable_if<
!can_query<T, execution::outstanding_work_t::untracked_t>::value
&& can_query<T, execution::outstanding_work_t::tracked_t>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
(is_nothrow_query<T, execution::outstanding_work_t::tracked_t>::value));
typedef execution::outstanding_work_t result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|| !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
struct static_query<T, execution::outstanding_work_t,
typename enable_if<
execution::detail::outstanding_work_t<0>::
query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename execution::detail::outstanding_work_t<0>::
query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return execution::detail::outstanding_work_t<0>::
query_static_constexpr_member<T>::value();
}
};
template <typename T>
struct static_query<T, execution::outstanding_work_t,
typename enable_if<
!execution::detail::outstanding_work_t<0>::
query_static_constexpr_member<T>::is_valid
&& !execution::detail::outstanding_work_t<0>::
query_member<T>::is_valid
&& traits::static_query<T,
execution::outstanding_work_t::untracked_t>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename traits::static_query<T,
execution::outstanding_work_t::untracked_t>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return traits::static_query<T,
execution::outstanding_work_t::untracked_t>::value();
}
};
template <typename T>
struct static_query<T, execution::outstanding_work_t,
typename enable_if<
!execution::detail::outstanding_work_t<0>::
query_static_constexpr_member<T>::is_valid
&& !execution::detail::outstanding_work_t<0>::
query_member<T>::is_valid
&& !traits::static_query<T,
execution::outstanding_work_t::untracked_t>::is_valid
&& traits::static_query<T,
execution::outstanding_work_t::tracked_t>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename traits::static_query<T,
execution::outstanding_work_t::tracked_t>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return traits::static_query<T,
execution::outstanding_work_t::tracked_t>::value();
}
};
template <typename T>
struct static_query<T, execution::outstanding_work_t::untracked_t,
typename enable_if<
execution::detail::outstanding_work::untracked_t<0>::
query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename execution::detail::outstanding_work::untracked_t<0>::
query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return execution::detail::outstanding_work::untracked_t<0>::
query_static_constexpr_member<T>::value();
}
};
template <typename T>
struct static_query<T, execution::outstanding_work_t::untracked_t,
typename enable_if<
!execution::detail::outstanding_work::untracked_t<0>::
query_static_constexpr_member<T>::is_valid
&& !execution::detail::outstanding_work::untracked_t<0>::
query_member<T>::is_valid
&& !traits::query_free<T,
execution::outstanding_work_t::untracked_t>::is_valid
&& !can_query<T, execution::outstanding_work_t::tracked_t>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef execution::outstanding_work_t::untracked_t result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return result_type();
}
};
template <typename T>
struct static_query<T, execution::outstanding_work_t::tracked_t,
typename enable_if<
execution::detail::outstanding_work::tracked_t<0>::
query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename execution::detail::outstanding_work::tracked_t<0>::
query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return execution::detail::outstanding_work::tracked_t<0>::
query_static_constexpr_member<T>::value();
}
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT)
template <typename T>
struct static_require<T, execution::outstanding_work_t::untracked_t,
typename enable_if<
static_query<T, execution::outstanding_work_t::untracked_t>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid =
(is_same<typename static_query<T,
execution::outstanding_work_t::untracked_t>::result_type,
execution::outstanding_work_t::untracked_t>::value));
};
template <typename T>
struct static_require<T, execution::outstanding_work_t::tracked_t,
typename enable_if<
static_query<T, execution::outstanding_work_t::tracked_t>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid =
(is_same<typename static_query<T,
execution::outstanding_work_t::tracked_t>::result_type,
execution::outstanding_work_t::tracked_t>::value));
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT)
} // namespace traits
#endif // defined(GENERATING_DOCUMENTATION)
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_OUTSTANDING_WORK_HPP

View File

@@ -0,0 +1,333 @@
//
// execution/prefer_only.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_PREFER_ONLY_HPP
#define BOOST_ASIO_EXECUTION_PREFER_ONLY_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/is_applicable_property.hpp>
#include <boost/asio/prefer.hpp>
#include <boost/asio/query.hpp>
#include <boost/asio/traits/static_query.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
#if defined(GENERATING_DOCUMENTATION)
namespace execution {
/// A property adapter that is used with the polymorphic executor wrapper
/// to mark properties as preferable, but not requirable.
template <typename Property>
struct prefer_only
{
/// The prefer_only adapter applies to the same types as the nested property.
template <typename T>
static constexpr bool is_applicable_property_v =
is_applicable_property<T, Property>::value;
/// The context_t property cannot be required.
static constexpr bool is_requirable = false;
/// The context_t property can be preferred, it the underlying property can
/// be preferred.
/**
* @c true if @c Property::is_preferable is @c true, otherwise @c false.
*/
static constexpr bool is_preferable = automatically_determined;
/// The type returned by queries against an @c any_executor.
typedef typename Property::polymorphic_query_result_type
polymorphic_query_result_type;
};
} // namespace execution
#else // defined(GENERATING_DOCUMENTATION)
namespace execution {
namespace detail {
template <typename InnerProperty, typename = void>
struct prefer_only_is_preferable
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = false);
};
template <typename InnerProperty>
struct prefer_only_is_preferable<InnerProperty,
typename enable_if<
InnerProperty::is_preferable
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = true);
};
template <typename InnerProperty, typename = void>
struct prefer_only_polymorphic_query_result_type
{
};
template <typename InnerProperty>
struct prefer_only_polymorphic_query_result_type<InnerProperty,
typename void_type<
typename InnerProperty::polymorphic_query_result_type
>::type>
{
typedef typename InnerProperty::polymorphic_query_result_type
polymorphic_query_result_type;
};
template <typename InnerProperty, typename = void>
struct prefer_only_property
{
InnerProperty property;
prefer_only_property(const InnerProperty& p)
: property(p)
{
}
};
#if defined(BOOST_ASIO_HAS_DECLTYPE) \
&& defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
template <typename InnerProperty>
struct prefer_only_property<InnerProperty,
typename void_type<
decltype(boost::asio::declval<const InnerProperty>().value())
>::type>
{
InnerProperty property;
prefer_only_property(const InnerProperty& p)
: property(p)
{
}
BOOST_ASIO_CONSTEXPR auto value() const
BOOST_ASIO_NOEXCEPT_IF((
noexcept(boost::asio::declval<const InnerProperty>().value())))
-> decltype(boost::asio::declval<const InnerProperty>().value())
{
return property.value();
}
};
#else // defined(BOOST_ASIO_HAS_DECLTYPE)
// && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
struct prefer_only_memfns_base
{
void value();
};
template <typename T>
struct prefer_only_memfns_derived
: T, prefer_only_memfns_base
{
};
template <typename T, T>
struct prefer_only_memfns_check
{
};
template <typename>
char (&prefer_only_value_memfn_helper(...))[2];
template <typename T>
char prefer_only_value_memfn_helper(
prefer_only_memfns_check<
void (prefer_only_memfns_base::*)(),
&prefer_only_memfns_derived<T>::value>*);
template <typename InnerProperty>
struct prefer_only_property<InnerProperty,
typename enable_if<
sizeof(prefer_only_value_memfn_helper<InnerProperty>(0)) != 1
&& !is_same<typename InnerProperty::polymorphic_query_result_type,
void>::value
>::type>
{
InnerProperty property;
prefer_only_property(const InnerProperty& p)
: property(p)
{
}
BOOST_ASIO_CONSTEXPR typename InnerProperty::polymorphic_query_result_type
value() const
{
return property.value();
}
};
#endif // defined(BOOST_ASIO_HAS_DECLTYPE)
// && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
} // namespace detail
template <typename InnerProperty>
struct prefer_only :
detail::prefer_only_is_preferable<InnerProperty>,
detail::prefer_only_polymorphic_query_result_type<InnerProperty>,
detail::prefer_only_property<InnerProperty>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = false);
BOOST_ASIO_CONSTEXPR prefer_only(const InnerProperty& p)
: detail::prefer_only_property<InnerProperty>(p)
{
}
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename traits::static_query<T, InnerProperty>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
traits::static_query<T, InnerProperty>::is_noexcept))
{
return traits::static_query<T, InnerProperty>::value();
}
template <typename E, typename T = decltype(prefer_only::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= prefer_only::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename Executor, typename Property>
friend BOOST_ASIO_CONSTEXPR
typename prefer_result<const Executor&, const InnerProperty&>::type
prefer(const Executor& ex, const prefer_only<Property>& p,
typename enable_if<
is_same<Property, InnerProperty>::value
>::type* = 0,
typename enable_if<
can_prefer<const Executor&, const InnerProperty&>::value
>::type* = 0)
#if !defined(BOOST_ASIO_MSVC) \
&& !defined(__clang__) // Clang crashes if noexcept is used here.
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_prefer<const Executor&, const InnerProperty&>::value))
#endif // !defined(BOOST_ASIO_MSVC)
// && !defined(__clang__)
{
return boost::asio::prefer(ex, p.property);
}
template <typename Executor, typename Property>
friend BOOST_ASIO_CONSTEXPR
typename query_result<const Executor&, const InnerProperty&>::type
query(const Executor& ex, const prefer_only<Property>& p,
typename enable_if<
is_same<Property, InnerProperty>::value
>::type* = 0,
typename enable_if<
can_query<const Executor&, const InnerProperty&>::value
>::type* = 0)
#if !defined(BOOST_ASIO_MSVC) \
&& !defined(__clang__) // Clang crashes if noexcept is used here.
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&, const InnerProperty&>::value))
#endif // !defined(BOOST_ASIO_MSVC)
// && !defined(__clang__)
{
return boost::asio::query(ex, p.property);
}
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename InnerProperty> template <typename E, typename T>
const T prefer_only<InnerProperty>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
} // namespace execution
template <typename T, typename InnerProperty>
struct is_applicable_property<T, execution::prefer_only<InnerProperty> >
: is_applicable_property<T, InnerProperty>
{
};
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|| !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T, typename InnerProperty>
struct static_query<T, execution::prefer_only<InnerProperty> > :
static_query<T, const InnerProperty&>
{
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT)
template <typename T, typename InnerProperty>
struct prefer_free_default<T, execution::prefer_only<InnerProperty>,
typename enable_if<
can_prefer<const T&, const InnerProperty&>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
(is_nothrow_prefer<const T&, const InnerProperty&>::value));
typedef typename prefer_result<const T&,
const InnerProperty&>::type result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
template <typename T, typename InnerProperty>
struct query_free<T, execution::prefer_only<InnerProperty>,
typename enable_if<
can_query<const T&, const InnerProperty&>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
(is_nothrow_query<const T&, const InnerProperty&>::value));
typedef typename query_result<const T&,
const InnerProperty&>::type result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
} // namespace traits
#endif // defined(GENERATING_DOCUMENTATION)
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_PREFER_ONLY_HPP

View File

@@ -0,0 +1,282 @@
//
// execution/receiver.hpp
// ~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_RECEIVER_HPP
#define BOOST_ASIO_EXECUTION_RECEIVER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/detail/variadic_templates.hpp>
#include <boost/asio/execution/set_done.hpp>
#include <boost/asio/execution/set_error.hpp>
#include <boost/asio/execution/set_value.hpp>
#if defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
# include <exception>
#else // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
# include <boost/system/error_code.hpp>
#endif // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
#if defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_FREE_TRAIT) \
&& defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT) \
&& defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_FREE_TRAIT) \
&& defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT) \
&& defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_FREE_TRAIT) \
&& defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT) \
&& defined(BOOST_ASIO_HAS_DEDUCED_RECEIVER_OF_FREE_TRAIT) \
&& defined(BOOST_ASIO_HAS_DEDUCED_RECEIVER_OF_MEMBER_TRAIT)
# define BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_RECEIVER_TRAIT 1
#endif // defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_FREE_TRAIT)
// && defined(BOOST_ASIO_HAS_DEDUCED_SET_DONE_MEMBER_TRAIT)
// && defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_FREE_TRAIT)
// && defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
// && defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_FREE_TRAIT)
// && defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
// && defined(BOOST_ASIO_HAS_DEDUCED_RECEIVER_OF_FREE_TRAIT)
// && defined(BOOST_ASIO_HAS_DEDUCED_RECEIVER_OF_MEMBER_TRAIT)
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
namespace detail {
template <typename T, typename E>
struct is_receiver_base :
integral_constant<bool,
is_move_constructible<typename remove_cvref<T>::type>::value
&& is_constructible<typename remove_cvref<T>::type, T>::value
>
{
};
} // namespace detail
#if defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
# define BOOST_ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT = std::exception_ptr
#else // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
# define BOOST_ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT \
= ::boost::system::error_code
#endif // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
/// The is_receiver trait detects whether a type T satisfies the
/// execution::receiver concept.
/**
* Class template @c is_receiver is a type trait that is derived from @c
* true_type if the type @c T meets the concept definition for a receiver for
* error type @c E, otherwise @c false_type.
*/
template <typename T, typename E BOOST_ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT>
struct is_receiver :
#if defined(GENERATING_DOCUMENTATION)
integral_constant<bool, automatically_determined>
#else // defined(GENERATING_DOCUMENTATION)
conditional<
can_set_done<typename remove_cvref<T>::type>::value
&& is_nothrow_set_done<typename remove_cvref<T>::type>::value
&& can_set_error<typename remove_cvref<T>::type, E>::value
&& is_nothrow_set_error<typename remove_cvref<T>::type, E>::value,
detail::is_receiver_base<T, E>,
false_type
>::type
#endif // defined(GENERATING_DOCUMENTATION)
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T, typename E BOOST_ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT>
BOOST_ASIO_CONSTEXPR const bool is_receiver_v = is_receiver<T, E>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#if defined(BOOST_ASIO_HAS_CONCEPTS)
template <typename T, typename E BOOST_ASIO_EXECUTION_RECEIVER_ERROR_DEFAULT>
BOOST_ASIO_CONCEPT receiver = is_receiver<T, E>::value;
#define BOOST_ASIO_EXECUTION_RECEIVER ::boost::asio::execution::receiver
#else // defined(BOOST_ASIO_HAS_CONCEPTS)
#define BOOST_ASIO_EXECUTION_RECEIVER typename
#endif // defined(BOOST_ASIO_HAS_CONCEPTS)
#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) \
|| defined(GENERATING_DOCUMENTATION)
/// The is_receiver_of trait detects whether a type T satisfies the
/// execution::receiver_of concept for some set of value arguments.
/**
* Class template @c is_receiver_of is a type trait that is derived from @c
* true_type if the type @c T meets the concept definition for a receiver for
* value arguments @c Vs, otherwise @c false_type.
*/
template <typename T, typename... Vs>
struct is_receiver_of :
#if defined(GENERATING_DOCUMENTATION)
integral_constant<bool, automatically_determined>
#else // defined(GENERATING_DOCUMENTATION)
conditional<
is_receiver<T>::value,
can_set_value<typename remove_cvref<T>::type, Vs...>,
false_type
>::type
#endif // defined(GENERATING_DOCUMENTATION)
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T, typename... Vs>
BOOST_ASIO_CONSTEXPR const bool is_receiver_of_v =
is_receiver_of<T, Vs...>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#if defined(BOOST_ASIO_HAS_CONCEPTS)
template <typename T, typename... Vs>
BOOST_ASIO_CONCEPT receiver_of = is_receiver_of<T, Vs...>::value;
#define BOOST_ASIO_EXECUTION_RECEIVER_OF_0 \
::boost::asio::execution::receiver_of
#define BOOST_ASIO_EXECUTION_RECEIVER_OF_1(v) \
::boost::asio::execution::receiver_of<v>
#else // defined(BOOST_ASIO_HAS_CONCEPTS)
#define BOOST_ASIO_EXECUTION_RECEIVER_OF_0 typename
#define BOOST_ASIO_EXECUTION_RECEIVER_OF_1(v) typename
#endif // defined(BOOST_ASIO_HAS_CONCEPTS)
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
// || defined(GENERATING_DOCUMENTATION)
template <typename T, typename = void,
typename = void, typename = void, typename = void, typename = void,
typename = void, typename = void, typename = void, typename = void>
struct is_receiver_of;
template <typename T>
struct is_receiver_of<T> :
conditional<
is_receiver<T>::value,
can_set_value<typename remove_cvref<T>::type>,
false_type
>::type
{
};
#define BOOST_ASIO_PRIVATE_RECEIVER_OF_TRAITS_DEF(n) \
template <typename T, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
struct is_receiver_of<T, BOOST_ASIO_VARIADIC_TARGS(n)> : \
conditional< \
conditional<true, is_receiver<T>, void>::type::value, \
can_set_value< \
typename remove_cvref<T>::type, \
BOOST_ASIO_VARIADIC_TARGS(n)>, \
false_type \
>::type \
{ \
}; \
/**/
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_RECEIVER_OF_TRAITS_DEF)
#undef BOOST_ASIO_PRIVATE_RECEIVER_OF_TRAITS_DEF
#define BOOST_ASIO_EXECUTION_RECEIVER_OF_0 typename
#define BOOST_ASIO_EXECUTION_RECEIVER_OF_1(v) typename
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
// || defined(GENERATING_DOCUMENTATION)
#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) \
|| defined(GENERATING_DOCUMENTATION)
/// The is_nothrow_receiver_of trait detects whether a type T satisfies the
/// execution::receiver_of concept for some set of value arguments, with a
/// noexcept @c set_value operation.
/**
* Class template @c is_nothrow_receiver_of is a type trait that is derived
* from @c true_type if the type @c T meets the concept definition for a
* receiver for value arguments @c Vs, and the expression
* <tt>execution::set_value(declval<T>(), declval<Ts>()...)</tt> is noexcept,
* otherwise @c false_type.
*/
template <typename T, typename... Vs>
struct is_nothrow_receiver_of :
#if defined(GENERATING_DOCUMENTATION)
integral_constant<bool, automatically_determined>
#else // defined(GENERATING_DOCUMENTATION)
integral_constant<bool,
is_receiver_of<T, Vs...>::value
&& is_nothrow_set_value<typename remove_cvref<T>::type, Vs...>::value
>
#endif // defined(GENERATING_DOCUMENTATION)
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T, typename... Vs>
BOOST_ASIO_CONSTEXPR const bool is_nothrow_receiver_of_v =
is_nothrow_receiver_of<T, Vs...>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
// || defined(GENERATING_DOCUMENTATION)
template <typename T, typename = void,
typename = void, typename = void, typename = void, typename = void,
typename = void, typename = void, typename = void, typename = void>
struct is_nothrow_receiver_of;
template <typename T>
struct is_nothrow_receiver_of<T> :
integral_constant<bool,
is_receiver_of<T>::value
&& is_nothrow_set_value<typename remove_cvref<T>::type>::value
>
{
};
#define BOOST_ASIO_PRIVATE_NOTHROW_RECEIVER_OF_TRAITS_DEF(n) \
template <typename T, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
struct is_nothrow_receiver_of<T, BOOST_ASIO_VARIADIC_TARGS(n)> : \
integral_constant<bool, \
is_receiver_of<T, BOOST_ASIO_VARIADIC_TARGS(n)>::value \
&& is_nothrow_set_value<typename remove_cvref<T>::type, \
BOOST_ASIO_VARIADIC_TARGS(n)>::value \
> \
{ \
}; \
/**/
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_NOTHROW_RECEIVER_OF_TRAITS_DEF)
#undef BOOST_ASIO_PRIVATE_NOTHROW_RECEIVER_OF_TRAITS_DEF
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
// || defined(GENERATING_DOCUMENTATION)
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_RECEIVER_HPP

View File

@@ -0,0 +1,50 @@
//
// execution/receiver_invocation_error.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_RECEIVER_INVOCATION_ERROR_HPP
#define BOOST_ASIO_EXECUTION_RECEIVER_INVOCATION_ERROR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <stdexcept>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
/// Exception reported via @c set_error when an exception escapes from
/// @c set_value.
class receiver_invocation_error
: public std::runtime_error
#if defined(BOOST_ASIO_HAS_STD_NESTED_EXCEPTION)
, public std::nested_exception
#endif // defined(BOOST_ASIO_HAS_STD_NESTED_EXCEPTION)
{
public:
/// Constructor.
BOOST_ASIO_DECL receiver_invocation_error();
};
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#if defined(BOOST_ASIO_HEADER_ONLY)
# include <boost/asio/execution/impl/receiver_invocation_error.ipp>
#endif // defined(BOOST_ASIO_HEADER_ONLY)
#endif // BOOST_ASIO_EXECUTION_RECEIVER_INVOCATION_ERROR_HPP

View File

@@ -0,0 +1,867 @@
//
// execution/relationship.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_RELATIONSHIP_HPP
#define BOOST_ASIO_EXECUTION_RELATIONSHIP_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/scheduler.hpp>
#include <boost/asio/execution/sender.hpp>
#include <boost/asio/is_applicable_property.hpp>
#include <boost/asio/query.hpp>
#include <boost/asio/traits/query_free.hpp>
#include <boost/asio/traits/query_member.hpp>
#include <boost/asio/traits/query_static_constexpr_member.hpp>
#include <boost/asio/traits/static_query.hpp>
#include <boost/asio/traits/static_require.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
#if defined(GENERATING_DOCUMENTATION)
namespace execution {
/// A property to describe whether submitted tasks represent continuations of
/// the calling context.
struct relationship_t
{
/// The relationship_t property applies to executors, senders, and schedulers.
template <typename T>
static constexpr bool is_applicable_property_v =
is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
/// The top-level relationship_t property cannot be required.
static constexpr bool is_requirable = false;
/// The top-level relationship_t property cannot be preferred.
static constexpr bool is_preferable = false;
/// The type returned by queries against an @c any_executor.
typedef relationship_t polymorphic_query_result_type;
/// A sub-property that indicates that the executor does not represent a
/// continuation of the calling context.
struct fork_t
{
/// The relationship_t::fork_t property applies to executors, senders, and
/// schedulers.
template <typename T>
static constexpr bool is_applicable_property_v =
is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
/// The relationship_t::fork_t property can be required.
static constexpr bool is_requirable = true;
/// The relationship_t::fork_t property can be preferred.
static constexpr bool is_preferable = true;
/// The type returned by queries against an @c any_executor.
typedef relationship_t polymorphic_query_result_type;
/// Default constructor.
constexpr fork_t();
/// Get the value associated with a property object.
/**
* @returns fork_t();
*/
static constexpr relationship_t value();
};
/// A sub-property that indicates that the executor represents a continuation
/// of the calling context.
struct continuation_t
{
/// The relationship_t::continuation_t property applies to executors,
/// senders, and schedulers.
template <typename T>
static constexpr bool is_applicable_property_v =
is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
/// The relationship_t::continuation_t property can be required.
static constexpr bool is_requirable = true;
/// The relationship_t::continuation_t property can be preferred.
static constexpr bool is_preferable = true;
/// The type returned by queries against an @c any_executor.
typedef relationship_t polymorphic_query_result_type;
/// Default constructor.
constexpr continuation_t();
/// Get the value associated with a property object.
/**
* @returns continuation_t();
*/
static constexpr relationship_t value();
};
/// A special value used for accessing the relationship_t::fork_t property.
static constexpr fork_t fork;
/// A special value used for accessing the relationship_t::continuation_t
/// property.
static constexpr continuation_t continuation;
/// Default constructor.
constexpr relationship_t();
/// Construct from a sub-property value.
constexpr relationship_t(fork_t);
/// Construct from a sub-property value.
constexpr relationship_t(continuation_t);
/// Compare property values for equality.
friend constexpr bool operator==(
const relationship_t& a, const relationship_t& b) noexcept;
/// Compare property values for inequality.
friend constexpr bool operator!=(
const relationship_t& a, const relationship_t& b) noexcept;
};
/// A special value used for accessing the relationship_t property.
constexpr relationship_t relationship;
} // namespace execution
#else // defined(GENERATING_DOCUMENTATION)
namespace execution {
namespace detail {
namespace relationship {
template <int I> struct fork_t;
template <int I> struct continuation_t;
} // namespace relationship
template <int I = 0>
struct relationship_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<T>::value
|| conditional<
is_executor<T>::value,
false_type,
is_sender<T>
>::type::value
|| conditional<
is_executor<T>::value,
false_type,
is_scheduler<T>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = false);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = false);
typedef relationship_t polymorphic_query_result_type;
typedef detail::relationship::fork_t<I> fork_t;
typedef detail::relationship::continuation_t<I> continuation_t;
BOOST_ASIO_CONSTEXPR relationship_t()
: value_(-1)
{
}
BOOST_ASIO_CONSTEXPR relationship_t(fork_t)
: value_(0)
{
}
BOOST_ASIO_CONSTEXPR relationship_t(continuation_t)
: value_(1)
{
}
template <typename T>
struct proxy
{
#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
struct type
{
template <typename P>
auto query(BOOST_ASIO_MOVE_ARG(P) p) const
noexcept(
noexcept(
declval<typename conditional<true, T, P>::type>().query(
BOOST_ASIO_MOVE_CAST(P)(p))
)
)
-> decltype(
declval<typename conditional<true, T, P>::type>().query(
BOOST_ASIO_MOVE_CAST(P)(p))
);
};
#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
typedef T type;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
};
template <typename T>
struct static_proxy
{
#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
struct type
{
template <typename P>
static constexpr auto query(BOOST_ASIO_MOVE_ARG(P) p)
noexcept(
noexcept(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
)
-> decltype(
conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
)
{
return T::query(BOOST_ASIO_MOVE_CAST(P)(p));
}
};
#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
typedef T type;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
};
template <typename T>
struct query_member :
traits::query_member<typename proxy<T>::type, relationship_t> {};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename static_proxy<T>::type, relationship_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
query_static_constexpr_member<T>::is_noexcept))
{
return query_static_constexpr_member<T>::value();
}
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename traits::static_query<T, fork_t>::result_type
static_query(
typename enable_if<
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
traits::static_query<T, fork_t>::is_valid
>::type* = 0) BOOST_ASIO_NOEXCEPT
{
return traits::static_query<T, fork_t>::value();
}
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename traits::static_query<T, continuation_t>::result_type
static_query(
typename enable_if<
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::static_query<T, fork_t>::is_valid
>::type* = 0,
typename enable_if<
traits::static_query<T, continuation_t>::is_valid
>::type* = 0) BOOST_ASIO_NOEXCEPT
{
return traits::static_query<T, continuation_t>::value();
}
template <typename E,
typename T = decltype(relationship_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= relationship_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
friend BOOST_ASIO_CONSTEXPR bool operator==(
const relationship_t& a, const relationship_t& b)
{
return a.value_ == b.value_;
}
friend BOOST_ASIO_CONSTEXPR bool operator!=(
const relationship_t& a, const relationship_t& b)
{
return a.value_ != b.value_;
}
struct convertible_from_relationship_t
{
BOOST_ASIO_CONSTEXPR convertible_from_relationship_t(relationship_t)
{
}
};
template <typename Executor>
friend BOOST_ASIO_CONSTEXPR relationship_t query(
const Executor& ex, convertible_from_relationship_t,
typename enable_if<
can_query<const Executor&, fork_t>::value
>::type* = 0)
#if !defined(__clang__) // Clang crashes if noexcept is used here.
#if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&, relationship_t<>::fork_t>::value))
#else // defined(BOOST_ASIO_MSVC)
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&, fork_t>::value))
#endif // defined(BOOST_ASIO_MSVC)
#endif // !defined(__clang__)
{
return boost::asio::query(ex, fork_t());
}
template <typename Executor>
friend BOOST_ASIO_CONSTEXPR relationship_t query(
const Executor& ex, convertible_from_relationship_t,
typename enable_if<
!can_query<const Executor&, fork_t>::value
>::type* = 0,
typename enable_if<
can_query<const Executor&, continuation_t>::value
>::type* = 0)
#if !defined(__clang__) // Clang crashes if noexcept is used here.
#if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&,
relationship_t<>::continuation_t>::value))
#else // defined(BOOST_ASIO_MSVC)
BOOST_ASIO_NOEXCEPT_IF((
is_nothrow_query<const Executor&, continuation_t>::value))
#endif // defined(BOOST_ASIO_MSVC)
#endif // !defined(__clang__)
{
return boost::asio::query(ex, continuation_t());
}
BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(fork_t, fork);
BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(continuation_t, continuation);
#if !defined(BOOST_ASIO_HAS_CONSTEXPR)
static const relationship_t instance;
#endif // !defined(BOOST_ASIO_HAS_CONSTEXPR)
private:
int value_;
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I> template <typename E, typename T>
const T relationship_t<I>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_CONSTEXPR)
template <int I>
const relationship_t<I> relationship_t<I>::instance;
#endif
template <int I>
const typename relationship_t<I>::fork_t
relationship_t<I>::fork;
template <int I>
const typename relationship_t<I>::continuation_t
relationship_t<I>::continuation;
namespace relationship {
template <int I = 0>
struct fork_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<T>::value
|| conditional<
is_executor<T>::value,
false_type,
is_sender<T>
>::type::value
|| conditional<
is_executor<T>::value,
false_type,
is_scheduler<T>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = true);
typedef relationship_t<I> polymorphic_query_result_type;
BOOST_ASIO_CONSTEXPR fork_t()
{
}
template <typename T>
struct query_member :
traits::query_member<
typename relationship_t<I>::template proxy<T>::type, fork_t> {};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename relationship_t<I>::template static_proxy<T>::type, fork_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
query_static_constexpr_member<T>::is_noexcept))
{
return query_static_constexpr_member<T>::value();
}
template <typename T>
static BOOST_ASIO_CONSTEXPR fork_t static_query(
typename enable_if<
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_free<T, fork_t>::is_valid
>::type* = 0,
typename enable_if<
!can_query<T, continuation_t<I> >::value
>::type* = 0) BOOST_ASIO_NOEXCEPT
{
return fork_t();
}
template <typename E, typename T = decltype(fork_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= fork_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
static BOOST_ASIO_CONSTEXPR relationship_t<I> value()
{
return fork_t();
}
friend BOOST_ASIO_CONSTEXPR bool operator==(
const fork_t&, const fork_t&)
{
return true;
}
friend BOOST_ASIO_CONSTEXPR bool operator!=(
const fork_t&, const fork_t&)
{
return false;
}
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I> template <typename E, typename T>
const T fork_t<I>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I = 0>
struct continuation_t
{
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
is_applicable_property_v = (
is_executor<T>::value
|| conditional<
is_executor<T>::value,
false_type,
is_sender<T>
>::type::value
|| conditional<
is_executor<T>::value,
false_type,
is_scheduler<T>
>::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_preferable = true);
typedef relationship_t<I> polymorphic_query_result_type;
BOOST_ASIO_CONSTEXPR continuation_t()
{
}
template <typename T>
struct query_member :
traits::query_member<
typename relationship_t<I>::template proxy<T>::type, continuation_t> {};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename relationship_t<I>::template static_proxy<T>::type,
continuation_t> {};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
query_static_constexpr_member<T>::is_noexcept))
{
return query_static_constexpr_member<T>::value();
}
template <typename E,
typename T = decltype(continuation_t::static_query<E>())>
static BOOST_ASIO_CONSTEXPR const T static_query_v
= continuation_t::static_query<E>();
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
static BOOST_ASIO_CONSTEXPR relationship_t<I> value()
{
return continuation_t();
}
friend BOOST_ASIO_CONSTEXPR bool operator==(
const continuation_t&, const continuation_t&)
{
return true;
}
friend BOOST_ASIO_CONSTEXPR bool operator!=(
const continuation_t&, const continuation_t&)
{
return false;
}
};
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <int I> template <typename E, typename T>
const T continuation_t<I>::static_query_v;
#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
} // namespace relationship
} // namespace detail
typedef detail::relationship_t<> relationship_t;
#if defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
constexpr relationship_t relationship;
#else // defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
namespace { static const relationship_t&
relationship = relationship_t::instance; }
#endif
} // namespace execution
#if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
struct is_applicable_property<T, execution::relationship_t>
: integral_constant<bool,
execution::is_executor<T>::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_sender<T>
>::type::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_scheduler<T>
>::type::value>
{
};
template <typename T>
struct is_applicable_property<T, execution::relationship_t::fork_t>
: integral_constant<bool,
execution::is_executor<T>::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_sender<T>
>::type::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_scheduler<T>
>::type::value>
{
};
template <typename T>
struct is_applicable_property<T, execution::relationship_t::continuation_t>
: integral_constant<bool,
execution::is_executor<T>::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_sender<T>
>::type::value
|| conditional<
execution::is_executor<T>::value,
false_type,
execution::is_scheduler<T>
>::type::value>
{
};
#endif // !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
namespace traits {
#if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
template <typename T>
struct query_free_default<T, execution::relationship_t,
typename enable_if<
can_query<T, execution::relationship_t::fork_t>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
(is_nothrow_query<T, execution::relationship_t::fork_t>::value));
typedef execution::relationship_t result_type;
};
template <typename T>
struct query_free_default<T, execution::relationship_t,
typename enable_if<
!can_query<T, execution::relationship_t::fork_t>::value
&& can_query<T, execution::relationship_t::continuation_t>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
(is_nothrow_query<T, execution::relationship_t::continuation_t>::value));
typedef execution::relationship_t result_type;
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
#if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
|| !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
struct static_query<T, execution::relationship_t,
typename enable_if<
execution::detail::relationship_t<0>::
query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename execution::detail::relationship_t<0>::
query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return execution::detail::relationship_t<0>::
query_static_constexpr_member<T>::value();
}
};
template <typename T>
struct static_query<T, execution::relationship_t,
typename enable_if<
!execution::detail::relationship_t<0>::
query_static_constexpr_member<T>::is_valid
&& !execution::detail::relationship_t<0>::
query_member<T>::is_valid
&& traits::static_query<T,
execution::relationship_t::fork_t>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename traits::static_query<T,
execution::relationship_t::fork_t>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return traits::static_query<T,
execution::relationship_t::fork_t>::value();
}
};
template <typename T>
struct static_query<T, execution::relationship_t,
typename enable_if<
!execution::detail::relationship_t<0>::
query_static_constexpr_member<T>::is_valid
&& !execution::detail::relationship_t<0>::
query_member<T>::is_valid
&& !traits::static_query<T,
execution::relationship_t::fork_t>::is_valid
&& traits::static_query<T,
execution::relationship_t::continuation_t>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename traits::static_query<T,
execution::relationship_t::continuation_t>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return traits::static_query<T,
execution::relationship_t::continuation_t>::value();
}
};
template <typename T>
struct static_query<T, execution::relationship_t::fork_t,
typename enable_if<
execution::detail::relationship::fork_t<0>::
query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename execution::detail::relationship::fork_t<0>::
query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return execution::detail::relationship::fork_t<0>::
query_static_constexpr_member<T>::value();
}
};
template <typename T>
struct static_query<T, execution::relationship_t::fork_t,
typename enable_if<
!execution::detail::relationship::fork_t<0>::
query_static_constexpr_member<T>::is_valid
&& !execution::detail::relationship::fork_t<0>::
query_member<T>::is_valid
&& !traits::query_free<T,
execution::relationship_t::fork_t>::is_valid
&& !can_query<T, execution::relationship_t::continuation_t>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef execution::relationship_t::fork_t result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return result_type();
}
};
template <typename T>
struct static_query<T, execution::relationship_t::continuation_t,
typename enable_if<
execution::detail::relationship::continuation_t<0>::
query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
typedef typename execution::detail::relationship::continuation_t<0>::
query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
return execution::detail::relationship::continuation_t<0>::
query_static_constexpr_member<T>::value();
}
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
// || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT)
template <typename T>
struct static_require<T, execution::relationship_t::fork_t,
typename enable_if<
static_query<T, execution::relationship_t::fork_t>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid =
(is_same<typename static_query<T,
execution::relationship_t::fork_t>::result_type,
execution::relationship_t::fork_t>::value));
};
template <typename T>
struct static_require<T, execution::relationship_t::continuation_t,
typename enable_if<
static_query<T, execution::relationship_t::continuation_t>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid =
(is_same<typename static_query<T,
execution::relationship_t::continuation_t>::result_type,
execution::relationship_t::continuation_t>::value));
};
#endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT)
} // namespace traits
#endif // defined(GENERATING_DOCUMENTATION)
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_RELATIONSHIP_HPP

View File

@@ -0,0 +1,291 @@
//
// execution/schedule.hpp
// ~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_SCHEDULE_HPP
#define BOOST_ASIO_EXECUTION_SCHEDULE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/traits/schedule_member.hpp>
#include <boost/asio/traits/schedule_free.hpp>
#include <boost/asio/detail/push_options.hpp>
#if defined(GENERATING_DOCUMENTATION)
namespace boost {
namespace asio {
namespace execution {
/// A customisation point that is used to obtain a sender from a scheduler.
/**
* The name <tt>execution::schedule</tt> denotes a customisation point object.
* For some subexpression <tt>s</tt>, let <tt>S</tt> be a type such that
* <tt>decltype((s))</tt> is <tt>S</tt>. The expression
* <tt>execution::schedule(s)</tt> is expression-equivalent to:
*
* @li <tt>s.schedule()</tt>, if that expression is valid and its type models
* <tt>sender</tt>.
*
* @li Otherwise, <tt>schedule(s)</tt>, if that expression is valid and its
* type models <tt>sender</tt> with overload resolution performed in a context
* that includes the declaration <tt>void schedule();</tt> and that does not
* include a declaration of <tt>execution::schedule</tt>.
*
* @li Otherwise, <tt>S</tt> if <tt>S</tt> satisfies <tt>executor</tt>.
*
* @li Otherwise, <tt>execution::schedule(s)</tt> is ill-formed.
*/
inline constexpr unspecified schedule = unspecified;
/// A type trait that determines whether a @c schedule expression is
/// well-formed.
/**
* Class template @c can_schedule is a trait that is derived from @c true_type
* if the expression <tt>execution::schedule(std::declval<S>())</tt> is well
* formed; otherwise @c false_type.
*/
template <typename S>
struct can_schedule :
integral_constant<bool, automatically_determined>
{
};
} // namespace execution
} // namespace asio
} // namespace boost
#else // defined(GENERATING_DOCUMENTATION)
namespace boost_asio_execution_schedule_fn {
using boost::asio::decay;
using boost::asio::declval;
using boost::asio::enable_if;
using boost::asio::execution::is_executor;
using boost::asio::traits::schedule_free;
using boost::asio::traits::schedule_member;
void schedule();
enum overload_type
{
identity,
call_member,
call_free,
ill_formed
};
template <typename S, typename = void, typename = void, typename = void>
struct call_traits
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = ill_formed);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
template <typename S>
struct call_traits<S,
typename enable_if<
schedule_member<S>::is_valid
>::type> :
schedule_member<S>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_member);
};
template <typename S>
struct call_traits<S,
typename enable_if<
!schedule_member<S>::is_valid
>::type,
typename enable_if<
schedule_free<S>::is_valid
>::type> :
schedule_free<S>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_free);
};
template <typename S>
struct call_traits<S,
typename enable_if<
!schedule_member<S>::is_valid
>::type,
typename enable_if<
!schedule_free<S>::is_valid
>::type,
typename enable_if<
is_executor<typename decay<S>::type>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = identity);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
#if defined(BOOST_ASIO_HAS_MOVE)
typedef BOOST_ASIO_MOVE_ARG(S) result_type;
#else // defined(BOOST_ASIO_HAS_MOVE)
typedef BOOST_ASIO_MOVE_ARG(typename decay<S>::type) result_type;
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
struct impl
{
template <typename S>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S>::overload == identity,
typename call_traits<S>::result_type
>::type
operator()(BOOST_ASIO_MOVE_ARG(S) s) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(S)(s);
}
#if defined(BOOST_ASIO_HAS_MOVE)
template <typename S>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S>::overload == call_member,
typename call_traits<S>::result_type
>::type
operator()(S&& s) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(S)(s).schedule();
}
template <typename S>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S>::overload == call_free,
typename call_traits<S>::result_type
>::type
operator()(S&& s) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S>::is_noexcept))
{
return schedule(BOOST_ASIO_MOVE_CAST(S)(s));
}
#else // defined(BOOST_ASIO_HAS_MOVE)
template <typename S>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&>::overload == call_member,
typename call_traits<S&>::result_type
>::type
operator()(S& s) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&>::is_noexcept))
{
return s.schedule();
}
template <typename S>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&>::overload == call_member,
typename call_traits<const S&>::result_type
>::type
operator()(const S& s) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&>::is_noexcept))
{
return s.schedule();
}
template <typename S>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&>::overload == call_free,
typename call_traits<S&>::result_type
>::type
operator()(S& s) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&>::is_noexcept))
{
return schedule(s);
}
template <typename S>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&>::overload == call_free,
typename call_traits<const S&>::result_type
>::type
operator()(const S& s) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&>::is_noexcept))
{
return schedule(s);
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
template <typename T = impl>
struct static_instance
{
static const T instance;
};
template <typename T>
const T static_instance<T>::instance = {};
} // namespace boost_asio_execution_schedule_fn
namespace boost {
namespace asio {
namespace execution {
namespace {
static BOOST_ASIO_CONSTEXPR const boost_asio_execution_schedule_fn::impl&
schedule = boost_asio_execution_schedule_fn::static_instance<>::instance;
} // namespace
template <typename S>
struct can_schedule :
integral_constant<bool,
boost_asio_execution_schedule_fn::call_traits<S>::overload !=
boost_asio_execution_schedule_fn::ill_formed>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S>
constexpr bool can_schedule_v = can_schedule<S>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S>
struct is_nothrow_schedule :
integral_constant<bool,
boost_asio_execution_schedule_fn::call_traits<S>::is_noexcept>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S>
constexpr bool is_nothrow_schedule_v
= is_nothrow_schedule<S>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
} // namespace execution
} // namespace asio
} // namespace boost
#endif // defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_SCHEDULE_HPP

View File

@@ -0,0 +1,88 @@
//
// execution/scheduler.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_SCHEDULER_HPP
#define BOOST_ASIO_EXECUTION_SCHEDULER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/schedule.hpp>
#include <boost/asio/traits/equality_comparable.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace execution {
namespace detail {
template <typename T>
struct is_scheduler_base :
integral_constant<bool,
is_copy_constructible<typename remove_cvref<T>::type>::value
&& traits::equality_comparable<typename remove_cvref<T>::type>::is_valid
>
{
};
} // namespace detail
/// The is_scheduler trait detects whether a type T satisfies the
/// execution::scheduler concept.
/**
* Class template @c is_scheduler is a type trait that is derived from @c
* true_type if the type @c T meets the concept definition for a scheduler for
* error type @c E, otherwise @c false_type.
*/
template <typename T>
struct is_scheduler :
#if defined(GENERATING_DOCUMENTATION)
integral_constant<bool, automatically_determined>
#else // defined(GENERATING_DOCUMENTATION)
conditional<
can_schedule<T>::value,
detail::is_scheduler_base<T>,
false_type
>::type
#endif // defined(GENERATING_DOCUMENTATION)
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_CONSTEXPR const bool is_scheduler_v = is_scheduler<T>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#if defined(BOOST_ASIO_HAS_CONCEPTS)
template <typename T>
BOOST_ASIO_CONCEPT scheduler = is_scheduler<T>::value;
#define BOOST_ASIO_EXECUTION_SCHEDULER ::boost::asio::execution::scheduler
#else // defined(BOOST_ASIO_HAS_CONCEPTS)
#define BOOST_ASIO_EXECUTION_SCHEDULER typename
#endif // defined(BOOST_ASIO_HAS_CONCEPTS)
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_SCHEDULER_HPP

View File

@@ -0,0 +1,313 @@
//
// execution/sender.hpp
// ~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_SENDER_HPP
#define BOOST_ASIO_EXECUTION_SENDER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/detail/as_invocable.hpp>
#include <boost/asio/execution/detail/void_receiver.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/receiver.hpp>
#include <boost/asio/detail/push_options.hpp>
#if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES) \
&& defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) \
&& defined(BOOST_ASIO_HAS_DECLTYPE) \
&& !defined(BOOST_ASIO_MSVC) || (_MSC_VER >= 1910)
# define BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_TYPED_SENDER_TRAIT 1
#endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
// && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
// && defined(BOOST_ASIO_HAS_DECLTYPE)
// && !defined(BOOST_ASIO_MSVC) || (_MSC_VER >= 1910)
namespace boost {
namespace asio {
namespace execution {
namespace detail {
namespace sender_base_ns { struct sender_base {}; }
template <typename S, typename = void>
struct sender_traits_base
{
typedef void asio_execution_sender_traits_base_is_unspecialised;
};
template <typename S>
struct sender_traits_base<S,
typename enable_if<
is_base_of<sender_base_ns::sender_base, S>::value
>::type>
{
};
template <typename S, typename = void, typename = void, typename = void>
struct has_sender_types : false_type
{
};
#if defined(BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_TYPED_SENDER_TRAIT)
template <
template <
template <typename...> class Tuple,
template <typename...> class Variant
> class>
struct has_value_types
{
typedef void type;
};
template <
template <
template <typename...> class Variant
> class>
struct has_error_types
{
typedef void type;
};
template <typename S>
struct has_sender_types<S,
typename has_value_types<S::template value_types>::type,
typename has_error_types<S::template error_types>::type,
typename conditional<S::sends_done, void, void>::type> : true_type
{
};
template <typename S>
struct sender_traits_base<S,
typename enable_if<
has_sender_types<S>::value
>::type>
{
template <
template <typename...> class Tuple,
template <typename...> class Variant>
using value_types = typename S::template value_types<Tuple, Variant>;
template <template <typename...> class Variant>
using error_types = typename S::template error_types<Variant>;
BOOST_ASIO_STATIC_CONSTEXPR(bool, sends_done = S::sends_done);
};
#endif // defined(BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_TYPED_SENDER_TRAIT)
template <typename S>
struct sender_traits_base<S,
typename enable_if<
!has_sender_types<S>::value
&& detail::is_executor_of_impl<S,
as_invocable<void_receiver, S> >::value
>::type>
{
#if defined(BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_TYPED_SENDER_TRAIT) \
&& defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
template <
template <typename...> class Tuple,
template <typename...> class Variant>
using value_types = Variant<Tuple<>>;
template <template <typename...> class Variant>
using error_types = Variant<std::exception_ptr>;
BOOST_ASIO_STATIC_CONSTEXPR(bool, sends_done = true);
#endif // defined(BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_TYPED_SENDER_TRAIT)
// && defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
};
} // namespace detail
/// Base class used for tagging senders.
#if defined(GENERATING_DOCUMENTATION)
typedef unspecified sender_base;
#else // defined(GENERATING_DOCUMENTATION)
typedef detail::sender_base_ns::sender_base sender_base;
#endif // defined(GENERATING_DOCUMENTATION)
/// Traits for senders.
template <typename S>
struct sender_traits
#if !defined(GENERATING_DOCUMENTATION)
: detail::sender_traits_base<S>
#endif // !defined(GENERATING_DOCUMENTATION)
{
};
namespace detail {
template <typename S, typename = void>
struct has_sender_traits : true_type
{
};
template <typename S>
struct has_sender_traits<S,
typename enable_if<
is_same<
typename boost::asio::execution::sender_traits<
S>::asio_execution_sender_traits_base_is_unspecialised,
void
>::value
>::type> : false_type
{
};
} // namespace detail
/// The is_sender trait detects whether a type T satisfies the
/// execution::sender concept.
/**
* Class template @c is_sender is a type trait that is derived from @c
* true_type if the type @c T meets the concept definition for a sender,
* otherwise @c false_type.
*/
template <typename T>
struct is_sender :
#if defined(GENERATING_DOCUMENTATION)
integral_constant<bool, automatically_determined>
#else // defined(GENERATING_DOCUMENTATION)
conditional<
detail::has_sender_traits<typename remove_cvref<T>::type>::value,
is_move_constructible<typename remove_cvref<T>::type>,
false_type
>::type
#endif // defined(GENERATING_DOCUMENTATION)
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_CONSTEXPR const bool is_sender_v = is_sender<T>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#if defined(BOOST_ASIO_HAS_CONCEPTS)
template <typename T>
BOOST_ASIO_CONCEPT sender = is_sender<T>::value;
#define BOOST_ASIO_EXECUTION_SENDER ::boost::asio::execution::sender
#else // defined(BOOST_ASIO_HAS_CONCEPTS)
#define BOOST_ASIO_EXECUTION_SENDER typename
#endif // defined(BOOST_ASIO_HAS_CONCEPTS)
template <typename S, typename R>
struct can_connect;
/// The is_sender_to trait detects whether a type T satisfies the
/// execution::sender_to concept for some receiver.
/**
* Class template @c is_sender_to is a type trait that is derived from @c
* true_type if the type @c T meets the concept definition for a sender
* for some receiver type R, otherwise @c false.
*/
template <typename T, typename R>
struct is_sender_to :
#if defined(GENERATING_DOCUMENTATION)
integral_constant<bool, automatically_determined>
#else // defined(GENERATING_DOCUMENTATION)
integral_constant<bool,
is_sender<T>::value
&& is_receiver<R>::value
&& can_connect<T, R>::value
>
#endif // defined(GENERATING_DOCUMENTATION)
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T, typename R>
BOOST_ASIO_CONSTEXPR const bool is_sender_to_v =
is_sender_to<T, R>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#if defined(BOOST_ASIO_HAS_CONCEPTS)
template <typename T, typename R>
BOOST_ASIO_CONCEPT sender_to = is_sender_to<T, R>::value;
#define BOOST_ASIO_EXECUTION_SENDER_TO(r) \
::boost::asio::execution::sender_to<r>
#else // defined(BOOST_ASIO_HAS_CONCEPTS)
#define BOOST_ASIO_EXECUTION_SENDER_TO(r) typename
#endif // defined(BOOST_ASIO_HAS_CONCEPTS)
/// The is_typed_sender trait detects whether a type T satisfies the
/// execution::typed_sender concept.
/**
* Class template @c is_typed_sender is a type trait that is derived from @c
* true_type if the type @c T meets the concept definition for a typed sender,
* otherwise @c false.
*/
template <typename T>
struct is_typed_sender :
#if defined(GENERATING_DOCUMENTATION)
integral_constant<bool, automatically_determined>
#else // defined(GENERATING_DOCUMENTATION)
integral_constant<bool,
is_sender<T>::value
&& detail::has_sender_types<
sender_traits<typename remove_cvref<T>::type> >::value
>
#endif // defined(GENERATING_DOCUMENTATION)
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_CONSTEXPR const bool is_typed_sender_v = is_typed_sender<T>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#if defined(BOOST_ASIO_HAS_CONCEPTS)
template <typename T>
BOOST_ASIO_CONCEPT typed_sender = is_typed_sender<T>::value;
#define BOOST_ASIO_EXECUTION_TYPED_SENDER \
::boost::asio::execution::typed_sender
#else // defined(BOOST_ASIO_HAS_CONCEPTS)
#define BOOST_ASIO_EXECUTION_TYPED_SENDER typename
#endif // defined(BOOST_ASIO_HAS_CONCEPTS)
} // namespace execution
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#include <boost/asio/execution/connect.hpp>
#endif // BOOST_ASIO_EXECUTION_SENDER_HPP

View File

@@ -0,0 +1,254 @@
//
// execution/set_done.hpp
// ~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_SET_DONE_HPP
#define BOOST_ASIO_EXECUTION_SET_DONE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/traits/set_done_member.hpp>
#include <boost/asio/traits/set_done_free.hpp>
#include <boost/asio/detail/push_options.hpp>
#if defined(GENERATING_DOCUMENTATION)
namespace boost {
namespace asio {
namespace execution {
/// A customisation point that delivers a done notification to a receiver.
/**
* The name <tt>execution::set_done</tt> denotes a customisation point object.
* The expression <tt>execution::set_done(R)</tt> for some subexpression
* <tt>R</tt> is expression-equivalent to:
*
* @li <tt>R.set_done()</tt>, if that expression is valid. If the function
* selected does not signal the receiver <tt>R</tt>'s done channel, the
* program is ill-formed with no diagnostic required.
*
* @li Otherwise, <tt>set_done(R)</tt>, if that expression is valid, with
* overload resolution performed in a context that includes the declaration
* <tt>void set_done();</tt> and that does not include a declaration of
* <tt>execution::set_done</tt>. If the function selected by overload
* resolution does not signal the receiver <tt>R</tt>'s done channel, the
* program is ill-formed with no diagnostic required.
*
* @li Otherwise, <tt>execution::set_done(R)</tt> is ill-formed.
*/
inline constexpr unspecified set_done = unspecified;
/// A type trait that determines whether a @c set_done expression is
/// well-formed.
/**
* Class template @c can_set_done is a trait that is derived from
* @c true_type if the expression <tt>execution::set_done(std::declval<R>(),
* std::declval<E>())</tt> is well formed; otherwise @c false_type.
*/
template <typename R>
struct can_set_done :
integral_constant<bool, automatically_determined>
{
};
} // namespace execution
} // namespace asio
} // namespace boost
#else // defined(GENERATING_DOCUMENTATION)
namespace boost_asio_execution_set_done_fn {
using boost::asio::decay;
using boost::asio::declval;
using boost::asio::enable_if;
using boost::asio::traits::set_done_free;
using boost::asio::traits::set_done_member;
void set_done();
enum overload_type
{
call_member,
call_free,
ill_formed
};
template <typename R, typename = void, typename = void>
struct call_traits
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = ill_formed);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
template <typename R>
struct call_traits<R,
typename enable_if<
set_done_member<R>::is_valid
>::type> :
set_done_member<R>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_member);
};
template <typename R>
struct call_traits<R,
typename enable_if<
!set_done_member<R>::is_valid
>::type,
typename enable_if<
set_done_free<R>::is_valid
>::type> :
set_done_free<R>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_free);
};
struct impl
{
#if defined(BOOST_ASIO_HAS_MOVE)
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R>::overload == call_member,
typename call_traits<R>::result_type
>::type
operator()(R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(R)(r).set_done();
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R>::overload == call_free,
typename call_traits<R>::result_type
>::type
operator()(R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R>::is_noexcept))
{
return set_done(BOOST_ASIO_MOVE_CAST(R)(r));
}
#else // defined(BOOST_ASIO_HAS_MOVE)
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R&>::overload == call_member,
typename call_traits<R&>::result_type
>::type
operator()(R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R&>::is_noexcept))
{
return r.set_done();
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const R&>::overload == call_member,
typename call_traits<const R&>::result_type
>::type
operator()(const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const R&>::is_noexcept))
{
return r.set_done();
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R&>::overload == call_free,
typename call_traits<R&>::result_type
>::type
operator()(R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R&>::is_noexcept))
{
return set_done(r);
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const R&>::overload == call_free,
typename call_traits<const R&>::result_type
>::type
operator()(const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const R&>::is_noexcept))
{
return set_done(r);
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
template <typename T = impl>
struct static_instance
{
static const T instance;
};
template <typename T>
const T static_instance<T>::instance = {};
} // namespace boost_asio_execution_set_done_fn
namespace boost {
namespace asio {
namespace execution {
namespace {
static BOOST_ASIO_CONSTEXPR const boost_asio_execution_set_done_fn::impl&
set_done = boost_asio_execution_set_done_fn::static_instance<>::instance;
} // namespace
template <typename R>
struct can_set_done :
integral_constant<bool,
boost_asio_execution_set_done_fn::call_traits<R>::overload !=
boost_asio_execution_set_done_fn::ill_formed>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R>
constexpr bool can_set_done_v = can_set_done<R>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R>
struct is_nothrow_set_done :
integral_constant<bool,
boost_asio_execution_set_done_fn::call_traits<R>::is_noexcept>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R>
constexpr bool is_nothrow_set_done_v
= is_nothrow_set_done<R>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
} // namespace execution
} // namespace asio
} // namespace boost
#endif // defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_SET_DONE_HPP

View File

@@ -0,0 +1,254 @@
//
// execution/set_error.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_SET_ERROR_HPP
#define BOOST_ASIO_EXECUTION_SET_ERROR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/traits/set_error_member.hpp>
#include <boost/asio/traits/set_error_free.hpp>
#include <boost/asio/detail/push_options.hpp>
#if defined(GENERATING_DOCUMENTATION)
namespace boost {
namespace asio {
namespace execution {
/// A customisation point that delivers an error notification to a receiver.
/**
* The name <tt>execution::set_error</tt> denotes a customisation point object.
* The expression <tt>execution::set_error(R, E)</tt> for some subexpressions
* <tt>R</tt> and <tt>E</tt> are expression-equivalent to:
*
* @li <tt>R.set_error(E)</tt>, if that expression is valid. If the function
* selected does not send the error <tt>E</tt> to the receiver <tt>R</tt>'s
* error channel, the program is ill-formed with no diagnostic required.
*
* @li Otherwise, <tt>set_error(R, E)</tt>, if that expression is valid, with
* overload resolution performed in a context that includes the declaration
* <tt>void set_error();</tt> and that does not include a declaration of
* <tt>execution::set_error</tt>. If the function selected by overload
* resolution does not send the error <tt>E</tt> to the receiver <tt>R</tt>'s
* error channel, the program is ill-formed with no diagnostic required.
*
* @li Otherwise, <tt>execution::set_error(R, E)</tt> is ill-formed.
*/
inline constexpr unspecified set_error = unspecified;
/// A type trait that determines whether a @c set_error expression is
/// well-formed.
/**
* Class template @c can_set_error is a trait that is derived from
* @c true_type if the expression <tt>execution::set_error(std::declval<R>(),
* std::declval<E>())</tt> is well formed; otherwise @c false_type.
*/
template <typename R, typename E>
struct can_set_error :
integral_constant<bool, automatically_determined>
{
};
} // namespace execution
} // namespace asio
} // namespace boost
#else // defined(GENERATING_DOCUMENTATION)
namespace boost_asio_execution_set_error_fn {
using boost::asio::decay;
using boost::asio::declval;
using boost::asio::enable_if;
using boost::asio::traits::set_error_free;
using boost::asio::traits::set_error_member;
void set_error();
enum overload_type
{
call_member,
call_free,
ill_formed
};
template <typename R, typename E, typename = void, typename = void>
struct call_traits
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = ill_formed);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
template <typename R, typename E>
struct call_traits<R, void(E),
typename enable_if<
set_error_member<R, E>::is_valid
>::type> :
set_error_member<R, E>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_member);
};
template <typename R, typename E>
struct call_traits<R, void(E),
typename enable_if<
!set_error_member<R, E>::is_valid
>::type,
typename enable_if<
set_error_free<R, E>::is_valid
>::type> :
set_error_free<R, E>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_free);
};
struct impl
{
#if defined(BOOST_ASIO_HAS_MOVE)
template <typename R, typename E>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R, void(E)>::overload == call_member,
typename call_traits<R, void(E)>::result_type
>::type
operator()(R&& r, E&& e) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R, void(E)>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(R)(r).set_error(BOOST_ASIO_MOVE_CAST(E)(e));
}
template <typename R, typename E>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R, void(E)>::overload == call_free,
typename call_traits<R, void(E)>::result_type
>::type
operator()(R&& r, E&& e) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R, void(E)>::is_noexcept))
{
return set_error(BOOST_ASIO_MOVE_CAST(R)(r), BOOST_ASIO_MOVE_CAST(E)(e));
}
#else // defined(BOOST_ASIO_HAS_MOVE)
template <typename R, typename E>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R&, void(const E&)>::overload == call_member,
typename call_traits<R&, void(const E&)>::result_type
>::type
operator()(R& r, const E& e) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R&, void(const E&)>::is_noexcept))
{
return r.set_error(e);
}
template <typename R, typename E>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const R&, void(const E&)>::overload == call_member,
typename call_traits<const R&, void(const E&)>::result_type
>::type
operator()(const R& r, const E& e) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const R&, void(const E&)>::is_noexcept))
{
return r.set_error(e);
}
template <typename R, typename E>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R&, void(const E&)>::overload == call_free,
typename call_traits<R&, void(const E&)>::result_type
>::type
operator()(R& r, const E& e) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R&, void(const E&)>::is_noexcept))
{
return set_error(r, e);
}
template <typename R, typename E>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const R&, void(const E&)>::overload == call_free,
typename call_traits<const R&, void(const E&)>::result_type
>::type
operator()(const R& r, const E& e) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const R&, void(const E&)>::is_noexcept))
{
return set_error(r, e);
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
template <typename T = impl>
struct static_instance
{
static const T instance;
};
template <typename T>
const T static_instance<T>::instance = {};
} // namespace boost_asio_execution_set_error_fn
namespace boost {
namespace asio {
namespace execution {
namespace {
static BOOST_ASIO_CONSTEXPR const boost_asio_execution_set_error_fn::impl&
set_error = boost_asio_execution_set_error_fn::static_instance<>::instance;
} // namespace
template <typename R, typename E>
struct can_set_error :
integral_constant<bool,
boost_asio_execution_set_error_fn::call_traits<R, void(E)>::overload !=
boost_asio_execution_set_error_fn::ill_formed>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R, typename E>
constexpr bool can_set_error_v = can_set_error<R, E>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R, typename E>
struct is_nothrow_set_error :
integral_constant<bool,
boost_asio_execution_set_error_fn::call_traits<R, void(E)>::is_noexcept>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R, typename E>
constexpr bool is_nothrow_set_error_v
= is_nothrow_set_error<R, E>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
} // namespace execution
} // namespace asio
} // namespace boost
#endif // defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_SET_ERROR_HPP

View File

@@ -0,0 +1,487 @@
//
// execution/set_value.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_SET_VALUE_HPP
#define BOOST_ASIO_EXECUTION_SET_VALUE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/detail/variadic_templates.hpp>
#include <boost/asio/traits/set_value_member.hpp>
#include <boost/asio/traits/set_value_free.hpp>
#include <boost/asio/detail/push_options.hpp>
#if defined(GENERATING_DOCUMENTATION)
namespace boost {
namespace asio {
namespace execution {
/// A customisation point that delivers a value to a receiver.
/**
* The name <tt>execution::set_value</tt> denotes a customisation point object.
* The expression <tt>execution::set_value(R, Vs...)</tt> for some
* subexpressions <tt>R</tt> and <tt>Vs...</tt> is expression-equivalent to:
*
* @li <tt>R.set_value(Vs...)</tt>, if that expression is valid. If the
* function selected does not send the value(s) <tt>Vs...</tt> to the receiver
* <tt>R</tt>'s value channel, the program is ill-formed with no diagnostic
* required.
*
* @li Otherwise, <tt>set_value(R, Vs...)</tt>, if that expression is valid,
* with overload resolution performed in a context that includes the
* declaration <tt>void set_value();</tt> and that does not include a
* declaration of <tt>execution::set_value</tt>. If the function selected by
* overload resolution does not send the value(s) <tt>Vs...</tt> to the
* receiver <tt>R</tt>'s value channel, the program is ill-formed with no
* diagnostic required.
*
* @li Otherwise, <tt>execution::set_value(R, Vs...)</tt> is ill-formed.
*/
inline constexpr unspecified set_value = unspecified;
/// A type trait that determines whether a @c set_value expression is
/// well-formed.
/**
* Class template @c can_set_value is a trait that is derived from
* @c true_type if the expression <tt>execution::set_value(std::declval<R>(),
* std::declval<Vs>()...)</tt> is well formed; otherwise @c false_type.
*/
template <typename R, typename... Vs>
struct can_set_value :
integral_constant<bool, automatically_determined>
{
};
} // namespace execution
} // namespace asio
} // namespace boost
#else // defined(GENERATING_DOCUMENTATION)
namespace boost_asio_execution_set_value_fn {
using boost::asio::decay;
using boost::asio::declval;
using boost::asio::enable_if;
using boost::asio::traits::set_value_free;
using boost::asio::traits::set_value_member;
void set_value();
enum overload_type
{
call_member,
call_free,
ill_formed
};
template <typename R, typename Vs, typename = void, typename = void>
struct call_traits
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = ill_formed);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
template <typename R, typename Vs>
struct call_traits<R, Vs,
typename enable_if<
set_value_member<R, Vs>::is_valid
>::type> :
set_value_member<R, Vs>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_member);
};
template <typename R, typename Vs>
struct call_traits<R, Vs,
typename enable_if<
!set_value_member<R, Vs>::is_valid
>::type,
typename enable_if<
set_value_free<R, Vs>::is_valid
>::type> :
set_value_free<R, Vs>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_free);
};
struct impl
{
#if defined(BOOST_ASIO_HAS_MOVE)
#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename R, typename... Vs>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R, void(Vs...)>::overload == call_member,
typename call_traits<R, void(Vs...)>::result_type
>::type
operator()(R&& r, Vs&&... v) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R, void(Vs...)>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(R)(r).set_value(BOOST_ASIO_MOVE_CAST(Vs)(v)...);
}
template <typename R, typename... Vs>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R, void(Vs...)>::overload == call_free,
typename call_traits<R, void(Vs...)>::result_type
>::type
operator()(R&& r, Vs&&... v) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R, void(Vs...)>::is_noexcept))
{
return set_value(BOOST_ASIO_MOVE_CAST(R)(r),
BOOST_ASIO_MOVE_CAST(Vs)(v)...);
}
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R, void()>::overload == call_member,
typename call_traits<R, void()>::result_type
>::type
operator()(R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R, void()>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(R)(r).set_value();
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R, void()>::overload == call_free,
typename call_traits<R, void()>::result_type
>::type
operator()(R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R, void()>::is_noexcept))
{
return set_value(BOOST_ASIO_MOVE_CAST(R)(r));
}
#define BOOST_ASIO_PRIVATE_SET_VALUE_CALL_DEF(n) \
template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
BOOST_ASIO_CONSTEXPR typename enable_if< \
call_traits<R, \
void(BOOST_ASIO_VARIADIC_TARGS(n))>::overload == call_member, \
typename call_traits<R, void(BOOST_ASIO_VARIADIC_TARGS(n))>::result_type \
>::type \
operator()(R&& r, BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) const \
BOOST_ASIO_NOEXCEPT_IF(( \
call_traits<R, void(BOOST_ASIO_VARIADIC_TARGS(n))>::is_noexcept)) \
{ \
return BOOST_ASIO_MOVE_CAST(R)(r).set_value( \
BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
} \
\
template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
BOOST_ASIO_CONSTEXPR typename enable_if< \
call_traits<R, void(BOOST_ASIO_VARIADIC_TARGS(n))>::overload == call_free, \
typename call_traits<R, void(BOOST_ASIO_VARIADIC_TARGS(n))>::result_type \
>::type \
operator()(R&& r, BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) const \
BOOST_ASIO_NOEXCEPT_IF(( \
call_traits<R, void(BOOST_ASIO_VARIADIC_TARGS(n))>::is_noexcept)) \
{ \
return set_value(BOOST_ASIO_MOVE_CAST(R)(r), \
BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
} \
/**/
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SET_VALUE_CALL_DEF)
#undef BOOST_ASIO_PRIVATE_SET_VALUE_CALL_DEF
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
#else // defined(BOOST_ASIO_HAS_MOVE)
#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename R, typename... Vs>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R&, void(const Vs&...)>::overload == call_member,
typename call_traits<R&, void(const Vs&...)>::result_type
>::type
operator()(R& r, const Vs&... v) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R&, void(const Vs&...)>::is_noexcept))
{
return r.set_value(v...);
}
template <typename R, typename... Vs>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const R&, void(const Vs&...)>::overload == call_member,
typename call_traits<const R&, void(const Vs&...)>::result_type
>::type
operator()(const R& r, const Vs&... v) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const R&, void(const Vs&...)>::is_noexcept))
{
return r.set_value(v...);
}
template <typename R, typename... Vs>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R&, void(const Vs&...)>::overload == call_free,
typename call_traits<R&, void(const Vs&...)>::result_type
>::type
operator()(R& r, const Vs&... v) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R&, void(const Vs&...)>::is_noexcept))
{
return set_value(r, v...);
}
template <typename R, typename... Vs>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const R&, void(const Vs&...)>::overload == call_free,
typename call_traits<const R&, void(const Vs&...)>::result_type
>::type
operator()(const R& r, const Vs&... v) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const R&, void(const Vs&...)>::is_noexcept))
{
return set_value(r, v...);
}
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R&, void()>::overload == call_member,
typename call_traits<R&, void()>::result_type
>::type
operator()(R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R&, void()>::is_noexcept))
{
return r.set_value();
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const R&, void()>::overload == call_member,
typename call_traits<const R&, void()>::result_type
>::type
operator()(const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const R&, void()>::is_noexcept))
{
return r.set_value();
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R&, void()>::overload == call_free,
typename call_traits<R&, void()>::result_type
>::type
operator()(R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R&, void()>::is_noexcept))
{
return set_value(r);
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const R&, void()>::overload == call_free,
typename call_traits<const R&, void()>::result_type
>::type
operator()(const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const R&, void()>::is_noexcept))
{
return set_value(r);
}
#define BOOST_ASIO_PRIVATE_SET_VALUE_CALL_DEF(n) \
template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
BOOST_ASIO_CONSTEXPR typename enable_if< \
call_traits<R&, \
void(BOOST_ASIO_VARIADIC_TARGS(n))>::overload == call_member, \
typename call_traits<R&, void(BOOST_ASIO_VARIADIC_TARGS(n))>::result_type \
>::type \
operator()(R& r, BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) const \
BOOST_ASIO_NOEXCEPT_IF(( \
call_traits<R&, void(BOOST_ASIO_VARIADIC_TARGS(n))>::is_noexcept)) \
{ \
return r.set_value(BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
} \
\
template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
BOOST_ASIO_CONSTEXPR typename enable_if< \
call_traits<const R&, \
void(BOOST_ASIO_VARIADIC_TARGS(n))>::overload == call_member, \
typename call_traits<const R&, \
void(BOOST_ASIO_VARIADIC_TARGS(n))>::result_type \
>::type \
operator()(const R& r, BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) const \
BOOST_ASIO_NOEXCEPT_IF(( \
call_traits<const R&, void(BOOST_ASIO_VARIADIC_TARGS(n))>::is_noexcept)) \
{ \
return r.set_value(BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
} \
\
template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
BOOST_ASIO_CONSTEXPR typename enable_if< \
call_traits<R&, \
void(BOOST_ASIO_VARIADIC_TARGS(n))>::overload == call_free, \
typename call_traits<R&, void(BOOST_ASIO_VARIADIC_TARGS(n))>::result_type \
>::type \
operator()(R& r, BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) const \
BOOST_ASIO_NOEXCEPT_IF(( \
call_traits<R&, void(BOOST_ASIO_VARIADIC_TARGS(n))>::is_noexcept)) \
{ \
return set_value(r, BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
} \
\
template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
BOOST_ASIO_CONSTEXPR typename enable_if< \
call_traits<const R&, \
void(BOOST_ASIO_VARIADIC_TARGS(n))>::overload == call_free, \
typename call_traits<const R&, \
void(BOOST_ASIO_VARIADIC_TARGS(n))>::result_type \
>::type \
operator()(const R& r, BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) const \
BOOST_ASIO_NOEXCEPT_IF(( \
call_traits<const R&, void(BOOST_ASIO_VARIADIC_TARGS(n))>::is_noexcept)) \
{ \
return set_value(r, BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
} \
/**/
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SET_VALUE_CALL_DEF)
#undef BOOST_ASIO_PRIVATE_SET_VALUE_CALL_DEF
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
template <typename T = impl>
struct static_instance
{
static const T instance;
};
template <typename T>
const T static_instance<T>::instance = {};
} // namespace boost_asio_execution_set_value_fn
namespace boost {
namespace asio {
namespace execution {
namespace {
static BOOST_ASIO_CONSTEXPR const boost_asio_execution_set_value_fn::impl&
set_value = boost_asio_execution_set_value_fn::static_instance<>::instance;
} // namespace
#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename R, typename... Vs>
struct can_set_value :
integral_constant<bool,
boost_asio_execution_set_value_fn::call_traits<R, void(Vs...)>::overload !=
boost_asio_execution_set_value_fn::ill_formed>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R, typename... Vs>
constexpr bool can_set_value_v = can_set_value<R, Vs...>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R, typename... Vs>
struct is_nothrow_set_value :
integral_constant<bool,
boost_asio_execution_set_value_fn::call_traits<R, void(Vs...)>::is_noexcept>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R, typename... Vs>
constexpr bool is_nothrow_set_value_v
= is_nothrow_set_value<R, Vs...>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename R, typename = void,
typename = void, typename = void, typename = void, typename = void,
typename = void, typename = void, typename = void, typename = void>
struct can_set_value;
template <typename R, typename = void,
typename = void, typename = void, typename = void, typename = void,
typename = void, typename = void, typename = void, typename = void>
struct is_nothrow_set_value;
template <typename R>
struct can_set_value<R> :
integral_constant<bool,
boost_asio_execution_set_value_fn::call_traits<R, void()>::overload !=
boost_asio_execution_set_value_fn::ill_formed>
{
};
template <typename R>
struct is_nothrow_set_value<R> :
integral_constant<bool,
boost_asio_execution_set_value_fn::call_traits<R, void()>::is_noexcept>
{
};
#define BOOST_ASIO_PRIVATE_SET_VALUE_TRAITS_DEF(n) \
template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
struct can_set_value<R, BOOST_ASIO_VARIADIC_TARGS(n)> : \
integral_constant<bool, \
boost_asio_execution_set_value_fn::call_traits<R, \
void(BOOST_ASIO_VARIADIC_TARGS(n))>::overload != \
boost_asio_execution_set_value_fn::ill_formed> \
{ \
}; \
\
template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
struct is_nothrow_set_value<R, BOOST_ASIO_VARIADIC_TARGS(n)> : \
integral_constant<bool, \
boost_asio_execution_set_value_fn::call_traits<R, \
void(BOOST_ASIO_VARIADIC_TARGS(n))>::is_noexcept> \
{ \
}; \
/**/
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SET_VALUE_TRAITS_DEF)
#undef BOOST_ASIO_PRIVATE_SET_VALUE_TRAITS_DEF
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
} // namespace execution
} // namespace asio
} // namespace boost
#endif // defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_SET_VALUE_HPP

View File

@@ -0,0 +1,251 @@
//
// execution/start.hpp
// ~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_START_HPP
#define BOOST_ASIO_EXECUTION_START_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/traits/start_member.hpp>
#include <boost/asio/traits/start_free.hpp>
#include <boost/asio/detail/push_options.hpp>
#if defined(GENERATING_DOCUMENTATION)
namespace boost {
namespace asio {
namespace execution {
/// A customisation point that notifies an operation state object to start
/// its associated operation.
/**
* The name <tt>execution::start</tt> denotes a customisation point object.
* The expression <tt>execution::start(R)</tt> for some subexpression
* <tt>R</tt> is expression-equivalent to:
*
* @li <tt>R.start()</tt>, if that expression is valid.
*
* @li Otherwise, <tt>start(R)</tt>, if that expression is valid, with
* overload resolution performed in a context that includes the declaration
* <tt>void start();</tt> and that does not include a declaration of
* <tt>execution::start</tt>.
*
* @li Otherwise, <tt>execution::start(R)</tt> is ill-formed.
*/
inline constexpr unspecified start = unspecified;
/// A type trait that determines whether a @c start expression is
/// well-formed.
/**
* Class template @c can_start is a trait that is derived from
* @c true_type if the expression <tt>execution::start(std::declval<R>(),
* std::declval<E>())</tt> is well formed; otherwise @c false_type.
*/
template <typename R>
struct can_start :
integral_constant<bool, automatically_determined>
{
};
} // namespace execution
} // namespace asio
} // namespace boost
#else // defined(GENERATING_DOCUMENTATION)
namespace boost_asio_execution_start_fn {
using boost::asio::decay;
using boost::asio::declval;
using boost::asio::enable_if;
using boost::asio::traits::start_free;
using boost::asio::traits::start_member;
void start();
enum overload_type
{
call_member,
call_free,
ill_formed
};
template <typename R, typename = void, typename = void>
struct call_traits
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = ill_formed);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
template <typename R>
struct call_traits<R,
typename enable_if<
start_member<R>::is_valid
>::type> :
start_member<R>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_member);
};
template <typename R>
struct call_traits<R,
typename enable_if<
!start_member<R>::is_valid
>::type,
typename enable_if<
start_free<R>::is_valid
>::type> :
start_free<R>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_free);
};
struct impl
{
#if defined(BOOST_ASIO_HAS_MOVE)
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R>::overload == call_member,
typename call_traits<R>::result_type
>::type
operator()(R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(R)(r).start();
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R>::overload == call_free,
typename call_traits<R>::result_type
>::type
operator()(R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R>::is_noexcept))
{
return start(BOOST_ASIO_MOVE_CAST(R)(r));
}
#else // defined(BOOST_ASIO_HAS_MOVE)
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R&>::overload == call_member,
typename call_traits<R&>::result_type
>::type
operator()(R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R&>::is_noexcept))
{
return r.start();
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const R&>::overload == call_member,
typename call_traits<const R&>::result_type
>::type
operator()(const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const R&>::is_noexcept))
{
return r.start();
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<R&>::overload == call_free,
typename call_traits<R&>::result_type
>::type
operator()(R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<R&>::is_noexcept))
{
return start(r);
}
template <typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const R&>::overload == call_free,
typename call_traits<const R&>::result_type
>::type
operator()(const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const R&>::is_noexcept))
{
return start(r);
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
template <typename T = impl>
struct static_instance
{
static const T instance;
};
template <typename T>
const T static_instance<T>::instance = {};
} // namespace boost_asio_execution_start_fn
namespace boost {
namespace asio {
namespace execution {
namespace {
static BOOST_ASIO_CONSTEXPR const boost_asio_execution_start_fn::impl&
start = boost_asio_execution_start_fn::static_instance<>::instance;
} // namespace
template <typename R>
struct can_start :
integral_constant<bool,
boost_asio_execution_start_fn::call_traits<R>::overload !=
boost_asio_execution_start_fn::ill_formed>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R>
constexpr bool can_start_v = can_start<R>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R>
struct is_nothrow_start :
integral_constant<bool,
boost_asio_execution_start_fn::call_traits<R>::is_noexcept>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename R>
constexpr bool is_nothrow_start_v
= is_nothrow_start<R>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
} // namespace execution
} // namespace asio
} // namespace boost
#endif // defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_START_HPP

View File

@@ -0,0 +1,454 @@
//
// execution/submit.hpp
// ~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_EXECUTION_SUBMIT_HPP
#define BOOST_ASIO_EXECUTION_SUBMIT_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/execution/detail/submit_receiver.hpp>
#include <boost/asio/execution/executor.hpp>
#include <boost/asio/execution/receiver.hpp>
#include <boost/asio/execution/sender.hpp>
#include <boost/asio/execution/start.hpp>
#include <boost/asio/traits/submit_member.hpp>
#include <boost/asio/traits/submit_free.hpp>
#include <boost/asio/detail/push_options.hpp>
#if defined(GENERATING_DOCUMENTATION)
namespace boost {
namespace asio {
namespace execution {
/// A customisation point that submits a sender to a receiver.
/**
* The name <tt>execution::submit</tt> denotes a customisation point object. For
* some subexpressions <tt>s</tt> and <tt>r</tt>, let <tt>S</tt> be a type such
* that <tt>decltype((s))</tt> is <tt>S</tt> and let <tt>R</tt> be a type such
* that <tt>decltype((r))</tt> is <tt>R</tt>. The expression
* <tt>execution::submit(s, r)</tt> is ill-formed if <tt>sender_to<S, R></tt> is
* not <tt>true</tt>. Otherwise, it is expression-equivalent to:
*
* @li <tt>s.submit(r)</tt>, if that expression is valid and <tt>S</tt> models
* <tt>sender</tt>. If the function selected does not submit the receiver
* object <tt>r</tt> via the sender <tt>s</tt>, the program is ill-formed with
* no diagnostic required.
*
* @li Otherwise, <tt>submit(s, r)</tt>, if that expression is valid and
* <tt>S</tt> models <tt>sender</tt>, with overload resolution performed in a
* context that includes the declaration <tt>void submit();</tt> and that does
* not include a declaration of <tt>execution::submit</tt>. If the function
* selected by overload resolution does not submit the receiver object
* <tt>r</tt> via the sender <tt>s</tt>, the program is ill-formed with no
* diagnostic required.
*
* @li Otherwise, <tt>execution::start((new submit_receiver<S,
* R>{s,r})->state_)</tt>, where <tt>submit_receiver</tt> is an
* implementation-defined class template equivalent to:
* @code template<class S, class R>
* struct submit_receiver {
* struct wrap {
* submit_receiver * p_;
* template<class...As>
* requires receiver_of<R, As...>
* void set_value(As&&... as) &&
* noexcept(is_nothrow_receiver_of_v<R, As...>) {
* execution::set_value(std::move(p_->r_), (As&&) as...);
* delete p_;
* }
* template<class E>
* requires receiver<R, E>
* void set_error(E&& e) && noexcept {
* execution::set_error(std::move(p_->r_), (E&&) e);
* delete p_;
* }
* void set_done() && noexcept {
* execution::set_done(std::move(p_->r_));
* delete p_;
* }
* };
* remove_cvref_t<R> r_;
* connect_result_t<S, wrap> state_;
* submit_receiver(S&& s, R&& r)
* : r_((R&&) r)
* , state_(execution::connect((S&&) s, wrap{this})) {}
* };
* @endcode
*/
inline constexpr unspecified submit = unspecified;
/// A type trait that determines whether a @c submit expression is
/// well-formed.
/**
* Class template @c can_submit is a trait that is derived from
* @c true_type if the expression <tt>execution::submit(std::declval<R>(),
* std::declval<E>())</tt> is well formed; otherwise @c false_type.
*/
template <typename S, typename R>
struct can_submit :
integral_constant<bool, automatically_determined>
{
};
} // namespace execution
} // namespace asio
} // namespace boost
#else // defined(GENERATING_DOCUMENTATION)
namespace boost_asio_execution_submit_fn {
using boost::asio::declval;
using boost::asio::enable_if;
using boost::asio::execution::is_sender_to;
using boost::asio::traits::submit_free;
using boost::asio::traits::submit_member;
void submit();
enum overload_type
{
call_member,
call_free,
adapter,
ill_formed
};
template <typename S, typename R, typename = void,
typename = void, typename = void>
struct call_traits
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = ill_formed);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
template <typename S, typename R>
struct call_traits<S, void(R),
typename enable_if<
submit_member<S, R>::is_valid
>::type,
typename enable_if<
is_sender_to<S, R>::value
>::type> :
submit_member<S, R>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_member);
};
template <typename S, typename R>
struct call_traits<S, void(R),
typename enable_if<
!submit_member<S, R>::is_valid
>::type,
typename enable_if<
submit_free<S, R>::is_valid
>::type,
typename enable_if<
is_sender_to<S, R>::value
>::type> :
submit_free<S, R>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_free);
};
template <typename S, typename R>
struct call_traits<S, void(R),
typename enable_if<
!submit_member<S, R>::is_valid
>::type,
typename enable_if<
!submit_free<S, R>::is_valid
>::type,
typename enable_if<
is_sender_to<S, R>::value
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = adapter);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
typedef void result_type;
};
struct impl
{
#if defined(BOOST_ASIO_HAS_MOVE)
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(R)>::overload == call_member,
typename call_traits<S, void(R)>::result_type
>::type
operator()(S&& s, R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(R)>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(S)(s).submit(BOOST_ASIO_MOVE_CAST(R)(r));
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(R)>::overload == call_free,
typename call_traits<S, void(R)>::result_type
>::type
operator()(S&& s, R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(R)>::is_noexcept))
{
return submit(BOOST_ASIO_MOVE_CAST(S)(s), BOOST_ASIO_MOVE_CAST(R)(r));
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S, void(R)>::overload == adapter,
typename call_traits<S, void(R)>::result_type
>::type
operator()(S&& s, R&& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S, void(R)>::is_noexcept))
{
return boost::asio::execution::start(
(new boost::asio::execution::detail::submit_receiver<S, R>(
BOOST_ASIO_MOVE_CAST(S)(s), BOOST_ASIO_MOVE_CAST(R)(r)))->state_);
}
#else // defined(BOOST_ASIO_HAS_MOVE)
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(R&)>::overload == call_member,
typename call_traits<S&, void(R&)>::result_type
>::type
operator()(S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(R&)>::is_noexcept))
{
return s.submit(r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(R&)>::overload == call_member,
typename call_traits<const S&, void(R&)>::result_type
>::type
operator()(const S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(R&)>::is_noexcept))
{
return s.submit(r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(R&)>::overload == call_free,
typename call_traits<S&, void(R&)>::result_type
>::type
operator()(S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(R&)>::is_noexcept))
{
return submit(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(R&)>::overload == call_free,
typename call_traits<const S&, void(R&)>::result_type
>::type
operator()(const S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(R&)>::is_noexcept))
{
return submit(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(R&)>::overload == adapter,
typename call_traits<S&, void(R&)>::result_type
>::type
operator()(S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(R&)>::is_noexcept))
{
return boost::asio::execution::start(
(new boost::asio::execution::detail::submit_receiver<
S&, R&>(s, r))->state_);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(R&)>::overload == adapter,
typename call_traits<const S&, void(R&)>::result_type
>::type
operator()(const S& s, R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(R&)>::is_noexcept))
{
boost::asio::execution::start(
(new boost::asio::execution::detail::submit_receiver<
const S&, R&>(s, r))->state_);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(const R&)>::overload == call_member,
typename call_traits<S&, void(const R&)>::result_type
>::type
operator()(S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(const R&)>::is_noexcept))
{
return s.submit(r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(const R&)>::overload == call_member,
typename call_traits<const S&, void(const R&)>::result_type
>::type
operator()(const S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(const R&)>::is_noexcept))
{
return s.submit(r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(const R&)>::overload == call_free,
typename call_traits<S&, void(const R&)>::result_type
>::type
operator()(S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(const R&)>::is_noexcept))
{
return submit(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(const R&)>::overload == call_free,
typename call_traits<const S&, void(const R&)>::result_type
>::type
operator()(const S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(const R&)>::is_noexcept))
{
return submit(s, r);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<S&, void(const R&)>::overload == adapter,
typename call_traits<S&, void(const R&)>::result_type
>::type
operator()(S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<S&, void(const R&)>::is_noexcept))
{
boost::asio::execution::start(
(new boost::asio::execution::detail::submit_receiver<
S&, const R&>(s, r))->state_);
}
template <typename S, typename R>
BOOST_ASIO_CONSTEXPR typename enable_if<
call_traits<const S&, void(const R&)>::overload == adapter,
typename call_traits<const S&, void(const R&)>::result_type
>::type
operator()(const S& s, const R& r) const
BOOST_ASIO_NOEXCEPT_IF((
call_traits<const S&, void(const R&)>::is_noexcept))
{
boost::asio::execution::start(
(new boost::asio::execution::detail::submit_receiver<
const S&, const R&>(s, r))->state_);
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
};
template <typename T = impl>
struct static_instance
{
static const T instance;
};
template <typename T>
const T static_instance<T>::instance = {};
} // namespace boost_asio_execution_submit_fn
namespace boost {
namespace asio {
namespace execution {
namespace {
static BOOST_ASIO_CONSTEXPR const boost_asio_execution_submit_fn::impl&
submit = boost_asio_execution_submit_fn::static_instance<>::instance;
} // namespace
template <typename S, typename R>
struct can_submit :
integral_constant<bool,
boost_asio_execution_submit_fn::call_traits<S, void(R)>::overload !=
boost_asio_execution_submit_fn::ill_formed>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename R>
constexpr bool can_submit_v = can_submit<S, R>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename R>
struct is_nothrow_submit :
integral_constant<bool,
boost_asio_execution_submit_fn::call_traits<S, void(R)>::is_noexcept>
{
};
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename R>
constexpr bool is_nothrow_submit_v
= is_nothrow_submit<S, R>::value;
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename S, typename R>
struct submit_result
{
typedef typename boost_asio_execution_submit_fn::call_traits<
S, void(R)>::result_type type;
};
namespace detail {
template <typename S, typename R>
void submit_helper(BOOST_ASIO_MOVE_ARG(S) s, BOOST_ASIO_MOVE_ARG(R) r)
{
execution::submit(BOOST_ASIO_MOVE_CAST(S)(s), BOOST_ASIO_MOVE_CAST(R)(r));
}
} // namespace detail
} // namespace execution
} // namespace asio
} // namespace boost
#endif // defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_EXECUTION_SUBMIT_HPP