Remove Activ libs and includes
This commit is contained in:
1 parent
28ed30c944
commit
4b718994be
10967 files changed
-2306716
No files matched your search
@@ -1,132 +0,0 @@
|
||||
//
|
||||
// impl/any_completion_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 ACTIV_BOOST_ASIO_IMPL_ANY_COMPLETION_EXECUTOR_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_ANY_COMPLETION_EXECUTOR_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
#include <ActivBoost/asio/any_completion_executor.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
any_completion_executor::any_completion_executor() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type()
|
||||
{
|
||||
}
|
||||
|
||||
any_completion_executor::any_completion_executor(nullptr_t) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type(nullptr_t())
|
||||
{
|
||||
}
|
||||
|
||||
any_completion_executor::any_completion_executor(
|
||||
const any_completion_executor& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type(static_cast<const base_type&>(e))
|
||||
{
|
||||
}
|
||||
|
||||
any_completion_executor::any_completion_executor(std::nothrow_t,
|
||||
const any_completion_executor& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type(static_cast<const base_type&>(e))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
any_completion_executor::any_completion_executor(
|
||||
any_completion_executor&& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type(static_cast<base_type&&>(e))
|
||||
{
|
||||
}
|
||||
|
||||
any_completion_executor::any_completion_executor(std::nothrow_t,
|
||||
any_completion_executor&& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type(static_cast<base_type&&>(e))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
any_completion_executor& any_completion_executor::operator=(
|
||||
const any_completion_executor& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
base_type::operator=(static_cast<const base_type&>(e));
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
any_completion_executor& any_completion_executor::operator=(
|
||||
any_completion_executor&& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
base_type::operator=(static_cast<base_type&&>(e));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
any_completion_executor& any_completion_executor::operator=(nullptr_t)
|
||||
{
|
||||
base_type::operator=(nullptr_t());
|
||||
return *this;
|
||||
}
|
||||
|
||||
any_completion_executor::~any_completion_executor()
|
||||
{
|
||||
}
|
||||
|
||||
void any_completion_executor::swap(
|
||||
any_completion_executor& other) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
static_cast<base_type&>(*this).swap(static_cast<base_type&>(other));
|
||||
}
|
||||
|
||||
template <>
|
||||
any_completion_executor any_completion_executor::prefer(
|
||||
const execution::outstanding_work_t::tracked_t& p, int) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
|
||||
template <>
|
||||
any_completion_executor any_completion_executor::prefer(
|
||||
const execution::outstanding_work_t::untracked_t& p, int) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
|
||||
template <>
|
||||
any_completion_executor any_completion_executor::prefer(
|
||||
const execution::relationship_t::fork_t& p, int) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
|
||||
template <>
|
||||
any_completion_executor any_completion_executor::prefer(
|
||||
const execution::relationship_t::continuation_t& p, int) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_ANY_COMPLETION_EXECUTOR_IPP
|
||||
@@ -1,143 +0,0 @@
|
||||
//
|
||||
// impl/any_io_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 ACTIV_BOOST_ASIO_IMPL_ANY_IO_EXECUTOR_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_ANY_IO_EXECUTOR_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
#include <ActivBoost/asio/any_io_executor.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
any_io_executor::any_io_executor() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type()
|
||||
{
|
||||
}
|
||||
|
||||
any_io_executor::any_io_executor(nullptr_t) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type(nullptr_t())
|
||||
{
|
||||
}
|
||||
|
||||
any_io_executor::any_io_executor(const any_io_executor& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type(static_cast<const base_type&>(e))
|
||||
{
|
||||
}
|
||||
|
||||
any_io_executor::any_io_executor(std::nothrow_t,
|
||||
const any_io_executor& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type(static_cast<const base_type&>(e))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
any_io_executor::any_io_executor(any_io_executor&& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type(static_cast<base_type&&>(e))
|
||||
{
|
||||
}
|
||||
|
||||
any_io_executor::any_io_executor(std::nothrow_t,
|
||||
any_io_executor&& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: base_type(static_cast<base_type&&>(e))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
any_io_executor& any_io_executor::operator=(
|
||||
const any_io_executor& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
base_type::operator=(static_cast<const base_type&>(e));
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
any_io_executor& any_io_executor::operator=(
|
||||
any_io_executor&& e) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
base_type::operator=(static_cast<base_type&&>(e));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
any_io_executor& any_io_executor::operator=(nullptr_t)
|
||||
{
|
||||
base_type::operator=(nullptr_t());
|
||||
return *this;
|
||||
}
|
||||
|
||||
any_io_executor::~any_io_executor()
|
||||
{
|
||||
}
|
||||
|
||||
void any_io_executor::swap(any_io_executor& other) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
static_cast<base_type&>(*this).swap(static_cast<base_type&>(other));
|
||||
}
|
||||
|
||||
template <>
|
||||
any_io_executor any_io_executor::require(
|
||||
const execution::blocking_t::never_t& p, int) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).require(p);
|
||||
}
|
||||
|
||||
template <>
|
||||
any_io_executor any_io_executor::prefer(
|
||||
const execution::blocking_t::possibly_t& p, int) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
|
||||
template <>
|
||||
any_io_executor any_io_executor::prefer(
|
||||
const execution::outstanding_work_t::tracked_t& p, int) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
|
||||
template <>
|
||||
any_io_executor any_io_executor::prefer(
|
||||
const execution::outstanding_work_t::untracked_t& p, int) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
|
||||
template <>
|
||||
any_io_executor any_io_executor::prefer(
|
||||
const execution::relationship_t::fork_t& p, int) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
|
||||
template <>
|
||||
any_io_executor any_io_executor::prefer(
|
||||
const execution::relationship_t::continuation_t& p, int) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_ANY_IO_EXECUTOR_IPP
|
||||
@@ -1,227 +0,0 @@
|
||||
//
|
||||
// impl/append.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 ACTIV_BOOST_ASIO_IMPL_APPEND_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_APPEND_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#include <ActivBoost/asio/associator.hpp>
|
||||
#include <ActivBoost/asio/async_result.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/type_traits.hpp>
|
||||
#include <ActivBoost/asio/detail/utility.hpp>
|
||||
#include <ActivBoost/asio/detail/variadic_templates.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Class to adapt an append_t as a completion handler.
|
||||
template <typename Handler, typename... Values>
|
||||
class append_handler
|
||||
{
|
||||
public:
|
||||
typedef void result_type;
|
||||
|
||||
template <typename H>
|
||||
append_handler(ACTIV_BOOST_ASIO_MOVE_ARG(H) handler, std::tuple<Values...> values)
|
||||
: handler_(ACTIV_BOOST_ASIO_MOVE_CAST(H)(handler)),
|
||||
values_(ACTIV_BOOST_ASIO_MOVE_CAST(std::tuple<Values...>)(values))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
this->invoke(
|
||||
index_sequence_for<Values...>{},
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
template <std::size_t... I, typename... Args>
|
||||
void invoke(index_sequence<I...>, ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Values)(std::get<I>(values_))...);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
std::tuple<Values...> values_;
|
||||
};
|
||||
|
||||
template <typename Handler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
append_handler<Handler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
append_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
append_handler<Handler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
append_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
append_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Signature, typename... Values>
|
||||
struct append_signature;
|
||||
|
||||
template <typename R, typename... Args, typename... Values>
|
||||
struct append_signature<R(Args...), Values...>
|
||||
{
|
||||
typedef R type(typename decay<Args>::type..., Values...);
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename CompletionToken, typename... Values, typename Signature>
|
||||
struct async_result<
|
||||
append_t<CompletionToken, Values...>, Signature>
|
||||
: async_result<CompletionToken,
|
||||
typename detail::append_signature<
|
||||
Signature, Values...>::type>
|
||||
{
|
||||
typedef typename detail::append_signature<
|
||||
Signature, Values...>::type signature;
|
||||
|
||||
template <typename Initiation>
|
||||
struct init_wrapper
|
||||
{
|
||||
init_wrapper(Initiation init)
|
||||
: initiation_(ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(init))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Handler, typename... Args>
|
||||
void operator()(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
std::tuple<Values...> values,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation_)(
|
||||
detail::append_handler<
|
||||
typename decay<Handler>::type, Values...>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Handler)(handler),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(std::tuple<Values...>)(values)),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
Initiation initiation_;
|
||||
};
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static ACTIV_BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(CompletionToken, signature,
|
||||
(async_initiate<CompletionToken, signature>(
|
||||
declval<init_wrapper<typename decay<Initiation>::type> >(),
|
||||
declval<CompletionToken&>(),
|
||||
declval<std::tuple<Values...> >(),
|
||||
declval<ACTIV_BOOST_ASIO_MOVE_ARG(Args)>()...)))
|
||||
initiate(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RawCompletionToken) token,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
return async_initiate<CompletionToken, signature>(
|
||||
init_wrapper<typename decay<Initiation>::type>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation)),
|
||||
token.token_,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(std::tuple<Values...>)(token.values_),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename Handler, typename... Values, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::append_handler<Handler, Values...>, DefaultCandidate>
|
||||
: Associator<Handler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<Handler, DefaultCandidate>::type
|
||||
get(const detail::append_handler<Handler, Values...>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<Handler, DefaultCandidate>::type)
|
||||
get(const detail::append_handler<Handler, Values...>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<Handler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_APPEND_HPP
|
||||
@@ -1,255 +0,0 @@
|
||||
//
|
||||
// impl/as_tuple.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 ACTIV_BOOST_ASIO_IMPL_AS_TUPLE_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_AS_TUPLE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include <ActivBoost/asio/associator.hpp>
|
||||
#include <ActivBoost/asio/async_result.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/type_traits.hpp>
|
||||
#include <ActivBoost/asio/detail/variadic_templates.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Class to adapt a as_tuple_t as a completion handler.
|
||||
template <typename Handler>
|
||||
class as_tuple_handler
|
||||
{
|
||||
public:
|
||||
typedef void result_type;
|
||||
|
||||
template <typename CompletionToken>
|
||||
as_tuple_handler(as_tuple_t<CompletionToken> e)
|
||||
: handler_(ACTIV_BOOST_ASIO_MOVE_CAST(CompletionToken)(e.token_))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename RedirectedHandler>
|
||||
as_tuple_handler(ACTIV_BOOST_ASIO_MOVE_ARG(RedirectedHandler) h)
|
||||
: handler_(ACTIV_BOOST_ASIO_MOVE_CAST(RedirectedHandler)(h))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)(
|
||||
std::make_tuple(ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...));
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
};
|
||||
|
||||
template <typename Handler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
as_tuple_handler<Handler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
as_tuple_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
as_tuple_handler<Handler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
as_tuple_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
as_tuple_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Signature>
|
||||
struct as_tuple_signature;
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct as_tuple_signature<R(Args...)>
|
||||
{
|
||||
typedef R type(std::tuple<typename decay<Args>::type...>);
|
||||
};
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct as_tuple_signature<R(Args...) &>
|
||||
{
|
||||
typedef R type(std::tuple<typename decay<Args>::type...>) &;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct as_tuple_signature<R(Args...) &&>
|
||||
{
|
||||
typedef R type(std::tuple<typename decay<Args>::type...>) &&;
|
||||
};
|
||||
|
||||
# if defined(ACTIV_BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct as_tuple_signature<R(Args...) noexcept>
|
||||
{
|
||||
typedef R type(std::tuple<typename decay<Args>::type...>) noexcept;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct as_tuple_signature<R(Args...) & noexcept>
|
||||
{
|
||||
typedef R type(std::tuple<typename decay<Args>::type...>) & noexcept;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct as_tuple_signature<R(Args...) && noexcept>
|
||||
{
|
||||
typedef R type(std::tuple<typename decay<Args>::type...>) && noexcept;
|
||||
};
|
||||
|
||||
# endif // defined(ACTIV_BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename CompletionToken, typename... Signatures>
|
||||
struct async_result<as_tuple_t<CompletionToken>, Signatures...>
|
||||
: async_result<CompletionToken,
|
||||
typename detail::as_tuple_signature<Signatures>::type...>
|
||||
{
|
||||
typedef async_result<CompletionToken,
|
||||
typename detail::as_tuple_signature<Signatures>::type...>
|
||||
base_async_result;
|
||||
|
||||
template <typename Initiation>
|
||||
struct init_wrapper
|
||||
{
|
||||
init_wrapper(Initiation init)
|
||||
: initiation_(ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(init))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Handler, typename... Args>
|
||||
void operator()(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation_)(
|
||||
detail::as_tuple_handler<
|
||||
typename decay<Handler>::type>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
Initiation initiation_;
|
||||
};
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static ACTIV_BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(CompletionToken,
|
||||
typename detail::as_tuple_signature<Signatures>::type...,
|
||||
(base_async_result::initiate(
|
||||
declval<init_wrapper<typename decay<Initiation>::type> >(),
|
||||
declval<CompletionToken>(),
|
||||
declval<ACTIV_BOOST_ASIO_MOVE_ARG(Args)>()...)))
|
||||
initiate(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RawCompletionToken) token,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
return base_async_result::initiate(
|
||||
init_wrapper<typename decay<Initiation>::type>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation)),
|
||||
token.token_, ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename Handler, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::as_tuple_handler<Handler>, DefaultCandidate>
|
||||
: Associator<Handler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<Handler, DefaultCandidate>::type
|
||||
get(const detail::as_tuple_handler<Handler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<Handler, DefaultCandidate>::type)
|
||||
get(const detail::as_tuple_handler<Handler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<Handler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_AS_TUPLE_HPP
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,529 +0,0 @@
|
||||
//
|
||||
// impl/buffered_read_stream.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 ACTIV_BOOST_ASIO_IMPL_BUFFERED_READ_STREAM_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_BUFFERED_READ_STREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/associator.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <ActivBoost/asio/detail/non_const_lvalue.hpp>
|
||||
#include <ActivBoost/asio/detail/type_traits.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
template <typename Stream>
|
||||
std::size_t buffered_read_stream<Stream>::fill()
|
||||
{
|
||||
detail::buffer_resize_guard<detail::buffered_stream_storage>
|
||||
resize_guard(storage_);
|
||||
std::size_t previous_size = storage_.size();
|
||||
storage_.resize(storage_.capacity());
|
||||
storage_.resize(previous_size + next_layer_.read_some(buffer(
|
||||
storage_.data() + previous_size,
|
||||
storage_.size() - previous_size)));
|
||||
resize_guard.commit();
|
||||
return storage_.size() - previous_size;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
std::size_t buffered_read_stream<Stream>::fill(Boost::system::error_code& ec)
|
||||
{
|
||||
detail::buffer_resize_guard<detail::buffered_stream_storage>
|
||||
resize_guard(storage_);
|
||||
std::size_t previous_size = storage_.size();
|
||||
storage_.resize(storage_.capacity());
|
||||
storage_.resize(previous_size + next_layer_.read_some(buffer(
|
||||
storage_.data() + previous_size,
|
||||
storage_.size() - previous_size),
|
||||
ec));
|
||||
resize_guard.commit();
|
||||
return storage_.size() - previous_size;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename ReadHandler>
|
||||
class buffered_fill_handler
|
||||
{
|
||||
public:
|
||||
buffered_fill_handler(detail::buffered_stream_storage& storage,
|
||||
std::size_t previous_size, ReadHandler& handler)
|
||||
: storage_(storage),
|
||||
previous_size_(previous_size),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
buffered_fill_handler(const buffered_fill_handler& other)
|
||||
: storage_(other.storage_),
|
||||
previous_size_(other.previous_size_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
buffered_fill_handler(buffered_fill_handler&& other)
|
||||
: storage_(other.storage_),
|
||||
previous_size_(other.previous_size_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()(const Boost::system::error_code& ec,
|
||||
const std::size_t bytes_transferred)
|
||||
{
|
||||
storage_.resize(previous_size_ + bytes_transferred);
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(ReadHandler)(handler_)(ec, bytes_transferred);
|
||||
}
|
||||
|
||||
//private:
|
||||
detail::buffered_stream_storage& storage_;
|
||||
std::size_t previous_size_;
|
||||
ReadHandler handler_;
|
||||
};
|
||||
|
||||
template <typename ReadHandler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
buffered_fill_handler<ReadHandler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename ReadHandler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
buffered_fill_handler<ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename ReadHandler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
buffered_fill_handler<ReadHandler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename ReadHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
buffered_fill_handler<ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename ReadHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
buffered_fill_handler<ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
class initiate_async_buffered_fill
|
||||
{
|
||||
public:
|
||||
typedef typename remove_reference<
|
||||
Stream>::type::lowest_layer_type::executor_type executor_type;
|
||||
|
||||
explicit initiate_async_buffered_fill(
|
||||
typename remove_reference<Stream>::type& next_layer)
|
||||
: next_layer_(next_layer)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return next_layer_.lowest_layer().get_executor();
|
||||
}
|
||||
|
||||
template <typename ReadHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
|
||||
buffered_stream_storage* storage) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a ReadHandler.
|
||||
ACTIV_BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
non_const_lvalue<ReadHandler> handler2(handler);
|
||||
std::size_t previous_size = storage->size();
|
||||
storage->resize(storage->capacity());
|
||||
next_layer_.async_read_some(
|
||||
buffer(
|
||||
storage->data() + previous_size,
|
||||
storage->size() - previous_size),
|
||||
buffered_fill_handler<typename decay<ReadHandler>::type>(
|
||||
*storage, previous_size, handler2.value));
|
||||
}
|
||||
|
||||
private:
|
||||
typename remove_reference<Stream>::type& next_layer_;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename ReadHandler, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::buffered_fill_handler<ReadHandler>,
|
||||
DefaultCandidate>
|
||||
: Associator<ReadHandler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<ReadHandler, DefaultCandidate>::type
|
||||
get(const detail::buffered_fill_handler<ReadHandler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<ReadHandler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<ReadHandler, DefaultCandidate>::type)
|
||||
get(const detail::buffered_fill_handler<ReadHandler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename Stream>
|
||||
template <
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) ReadHandler>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadHandler,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
buffered_read_stream<Stream>::async_fill(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<ReadHandler,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_buffered_fill<Stream> >(),
|
||||
handler, declval<detail::buffered_stream_storage*>())))
|
||||
{
|
||||
return async_initiate<ReadHandler,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_buffered_fill<Stream>(next_layer_),
|
||||
handler, &storage_);
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t buffered_read_stream<Stream>::read_some(
|
||||
const MutableBufferSequence& buffers)
|
||||
{
|
||||
using Boost::asio::buffer_size;
|
||||
if (buffer_size(buffers) == 0)
|
||||
return 0;
|
||||
|
||||
if (storage_.empty())
|
||||
this->fill();
|
||||
|
||||
return this->copy(buffers);
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t buffered_read_stream<Stream>::read_some(
|
||||
const MutableBufferSequence& buffers, Boost::system::error_code& ec)
|
||||
{
|
||||
ec = Boost::system::error_code();
|
||||
|
||||
using Boost::asio::buffer_size;
|
||||
if (buffer_size(buffers) == 0)
|
||||
return 0;
|
||||
|
||||
if (storage_.empty() && !this->fill(ec))
|
||||
return 0;
|
||||
|
||||
return this->copy(buffers);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
class buffered_read_some_handler
|
||||
{
|
||||
public:
|
||||
buffered_read_some_handler(detail::buffered_stream_storage& storage,
|
||||
const MutableBufferSequence& buffers, ReadHandler& handler)
|
||||
: storage_(storage),
|
||||
buffers_(buffers),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
buffered_read_some_handler(const buffered_read_some_handler& other)
|
||||
: storage_(other.storage_),
|
||||
buffers_(other.buffers_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
buffered_read_some_handler(buffered_read_some_handler&& other)
|
||||
: storage_(other.storage_),
|
||||
buffers_(other.buffers_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()(const Boost::system::error_code& ec, std::size_t)
|
||||
{
|
||||
if (ec || storage_.empty())
|
||||
{
|
||||
const std::size_t length = 0;
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(ReadHandler)(handler_)(ec, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::size_t bytes_copied = Boost::asio::buffer_copy(
|
||||
buffers_, storage_.data(), storage_.size());
|
||||
storage_.consume(bytes_copied);
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(ReadHandler)(handler_)(ec, bytes_copied);
|
||||
}
|
||||
}
|
||||
|
||||
//private:
|
||||
detail::buffered_stream_storage& storage_;
|
||||
MutableBufferSequence buffers_;
|
||||
ReadHandler handler_;
|
||||
};
|
||||
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
buffered_read_some_handler<
|
||||
MutableBufferSequence, ReadHandler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
buffered_read_some_handler<
|
||||
MutableBufferSequence, ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
buffered_read_some_handler<
|
||||
MutableBufferSequence, ReadHandler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename MutableBufferSequence,
|
||||
typename ReadHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
buffered_read_some_handler<
|
||||
MutableBufferSequence, ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename MutableBufferSequence,
|
||||
typename ReadHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
buffered_read_some_handler<
|
||||
MutableBufferSequence, ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
class initiate_async_buffered_read_some
|
||||
{
|
||||
public:
|
||||
typedef typename remove_reference<
|
||||
Stream>::type::lowest_layer_type::executor_type executor_type;
|
||||
|
||||
explicit initiate_async_buffered_read_some(
|
||||
typename remove_reference<Stream>::type& next_layer)
|
||||
: next_layer_(next_layer)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return next_layer_.lowest_layer().get_executor();
|
||||
}
|
||||
|
||||
template <typename ReadHandler, typename MutableBufferSequence>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
|
||||
buffered_stream_storage* storage,
|
||||
const MutableBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a ReadHandler.
|
||||
ACTIV_BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
using Boost::asio::buffer_size;
|
||||
non_const_lvalue<ReadHandler> handler2(handler);
|
||||
if (buffer_size(buffers) == 0 || !storage->empty())
|
||||
{
|
||||
next_layer_.async_read_some(ACTIV_BOOST_ASIO_MUTABLE_BUFFER(0, 0),
|
||||
buffered_read_some_handler<MutableBufferSequence,
|
||||
typename decay<ReadHandler>::type>(
|
||||
*storage, buffers, handler2.value));
|
||||
}
|
||||
else
|
||||
{
|
||||
initiate_async_buffered_fill<Stream>(this->next_layer_)(
|
||||
buffered_read_some_handler<MutableBufferSequence,
|
||||
typename decay<ReadHandler>::type>(
|
||||
*storage, buffers, handler2.value),
|
||||
storage);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
typename remove_reference<Stream>::type& next_layer_;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename MutableBufferSequence, typename ReadHandler,
|
||||
typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::buffered_read_some_handler<MutableBufferSequence, ReadHandler>,
|
||||
DefaultCandidate>
|
||||
: Associator<ReadHandler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<ReadHandler, DefaultCandidate>::type
|
||||
get(const detail::buffered_read_some_handler<
|
||||
MutableBufferSequence, ReadHandler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<ReadHandler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<ReadHandler, DefaultCandidate>::type)
|
||||
get(const detail::buffered_read_some_handler<
|
||||
MutableBufferSequence, ReadHandler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename Stream>
|
||||
template <typename MutableBufferSequence,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) ReadHandler>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadHandler,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
buffered_read_stream<Stream>::async_read_some(
|
||||
const MutableBufferSequence& buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<ReadHandler,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_buffered_read_some<Stream> >(),
|
||||
handler, declval<detail::buffered_stream_storage*>(), buffers)))
|
||||
{
|
||||
return async_initiate<ReadHandler,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_buffered_read_some<Stream>(next_layer_),
|
||||
handler, &storage_, buffers);
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t buffered_read_stream<Stream>::peek(
|
||||
const MutableBufferSequence& buffers)
|
||||
{
|
||||
if (storage_.empty())
|
||||
this->fill();
|
||||
return this->peek_copy(buffers);
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t buffered_read_stream<Stream>::peek(
|
||||
const MutableBufferSequence& buffers, Boost::system::error_code& ec)
|
||||
{
|
||||
ec = Boost::system::error_code();
|
||||
if (storage_.empty() && !this->fill(ec))
|
||||
return 0;
|
||||
return this->peek_copy(buffers);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_BUFFERED_READ_STREAM_HPP
|
||||
@@ -1,509 +0,0 @@
|
||||
//
|
||||
// impl/buffered_write_stream.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 ACTIV_BOOST_ASIO_IMPL_BUFFERED_WRITE_STREAM_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_BUFFERED_WRITE_STREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/associator.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <ActivBoost/asio/detail/non_const_lvalue.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
template <typename Stream>
|
||||
std::size_t buffered_write_stream<Stream>::flush()
|
||||
{
|
||||
std::size_t bytes_written = write(next_layer_,
|
||||
buffer(storage_.data(), storage_.size()));
|
||||
storage_.consume(bytes_written);
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
std::size_t buffered_write_stream<Stream>::flush(Boost::system::error_code& ec)
|
||||
{
|
||||
std::size_t bytes_written = write(next_layer_,
|
||||
buffer(storage_.data(), storage_.size()),
|
||||
transfer_all(), ec);
|
||||
storage_.consume(bytes_written);
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename WriteHandler>
|
||||
class buffered_flush_handler
|
||||
{
|
||||
public:
|
||||
buffered_flush_handler(detail::buffered_stream_storage& storage,
|
||||
WriteHandler& handler)
|
||||
: storage_(storage),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
buffered_flush_handler(const buffered_flush_handler& other)
|
||||
: storage_(other.storage_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
buffered_flush_handler(buffered_flush_handler&& other)
|
||||
: storage_(other.storage_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(WriteHandler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()(const Boost::system::error_code& ec,
|
||||
const std::size_t bytes_written)
|
||||
{
|
||||
storage_.consume(bytes_written);
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(WriteHandler)(handler_)(ec, bytes_written);
|
||||
}
|
||||
|
||||
//private:
|
||||
detail::buffered_stream_storage& storage_;
|
||||
WriteHandler handler_;
|
||||
};
|
||||
|
||||
template <typename WriteHandler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
buffered_flush_handler<WriteHandler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename WriteHandler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
buffered_flush_handler<WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename WriteHandler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
buffered_flush_handler<WriteHandler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename WriteHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
buffered_flush_handler<WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename WriteHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
buffered_flush_handler<WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
class initiate_async_buffered_flush
|
||||
{
|
||||
public:
|
||||
typedef typename remove_reference<
|
||||
Stream>::type::lowest_layer_type::executor_type executor_type;
|
||||
|
||||
explicit initiate_async_buffered_flush(
|
||||
typename remove_reference<Stream>::type& next_layer)
|
||||
: next_layer_(next_layer)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return next_layer_.lowest_layer().get_executor();
|
||||
}
|
||||
|
||||
template <typename WriteHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(WriteHandler) handler,
|
||||
buffered_stream_storage* storage) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WriteHandler.
|
||||
ACTIV_BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
non_const_lvalue<WriteHandler> handler2(handler);
|
||||
async_write(next_layer_, buffer(storage->data(), storage->size()),
|
||||
buffered_flush_handler<typename decay<WriteHandler>::type>(
|
||||
*storage, handler2.value));
|
||||
}
|
||||
|
||||
private:
|
||||
typename remove_reference<Stream>::type& next_layer_;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename WriteHandler, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::buffered_flush_handler<WriteHandler>,
|
||||
DefaultCandidate>
|
||||
: Associator<WriteHandler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<WriteHandler, DefaultCandidate>::type
|
||||
get(const detail::buffered_flush_handler<WriteHandler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<WriteHandler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<WriteHandler, DefaultCandidate>::type)
|
||||
get(const detail::buffered_flush_handler<WriteHandler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<WriteHandler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<WriteHandler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename Stream>
|
||||
template <
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) WriteHandler>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteHandler,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
buffered_write_stream<Stream>::async_flush(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<WriteHandler,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_buffered_flush<Stream> >(),
|
||||
handler, declval<detail::buffered_stream_storage*>())))
|
||||
{
|
||||
return async_initiate<WriteHandler,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_buffered_flush<Stream>(next_layer_),
|
||||
handler, &storage_);
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t buffered_write_stream<Stream>::write_some(
|
||||
const ConstBufferSequence& buffers)
|
||||
{
|
||||
using Boost::asio::buffer_size;
|
||||
if (buffer_size(buffers) == 0)
|
||||
return 0;
|
||||
|
||||
if (storage_.size() == storage_.capacity())
|
||||
this->flush();
|
||||
|
||||
return this->copy(buffers);
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t buffered_write_stream<Stream>::write_some(
|
||||
const ConstBufferSequence& buffers, Boost::system::error_code& ec)
|
||||
{
|
||||
ec = Boost::system::error_code();
|
||||
|
||||
using Boost::asio::buffer_size;
|
||||
if (buffer_size(buffers) == 0)
|
||||
return 0;
|
||||
|
||||
if (storage_.size() == storage_.capacity() && !flush(ec))
|
||||
return 0;
|
||||
|
||||
return this->copy(buffers);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
class buffered_write_some_handler
|
||||
{
|
||||
public:
|
||||
buffered_write_some_handler(detail::buffered_stream_storage& storage,
|
||||
const ConstBufferSequence& buffers, WriteHandler& handler)
|
||||
: storage_(storage),
|
||||
buffers_(buffers),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
buffered_write_some_handler(const buffered_write_some_handler& other)
|
||||
: storage_(other.storage_),
|
||||
buffers_(other.buffers_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
buffered_write_some_handler(buffered_write_some_handler&& other)
|
||||
: storage_(other.storage_),
|
||||
buffers_(other.buffers_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(WriteHandler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()(const Boost::system::error_code& ec, std::size_t)
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
const std::size_t length = 0;
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(WriteHandler)(handler_)(ec, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
using Boost::asio::buffer_size;
|
||||
std::size_t orig_size = storage_.size();
|
||||
std::size_t space_avail = storage_.capacity() - orig_size;
|
||||
std::size_t bytes_avail = buffer_size(buffers_);
|
||||
std::size_t length = bytes_avail < space_avail
|
||||
? bytes_avail : space_avail;
|
||||
storage_.resize(orig_size + length);
|
||||
const std::size_t bytes_copied = Boost::asio::buffer_copy(
|
||||
storage_.data() + orig_size, buffers_, length);
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(WriteHandler)(handler_)(ec, bytes_copied);
|
||||
}
|
||||
}
|
||||
|
||||
//private:
|
||||
detail::buffered_stream_storage& storage_;
|
||||
ConstBufferSequence buffers_;
|
||||
WriteHandler handler_;
|
||||
};
|
||||
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
buffered_write_some_handler<
|
||||
ConstBufferSequence, WriteHandler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
buffered_write_some_handler<
|
||||
ConstBufferSequence, WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
buffered_write_some_handler<
|
||||
ConstBufferSequence, WriteHandler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename ConstBufferSequence,
|
||||
typename WriteHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
buffered_write_some_handler<
|
||||
ConstBufferSequence, WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename ConstBufferSequence,
|
||||
typename WriteHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
buffered_write_some_handler<
|
||||
ConstBufferSequence, WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
class initiate_async_buffered_write_some
|
||||
{
|
||||
public:
|
||||
typedef typename remove_reference<
|
||||
Stream>::type::lowest_layer_type::executor_type executor_type;
|
||||
|
||||
explicit initiate_async_buffered_write_some(
|
||||
typename remove_reference<Stream>::type& next_layer)
|
||||
: next_layer_(next_layer)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return next_layer_.lowest_layer().get_executor();
|
||||
}
|
||||
|
||||
template <typename WriteHandler, typename ConstBufferSequence>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(WriteHandler) handler,
|
||||
buffered_stream_storage* storage,
|
||||
const ConstBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WriteHandler.
|
||||
ACTIV_BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
using Boost::asio::buffer_size;
|
||||
non_const_lvalue<WriteHandler> handler2(handler);
|
||||
if (buffer_size(buffers) == 0 || storage->size() < storage->capacity())
|
||||
{
|
||||
next_layer_.async_write_some(ACTIV_BOOST_ASIO_CONST_BUFFER(0, 0),
|
||||
buffered_write_some_handler<ConstBufferSequence,
|
||||
typename decay<WriteHandler>::type>(
|
||||
*storage, buffers, handler2.value));
|
||||
}
|
||||
else
|
||||
{
|
||||
initiate_async_buffered_flush<Stream>(this->next_layer_)(
|
||||
buffered_write_some_handler<ConstBufferSequence,
|
||||
typename decay<WriteHandler>::type>(
|
||||
*storage, buffers, handler2.value),
|
||||
storage);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
typename remove_reference<Stream>::type& next_layer_;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename ConstBufferSequence, typename WriteHandler,
|
||||
typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::buffered_write_some_handler<ConstBufferSequence, WriteHandler>,
|
||||
DefaultCandidate>
|
||||
: Associator<WriteHandler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<WriteHandler, DefaultCandidate>::type
|
||||
get(const detail::buffered_write_some_handler<
|
||||
ConstBufferSequence, WriteHandler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<WriteHandler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<WriteHandler, DefaultCandidate>::type)
|
||||
get(const detail::buffered_write_some_handler<
|
||||
ConstBufferSequence, WriteHandler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<WriteHandler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<WriteHandler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename Stream>
|
||||
template <typename ConstBufferSequence,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) WriteHandler>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteHandler,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
buffered_write_stream<Stream>::async_write_some(
|
||||
const ConstBufferSequence& buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<WriteHandler,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_buffered_write_some<Stream> >(),
|
||||
handler, declval<detail::buffered_stream_storage*>(), buffers)))
|
||||
{
|
||||
return async_initiate<WriteHandler,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_buffered_write_some<Stream>(next_layer_),
|
||||
handler, &storage_, buffers);
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t buffered_write_stream<Stream>::copy(
|
||||
const ConstBufferSequence& buffers)
|
||||
{
|
||||
using Boost::asio::buffer_size;
|
||||
std::size_t orig_size = storage_.size();
|
||||
std::size_t space_avail = storage_.capacity() - orig_size;
|
||||
std::size_t bytes_avail = buffer_size(buffers);
|
||||
std::size_t length = bytes_avail < space_avail ? bytes_avail : space_avail;
|
||||
storage_.resize(orig_size + length);
|
||||
return Boost::asio::buffer_copy(
|
||||
storage_.data() + orig_size, buffers, length);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_BUFFERED_WRITE_STREAM_HPP
|
||||
@@ -1,98 +0,0 @@
|
||||
//
|
||||
// impl/cancellation_signal.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 ACTIV_BOOST_ASIO_IMPL_CANCELLATION_SIGNAL_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_CANCELLATION_SIGNAL_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/cancellation_signal.hpp>
|
||||
#include <ActivBoost/asio/detail/thread_context.hpp>
|
||||
#include <ActivBoost/asio/detail/thread_info_base.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
cancellation_signal::~cancellation_signal()
|
||||
{
|
||||
if (handler_)
|
||||
{
|
||||
std::pair<void*, std::size_t> mem = handler_->destroy();
|
||||
detail::thread_info_base::deallocate(
|
||||
detail::thread_info_base::cancellation_signal_tag(),
|
||||
detail::thread_context::top_of_thread_call_stack(),
|
||||
mem.first, mem.second);
|
||||
}
|
||||
}
|
||||
|
||||
void cancellation_slot::clear()
|
||||
{
|
||||
if (handler_ != 0 && *handler_ != 0)
|
||||
{
|
||||
std::pair<void*, std::size_t> mem = (*handler_)->destroy();
|
||||
detail::thread_info_base::deallocate(
|
||||
detail::thread_info_base::cancellation_signal_tag(),
|
||||
detail::thread_context::top_of_thread_call_stack(),
|
||||
mem.first, mem.second);
|
||||
*handler_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<void*, std::size_t> cancellation_slot::prepare_memory(
|
||||
std::size_t size, std::size_t align)
|
||||
{
|
||||
assert(handler_);
|
||||
std::pair<void*, std::size_t> mem;
|
||||
if (*handler_)
|
||||
{
|
||||
mem = (*handler_)->destroy();
|
||||
*handler_ = 0;
|
||||
}
|
||||
if (size > mem.second
|
||||
|| reinterpret_cast<std::size_t>(mem.first) % align != 0)
|
||||
{
|
||||
if (mem.first)
|
||||
{
|
||||
detail::thread_info_base::deallocate(
|
||||
detail::thread_info_base::cancellation_signal_tag(),
|
||||
detail::thread_context::top_of_thread_call_stack(),
|
||||
mem.first, mem.second);
|
||||
}
|
||||
mem.first = detail::thread_info_base::allocate(
|
||||
detail::thread_info_base::cancellation_signal_tag(),
|
||||
detail::thread_context::top_of_thread_call_stack(),
|
||||
size, align);
|
||||
mem.second = size;
|
||||
}
|
||||
return mem;
|
||||
}
|
||||
|
||||
cancellation_slot::auto_delete_helper::~auto_delete_helper()
|
||||
{
|
||||
if (mem.first)
|
||||
{
|
||||
detail::thread_info_base::deallocate(
|
||||
detail::thread_info_base::cancellation_signal_tag(),
|
||||
detail::thread_context::top_of_thread_call_stack(),
|
||||
mem.first, mem.second);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_CANCELLATION_SIGNAL_IPP
|
||||
@@ -1,401 +0,0 @@
|
||||
//
|
||||
// impl/co_spawn.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 ACTIV_BOOST_ASIO_IMPL_CO_SPAWN_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_CO_SPAWN_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/associated_cancellation_slot.hpp>
|
||||
#include <ActivBoost/asio/awaitable.hpp>
|
||||
#include <ActivBoost/asio/dispatch.hpp>
|
||||
#include <ActivBoost/asio/execution/outstanding_work.hpp>
|
||||
#include <ActivBoost/asio/post.hpp>
|
||||
#include <ActivBoost/asio/prefer.hpp>
|
||||
#include <ActivBoost/asio/use_awaitable.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
template <typename Executor, typename = void>
|
||||
class co_spawn_work_guard
|
||||
{
|
||||
public:
|
||||
typedef typename decay<
|
||||
typename prefer_result<Executor,
|
||||
execution::outstanding_work_t::tracked_t
|
||||
>::type
|
||||
>::type executor_type;
|
||||
|
||||
co_spawn_work_guard(const Executor& ex)
|
||||
: executor_(Boost::asio::prefer(ex, execution::outstanding_work.tracked))
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return executor_;
|
||||
}
|
||||
|
||||
private:
|
||||
executor_type executor_;
|
||||
};
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
template <typename Executor>
|
||||
struct co_spawn_work_guard<Executor,
|
||||
typename enable_if<
|
||||
!execution::is_executor<Executor>::value
|
||||
>::type> : executor_work_guard<Executor>
|
||||
{
|
||||
co_spawn_work_guard(const Executor& ex)
|
||||
: executor_work_guard<Executor>(ex)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
template <typename Executor>
|
||||
inline co_spawn_work_guard<Executor>
|
||||
make_co_spawn_work_guard(const Executor& ex)
|
||||
{
|
||||
return co_spawn_work_guard<Executor>(ex);
|
||||
}
|
||||
|
||||
template <typename T, typename Executor, typename F, typename Handler>
|
||||
awaitable<awaitable_thread_entry_point, Executor> co_spawn_entry_point(
|
||||
awaitable<T, Executor>*, Executor ex, F f, Handler handler)
|
||||
{
|
||||
auto spawn_work = make_co_spawn_work_guard(ex);
|
||||
auto handler_work = make_co_spawn_work_guard(
|
||||
Boost::asio::get_associated_executor(handler, ex));
|
||||
|
||||
(void) co_await (dispatch)(
|
||||
use_awaitable_t<Executor>{__FILE__, __LINE__, "co_spawn_entry_point"});
|
||||
|
||||
(co_await awaitable_thread_has_context_switched{}) = false;
|
||||
std::exception_ptr e = nullptr;
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
T t = co_await f();
|
||||
|
||||
done = true;
|
||||
|
||||
bool switched = (co_await awaitable_thread_has_context_switched{});
|
||||
if (!switched)
|
||||
{
|
||||
(void) co_await (post)(
|
||||
use_awaitable_t<Executor>{__FILE__,
|
||||
__LINE__, "co_spawn_entry_point"});
|
||||
}
|
||||
|
||||
(dispatch)(handler_work.get_executor(),
|
||||
[handler = std::move(handler), t = std::move(t)]() mutable
|
||||
{
|
||||
std::move(handler)(std::exception_ptr(), std::move(t));
|
||||
});
|
||||
|
||||
co_return;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (done)
|
||||
throw;
|
||||
|
||||
e = std::current_exception();
|
||||
}
|
||||
|
||||
bool switched = (co_await awaitable_thread_has_context_switched{});
|
||||
if (!switched)
|
||||
{
|
||||
(void) co_await (post)(
|
||||
use_awaitable_t<Executor>{__FILE__, __LINE__, "co_spawn_entry_point"});
|
||||
}
|
||||
|
||||
(dispatch)(handler_work.get_executor(),
|
||||
[handler = std::move(handler), e]() mutable
|
||||
{
|
||||
std::move(handler)(e, T());
|
||||
});
|
||||
}
|
||||
|
||||
template <typename Executor, typename F, typename Handler>
|
||||
awaitable<awaitable_thread_entry_point, Executor> co_spawn_entry_point(
|
||||
awaitable<void, Executor>*, Executor ex, F f, Handler handler)
|
||||
{
|
||||
auto spawn_work = make_co_spawn_work_guard(ex);
|
||||
auto handler_work = make_co_spawn_work_guard(
|
||||
Boost::asio::get_associated_executor(handler, ex));
|
||||
|
||||
(void) co_await (dispatch)(
|
||||
use_awaitable_t<Executor>{__FILE__, __LINE__, "co_spawn_entry_point"});
|
||||
|
||||
(co_await awaitable_thread_has_context_switched{}) = false;
|
||||
std::exception_ptr e = nullptr;
|
||||
try
|
||||
{
|
||||
co_await f();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
e = std::current_exception();
|
||||
}
|
||||
|
||||
bool switched = (co_await awaitable_thread_has_context_switched{});
|
||||
if (!switched)
|
||||
{
|
||||
(void) co_await (post)(
|
||||
use_awaitable_t<Executor>{__FILE__, __LINE__, "co_spawn_entry_point"});
|
||||
}
|
||||
|
||||
(dispatch)(handler_work.get_executor(),
|
||||
[handler = std::move(handler), e]() mutable
|
||||
{
|
||||
std::move(handler)(e);
|
||||
});
|
||||
}
|
||||
|
||||
template <typename T, typename Executor>
|
||||
class awaitable_as_function
|
||||
{
|
||||
public:
|
||||
explicit awaitable_as_function(awaitable<T, Executor>&& a)
|
||||
: awaitable_(std::move(a))
|
||||
{
|
||||
}
|
||||
|
||||
awaitable<T, Executor> operator()()
|
||||
{
|
||||
return std::move(awaitable_);
|
||||
}
|
||||
|
||||
private:
|
||||
awaitable<T, Executor> awaitable_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Executor, typename = void>
|
||||
class co_spawn_cancellation_handler
|
||||
{
|
||||
public:
|
||||
co_spawn_cancellation_handler(const Handler&, const Executor& ex)
|
||||
: ex_(ex)
|
||||
{
|
||||
}
|
||||
|
||||
cancellation_slot slot()
|
||||
{
|
||||
return signal_.slot();
|
||||
}
|
||||
|
||||
void operator()(cancellation_type_t type)
|
||||
{
|
||||
cancellation_signal* sig = &signal_;
|
||||
Boost::asio::dispatch(ex_, [sig, type]{ sig->emit(type); });
|
||||
}
|
||||
|
||||
private:
|
||||
cancellation_signal signal_;
|
||||
Executor ex_;
|
||||
};
|
||||
|
||||
|
||||
template <typename Handler, typename Executor>
|
||||
class co_spawn_cancellation_handler<Handler, Executor,
|
||||
typename enable_if<
|
||||
is_same<
|
||||
typename associated_executor<Handler,
|
||||
Executor>::asio_associated_executor_is_unspecialised,
|
||||
void
|
||||
>::value
|
||||
>::type>
|
||||
{
|
||||
public:
|
||||
co_spawn_cancellation_handler(const Handler&, const Executor&)
|
||||
{
|
||||
}
|
||||
|
||||
cancellation_slot slot()
|
||||
{
|
||||
return signal_.slot();
|
||||
}
|
||||
|
||||
void operator()(cancellation_type_t type)
|
||||
{
|
||||
signal_.emit(type);
|
||||
}
|
||||
|
||||
private:
|
||||
cancellation_signal signal_;
|
||||
};
|
||||
|
||||
template <typename Executor>
|
||||
class initiate_co_spawn
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
template <typename OtherExecutor>
|
||||
explicit initiate_co_spawn(const OtherExecutor& ex)
|
||||
: ex_(ex)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return ex_;
|
||||
}
|
||||
|
||||
template <typename Handler, typename F>
|
||||
void operator()(Handler&& handler, F&& f) const
|
||||
{
|
||||
typedef typename result_of<F()>::type awaitable_type;
|
||||
typedef typename decay<Handler>::type handler_type;
|
||||
typedef co_spawn_cancellation_handler<
|
||||
handler_type, Executor> cancel_handler_type;
|
||||
|
||||
auto slot = Boost::asio::get_associated_cancellation_slot(handler);
|
||||
cancel_handler_type* cancel_handler = slot.is_connected()
|
||||
? &slot.template emplace<cancel_handler_type>(handler, ex_)
|
||||
: nullptr;
|
||||
|
||||
cancellation_slot proxy_slot(
|
||||
cancel_handler
|
||||
? cancel_handler->slot()
|
||||
: cancellation_slot());
|
||||
|
||||
cancellation_state cancel_state(proxy_slot);
|
||||
|
||||
auto a = (co_spawn_entry_point)(static_cast<awaitable_type*>(nullptr),
|
||||
ex_, std::forward<F>(f), std::forward<Handler>(handler));
|
||||
awaitable_handler<executor_type, void>(std::move(a),
|
||||
ex_, proxy_slot, cancel_state).launch();
|
||||
}
|
||||
|
||||
private:
|
||||
Executor ex_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename Executor, typename T, typename AwaitableExecutor,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(
|
||||
void(std::exception_ptr, T)) CompletionToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
|
||||
CompletionToken, void(std::exception_ptr, T))
|
||||
co_spawn(const Executor& ex,
|
||||
awaitable<T, AwaitableExecutor> a, CompletionToken&& token,
|
||||
typename constraint<
|
||||
(is_executor<Executor>::value || execution::is_executor<Executor>::value)
|
||||
&& is_convertible<Executor, AwaitableExecutor>::value
|
||||
>::type)
|
||||
{
|
||||
return async_initiate<CompletionToken, void(std::exception_ptr, T)>(
|
||||
detail::initiate_co_spawn<AwaitableExecutor>(AwaitableExecutor(ex)),
|
||||
token, detail::awaitable_as_function<T, AwaitableExecutor>(std::move(a)));
|
||||
}
|
||||
|
||||
template <typename Executor, typename AwaitableExecutor,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(
|
||||
void(std::exception_ptr)) CompletionToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
|
||||
CompletionToken, void(std::exception_ptr))
|
||||
co_spawn(const Executor& ex,
|
||||
awaitable<void, AwaitableExecutor> a, CompletionToken&& token,
|
||||
typename constraint<
|
||||
(is_executor<Executor>::value || execution::is_executor<Executor>::value)
|
||||
&& is_convertible<Executor, AwaitableExecutor>::value
|
||||
>::type)
|
||||
{
|
||||
return async_initiate<CompletionToken, void(std::exception_ptr)>(
|
||||
detail::initiate_co_spawn<AwaitableExecutor>(AwaitableExecutor(ex)),
|
||||
token, detail::awaitable_as_function<
|
||||
void, AwaitableExecutor>(std::move(a)));
|
||||
}
|
||||
|
||||
template <typename ExecutionContext, typename T, typename AwaitableExecutor,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(
|
||||
void(std::exception_ptr, T)) CompletionToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
|
||||
CompletionToken, void(std::exception_ptr, T))
|
||||
co_spawn(ExecutionContext& ctx,
|
||||
awaitable<T, AwaitableExecutor> a, CompletionToken&& token,
|
||||
typename constraint<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
&& is_convertible<typename ExecutionContext::executor_type,
|
||||
AwaitableExecutor>::value
|
||||
>::type)
|
||||
{
|
||||
return (co_spawn)(ctx.get_executor(), std::move(a),
|
||||
std::forward<CompletionToken>(token));
|
||||
}
|
||||
|
||||
template <typename ExecutionContext, typename AwaitableExecutor,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(
|
||||
void(std::exception_ptr)) CompletionToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
|
||||
CompletionToken, void(std::exception_ptr))
|
||||
co_spawn(ExecutionContext& ctx,
|
||||
awaitable<void, AwaitableExecutor> a, CompletionToken&& token,
|
||||
typename constraint<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
&& is_convertible<typename ExecutionContext::executor_type,
|
||||
AwaitableExecutor>::value
|
||||
>::type)
|
||||
{
|
||||
return (co_spawn)(ctx.get_executor(), std::move(a),
|
||||
std::forward<CompletionToken>(token));
|
||||
}
|
||||
|
||||
template <typename Executor, typename F,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(typename detail::awaitable_signature<
|
||||
typename result_of<F()>::type>::type) CompletionToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken,
|
||||
typename detail::awaitable_signature<typename result_of<F()>::type>::type)
|
||||
co_spawn(const Executor& ex, F&& f, CompletionToken&& token,
|
||||
typename constraint<
|
||||
is_executor<Executor>::value || execution::is_executor<Executor>::value
|
||||
>::type)
|
||||
{
|
||||
return async_initiate<CompletionToken,
|
||||
typename detail::awaitable_signature<typename result_of<F()>::type>::type>(
|
||||
detail::initiate_co_spawn<
|
||||
typename result_of<F()>::type::executor_type>(ex),
|
||||
token, std::forward<F>(f));
|
||||
}
|
||||
|
||||
template <typename ExecutionContext, typename F,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(typename detail::awaitable_signature<
|
||||
typename result_of<F()>::type>::type) CompletionToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken,
|
||||
typename detail::awaitable_signature<typename result_of<F()>::type>::type)
|
||||
co_spawn(ExecutionContext& ctx, F&& f, CompletionToken&& token,
|
||||
typename constraint<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type)
|
||||
{
|
||||
return (co_spawn)(ctx.get_executor(), std::forward<F>(f),
|
||||
std::forward<CompletionToken>(token));
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_CO_SPAWN_HPP
|
||||
@@ -1,961 +0,0 @@
|
||||
//
|
||||
// impl/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 ACTIV_BOOST_ASIO_IMPL_CONNECT_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_CONNECT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <algorithm>
|
||||
#include <ActivBoost/asio/associator.hpp>
|
||||
#include <ActivBoost/asio/detail/base_from_cancellation_state.hpp>
|
||||
#include <ActivBoost/asio/detail/bind_handler.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_tracking.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <ActivBoost/asio/detail/non_const_lvalue.hpp>
|
||||
#include <ActivBoost/asio/detail/throw_error.hpp>
|
||||
#include <ActivBoost/asio/detail/type_traits.hpp>
|
||||
#include <ActivBoost/asio/error.hpp>
|
||||
#include <ActivBoost/asio/post.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
struct default_connect_condition
|
||||
{
|
||||
template <typename Endpoint>
|
||||
bool operator()(const Boost::system::error_code&, const Endpoint&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Protocol, typename Iterator>
|
||||
inline typename Protocol::endpoint deref_connect_result(
|
||||
Iterator iter, Boost::system::error_code& ec)
|
||||
{
|
||||
return ec ? typename Protocol::endpoint() : *iter;
|
||||
}
|
||||
|
||||
template <typename T, typename Iterator>
|
||||
struct legacy_connect_condition_helper : T
|
||||
{
|
||||
typedef char (*fallback_func_type)(...);
|
||||
operator fallback_func_type() const;
|
||||
};
|
||||
|
||||
template <typename R, typename Arg1, typename Arg2, typename Iterator>
|
||||
struct legacy_connect_condition_helper<R (*)(Arg1, Arg2), Iterator>
|
||||
{
|
||||
R operator()(Arg1, Arg2) const;
|
||||
char operator()(...) const;
|
||||
};
|
||||
|
||||
template <typename T, typename Iterator>
|
||||
struct is_legacy_connect_condition
|
||||
{
|
||||
static char asio_connect_condition_check(char);
|
||||
static char (&asio_connect_condition_check(Iterator))[2];
|
||||
|
||||
static const bool value =
|
||||
sizeof(asio_connect_condition_check(
|
||||
(declval<legacy_connect_condition_helper<T, Iterator> >())(
|
||||
declval<const Boost::system::error_code>(),
|
||||
declval<const Iterator>()))) != 1;
|
||||
};
|
||||
|
||||
template <typename ConnectCondition, typename Iterator>
|
||||
inline Iterator call_connect_condition(ConnectCondition& connect_condition,
|
||||
const Boost::system::error_code& ec, Iterator next, Iterator end,
|
||||
typename enable_if<is_legacy_connect_condition<
|
||||
ConnectCondition, Iterator>::value>::type* = 0)
|
||||
{
|
||||
if (next != end)
|
||||
return connect_condition(ec, next);
|
||||
return end;
|
||||
}
|
||||
|
||||
template <typename ConnectCondition, typename Iterator>
|
||||
inline Iterator call_connect_condition(ConnectCondition& connect_condition,
|
||||
const Boost::system::error_code& ec, Iterator next, Iterator end,
|
||||
typename enable_if<!is_legacy_connect_condition<
|
||||
ConnectCondition, Iterator>::value>::type* = 0)
|
||||
{
|
||||
for (;next != end; ++next)
|
||||
if (connect_condition(ec, *next))
|
||||
return next;
|
||||
return end;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor, typename EndpointSequence>
|
||||
typename Protocol::endpoint connect(basic_socket<Protocol, Executor>& s,
|
||||
const EndpointSequence& endpoints,
|
||||
typename constraint<is_endpoint_sequence<
|
||||
EndpointSequence>::value>::type)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
typename Protocol::endpoint result = connect(s, endpoints, ec);
|
||||
Boost::asio::detail::throw_error(ec, "connect");
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor, typename EndpointSequence>
|
||||
typename Protocol::endpoint connect(basic_socket<Protocol, Executor>& s,
|
||||
const EndpointSequence& endpoints, Boost::system::error_code& ec,
|
||||
typename constraint<is_endpoint_sequence<
|
||||
EndpointSequence>::value>::type)
|
||||
{
|
||||
return detail::deref_connect_result<Protocol>(
|
||||
connect(s, endpoints.begin(), endpoints.end(),
|
||||
detail::default_connect_condition(), ec), ec);
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
template <typename Protocol, typename Executor, typename Iterator>
|
||||
Iterator connect(basic_socket<Protocol, Executor>& s, Iterator begin,
|
||||
typename constraint<!is_endpoint_sequence<Iterator>::value>::type)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
Iterator result = connect(s, begin, ec);
|
||||
Boost::asio::detail::throw_error(ec, "connect");
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor, typename Iterator>
|
||||
inline Iterator connect(basic_socket<Protocol, Executor>& s,
|
||||
Iterator begin, Boost::system::error_code& ec,
|
||||
typename constraint<!is_endpoint_sequence<Iterator>::value>::type)
|
||||
{
|
||||
return connect(s, begin, Iterator(), detail::default_connect_condition(), ec);
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
template <typename Protocol, typename Executor, typename Iterator>
|
||||
Iterator connect(basic_socket<Protocol, Executor>& s,
|
||||
Iterator begin, Iterator end)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
Iterator result = connect(s, begin, end, ec);
|
||||
Boost::asio::detail::throw_error(ec, "connect");
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor, typename Iterator>
|
||||
inline Iterator connect(basic_socket<Protocol, Executor>& s,
|
||||
Iterator begin, Iterator end, Boost::system::error_code& ec)
|
||||
{
|
||||
return connect(s, begin, end, detail::default_connect_condition(), ec);
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor,
|
||||
typename EndpointSequence, typename ConnectCondition>
|
||||
typename Protocol::endpoint connect(basic_socket<Protocol, Executor>& s,
|
||||
const EndpointSequence& endpoints, ConnectCondition connect_condition,
|
||||
typename constraint<is_endpoint_sequence<
|
||||
EndpointSequence>::value>::type)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
typename Protocol::endpoint result = connect(
|
||||
s, endpoints, connect_condition, ec);
|
||||
Boost::asio::detail::throw_error(ec, "connect");
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor,
|
||||
typename EndpointSequence, typename ConnectCondition>
|
||||
typename Protocol::endpoint connect(basic_socket<Protocol, Executor>& s,
|
||||
const EndpointSequence& endpoints, ConnectCondition connect_condition,
|
||||
Boost::system::error_code& ec,
|
||||
typename constraint<is_endpoint_sequence<
|
||||
EndpointSequence>::value>::type)
|
||||
{
|
||||
return detail::deref_connect_result<Protocol>(
|
||||
connect(s, endpoints.begin(), endpoints.end(),
|
||||
connect_condition, ec), ec);
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
template <typename Protocol, typename Executor,
|
||||
typename Iterator, typename ConnectCondition>
|
||||
Iterator connect(basic_socket<Protocol, Executor>& s,
|
||||
Iterator begin, ConnectCondition connect_condition,
|
||||
typename constraint<!is_endpoint_sequence<Iterator>::value>::type)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
Iterator result = connect(s, begin, connect_condition, ec);
|
||||
Boost::asio::detail::throw_error(ec, "connect");
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor,
|
||||
typename Iterator, typename ConnectCondition>
|
||||
inline Iterator connect(basic_socket<Protocol, Executor>& s,
|
||||
Iterator begin, ConnectCondition connect_condition,
|
||||
Boost::system::error_code& ec,
|
||||
typename constraint<!is_endpoint_sequence<Iterator>::value>::type)
|
||||
{
|
||||
return connect(s, begin, Iterator(), connect_condition, ec);
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
template <typename Protocol, typename Executor,
|
||||
typename Iterator, typename ConnectCondition>
|
||||
Iterator connect(basic_socket<Protocol, Executor>& s, Iterator begin,
|
||||
Iterator end, ConnectCondition connect_condition)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
Iterator result = connect(s, begin, end, connect_condition, ec);
|
||||
Boost::asio::detail::throw_error(ec, "connect");
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor,
|
||||
typename Iterator, typename ConnectCondition>
|
||||
Iterator connect(basic_socket<Protocol, Executor>& s, Iterator begin,
|
||||
Iterator end, ConnectCondition connect_condition,
|
||||
Boost::system::error_code& ec)
|
||||
{
|
||||
ec = Boost::system::error_code();
|
||||
|
||||
for (Iterator iter = begin; iter != end; ++iter)
|
||||
{
|
||||
iter = (detail::call_connect_condition(connect_condition, ec, iter, end));
|
||||
if (iter != end)
|
||||
{
|
||||
s.close(ec);
|
||||
s.connect(*iter, ec);
|
||||
if (!ec)
|
||||
return iter;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ec)
|
||||
ec = Boost::asio::error::not_found;
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// Enable the empty base class optimisation for the connect condition.
|
||||
template <typename ConnectCondition>
|
||||
class base_from_connect_condition
|
||||
{
|
||||
protected:
|
||||
explicit base_from_connect_condition(
|
||||
const ConnectCondition& connect_condition)
|
||||
: connect_condition_(connect_condition)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
void check_condition(const Boost::system::error_code& ec,
|
||||
Iterator& iter, Iterator& end)
|
||||
{
|
||||
iter = detail::call_connect_condition(connect_condition_, ec, iter, end);
|
||||
}
|
||||
|
||||
private:
|
||||
ConnectCondition connect_condition_;
|
||||
};
|
||||
|
||||
// The default_connect_condition implementation is essentially a no-op. This
|
||||
// template specialisation lets us eliminate all costs associated with it.
|
||||
template <>
|
||||
class base_from_connect_condition<default_connect_condition>
|
||||
{
|
||||
protected:
|
||||
explicit base_from_connect_condition(const default_connect_condition&)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
void check_condition(const Boost::system::error_code&, Iterator&, Iterator&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Protocol, typename Executor, typename EndpointSequence,
|
||||
typename ConnectCondition, typename RangeConnectHandler>
|
||||
class range_connect_op
|
||||
: public base_from_cancellation_state<RangeConnectHandler>,
|
||||
base_from_connect_condition<ConnectCondition>
|
||||
{
|
||||
public:
|
||||
range_connect_op(basic_socket<Protocol, Executor>& sock,
|
||||
const EndpointSequence& endpoints,
|
||||
const ConnectCondition& connect_condition,
|
||||
RangeConnectHandler& handler)
|
||||
: base_from_cancellation_state<RangeConnectHandler>(
|
||||
handler, enable_partial_cancellation()),
|
||||
base_from_connect_condition<ConnectCondition>(connect_condition),
|
||||
socket_(sock),
|
||||
endpoints_(endpoints),
|
||||
index_(0),
|
||||
start_(0),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(RangeConnectHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
range_connect_op(const range_connect_op& other)
|
||||
: base_from_cancellation_state<RangeConnectHandler>(other),
|
||||
base_from_connect_condition<ConnectCondition>(other),
|
||||
socket_(other.socket_),
|
||||
endpoints_(other.endpoints_),
|
||||
index_(other.index_),
|
||||
start_(other.start_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
range_connect_op(range_connect_op&& other)
|
||||
: base_from_cancellation_state<RangeConnectHandler>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(base_from_cancellation_state<
|
||||
RangeConnectHandler>)(other)),
|
||||
base_from_connect_condition<ConnectCondition>(other),
|
||||
socket_(other.socket_),
|
||||
endpoints_(other.endpoints_),
|
||||
index_(other.index_),
|
||||
start_(other.start_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(RangeConnectHandler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()(Boost::system::error_code ec, int start = 0)
|
||||
{
|
||||
this->process(ec, start,
|
||||
const_cast<const EndpointSequence&>(endpoints_).begin(),
|
||||
const_cast<const EndpointSequence&>(endpoints_).end());
|
||||
}
|
||||
|
||||
//private:
|
||||
template <typename Iterator>
|
||||
void process(Boost::system::error_code ec,
|
||||
int start, Iterator begin, Iterator end)
|
||||
{
|
||||
Iterator iter = begin;
|
||||
std::advance(iter, index_);
|
||||
|
||||
switch (start_ = start)
|
||||
{
|
||||
case 1:
|
||||
for (;;)
|
||||
{
|
||||
this->check_condition(ec, iter, end);
|
||||
index_ = std::distance(begin, iter);
|
||||
|
||||
if (iter != end)
|
||||
{
|
||||
socket_.close(ec);
|
||||
ACTIV_BOOST_ASIO_HANDLER_LOCATION((__FILE__, __LINE__, "async_connect"));
|
||||
socket_.async_connect(*iter,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(range_connect_op)(*this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (start)
|
||||
{
|
||||
ec = Boost::asio::error::not_found;
|
||||
ACTIV_BOOST_ASIO_HANDLER_LOCATION((__FILE__, __LINE__, "async_connect"));
|
||||
Boost::asio::post(socket_.get_executor(),
|
||||
detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(range_connect_op)(*this), ec));
|
||||
return;
|
||||
}
|
||||
|
||||
/* fall-through */ default:
|
||||
|
||||
if (iter == end)
|
||||
break;
|
||||
|
||||
if (!socket_.is_open())
|
||||
{
|
||||
ec = Boost::asio::error::operation_aborted;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ec)
|
||||
break;
|
||||
|
||||
if (this->cancelled() != cancellation_type::none)
|
||||
{
|
||||
ec = Boost::asio::error::operation_aborted;
|
||||
break;
|
||||
}
|
||||
|
||||
++iter;
|
||||
++index_;
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(RangeConnectHandler)(handler_)(
|
||||
static_cast<const Boost::system::error_code&>(ec),
|
||||
static_cast<const typename Protocol::endpoint&>(
|
||||
ec || iter == end ? typename Protocol::endpoint() : *iter));
|
||||
}
|
||||
}
|
||||
|
||||
basic_socket<Protocol, Executor>& socket_;
|
||||
EndpointSequence endpoints_;
|
||||
std::size_t index_;
|
||||
int start_;
|
||||
RangeConnectHandler handler_;
|
||||
};
|
||||
|
||||
template <typename Protocol, typename Executor, typename EndpointSequence,
|
||||
typename ConnectCondition, typename RangeConnectHandler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
range_connect_op<Protocol, Executor, EndpointSequence,
|
||||
ConnectCondition, RangeConnectHandler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor, typename EndpointSequence,
|
||||
typename ConnectCondition, typename RangeConnectHandler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
range_connect_op<Protocol, Executor, EndpointSequence,
|
||||
ConnectCondition, RangeConnectHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor, typename EndpointSequence,
|
||||
typename ConnectCondition, typename RangeConnectHandler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
range_connect_op<Protocol, Executor, EndpointSequence,
|
||||
ConnectCondition, RangeConnectHandler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Executor, typename Protocol,
|
||||
typename EndpointSequence, typename ConnectCondition,
|
||||
typename RangeConnectHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
range_connect_op<Protocol, Executor, EndpointSequence,
|
||||
ConnectCondition, RangeConnectHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename Executor, typename Protocol,
|
||||
typename EndpointSequence, typename ConnectCondition,
|
||||
typename RangeConnectHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
range_connect_op<Protocol, Executor, EndpointSequence,
|
||||
ConnectCondition, RangeConnectHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor>
|
||||
class initiate_async_range_connect
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_range_connect(basic_socket<Protocol, Executor>& s)
|
||||
: socket_(s)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return socket_.get_executor();
|
||||
}
|
||||
|
||||
template <typename RangeConnectHandler,
|
||||
typename EndpointSequence, typename ConnectCondition>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(RangeConnectHandler) handler,
|
||||
const EndpointSequence& endpoints,
|
||||
const ConnectCondition& connect_condition) const
|
||||
{
|
||||
// If you get an error on the following line it means that your
|
||||
// handler does not meet the documented type requirements for an
|
||||
// RangeConnectHandler.
|
||||
ACTIV_BOOST_ASIO_RANGE_CONNECT_HANDLER_CHECK(RangeConnectHandler,
|
||||
handler, typename Protocol::endpoint) type_check;
|
||||
|
||||
non_const_lvalue<RangeConnectHandler> handler2(handler);
|
||||
range_connect_op<Protocol, Executor, EndpointSequence, ConnectCondition,
|
||||
typename decay<RangeConnectHandler>::type>(socket_, endpoints,
|
||||
connect_condition, handler2.value)(Boost::system::error_code(), 1);
|
||||
}
|
||||
|
||||
private:
|
||||
basic_socket<Protocol, Executor>& socket_;
|
||||
};
|
||||
|
||||
template <typename Protocol, typename Executor, typename Iterator,
|
||||
typename ConnectCondition, typename IteratorConnectHandler>
|
||||
class iterator_connect_op
|
||||
: public base_from_cancellation_state<IteratorConnectHandler>,
|
||||
base_from_connect_condition<ConnectCondition>
|
||||
{
|
||||
public:
|
||||
iterator_connect_op(basic_socket<Protocol, Executor>& sock,
|
||||
const Iterator& begin, const Iterator& end,
|
||||
const ConnectCondition& connect_condition,
|
||||
IteratorConnectHandler& handler)
|
||||
: base_from_cancellation_state<IteratorConnectHandler>(
|
||||
handler, enable_partial_cancellation()),
|
||||
base_from_connect_condition<ConnectCondition>(connect_condition),
|
||||
socket_(sock),
|
||||
iter_(begin),
|
||||
end_(end),
|
||||
start_(0),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(IteratorConnectHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
iterator_connect_op(const iterator_connect_op& other)
|
||||
: base_from_cancellation_state<IteratorConnectHandler>(other),
|
||||
base_from_connect_condition<ConnectCondition>(other),
|
||||
socket_(other.socket_),
|
||||
iter_(other.iter_),
|
||||
end_(other.end_),
|
||||
start_(other.start_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
iterator_connect_op(iterator_connect_op&& other)
|
||||
: base_from_cancellation_state<IteratorConnectHandler>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(base_from_cancellation_state<
|
||||
IteratorConnectHandler>)(other)),
|
||||
base_from_connect_condition<ConnectCondition>(other),
|
||||
socket_(other.socket_),
|
||||
iter_(other.iter_),
|
||||
end_(other.end_),
|
||||
start_(other.start_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(IteratorConnectHandler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()(Boost::system::error_code ec, int start = 0)
|
||||
{
|
||||
switch (start_ = start)
|
||||
{
|
||||
case 1:
|
||||
for (;;)
|
||||
{
|
||||
this->check_condition(ec, iter_, end_);
|
||||
|
||||
if (iter_ != end_)
|
||||
{
|
||||
socket_.close(ec);
|
||||
ACTIV_BOOST_ASIO_HANDLER_LOCATION((__FILE__, __LINE__, "async_connect"));
|
||||
socket_.async_connect(*iter_,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(iterator_connect_op)(*this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (start)
|
||||
{
|
||||
ec = Boost::asio::error::not_found;
|
||||
ACTIV_BOOST_ASIO_HANDLER_LOCATION((__FILE__, __LINE__, "async_connect"));
|
||||
Boost::asio::post(socket_.get_executor(),
|
||||
detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(iterator_connect_op)(*this), ec));
|
||||
return;
|
||||
}
|
||||
|
||||
/* fall-through */ default:
|
||||
|
||||
if (iter_ == end_)
|
||||
break;
|
||||
|
||||
if (!socket_.is_open())
|
||||
{
|
||||
ec = Boost::asio::error::operation_aborted;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ec)
|
||||
break;
|
||||
|
||||
if (this->cancelled() != cancellation_type::none)
|
||||
{
|
||||
ec = Boost::asio::error::operation_aborted;
|
||||
break;
|
||||
}
|
||||
|
||||
++iter_;
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(IteratorConnectHandler)(handler_)(
|
||||
static_cast<const Boost::system::error_code&>(ec),
|
||||
static_cast<const Iterator&>(iter_));
|
||||
}
|
||||
}
|
||||
|
||||
//private:
|
||||
basic_socket<Protocol, Executor>& socket_;
|
||||
Iterator iter_;
|
||||
Iterator end_;
|
||||
int start_;
|
||||
IteratorConnectHandler handler_;
|
||||
};
|
||||
|
||||
template <typename Protocol, typename Executor, typename Iterator,
|
||||
typename ConnectCondition, typename IteratorConnectHandler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
iterator_connect_op<Protocol, Executor, Iterator,
|
||||
ConnectCondition, IteratorConnectHandler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor, typename Iterator,
|
||||
typename ConnectCondition, typename IteratorConnectHandler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
iterator_connect_op<Protocol, Executor, Iterator,
|
||||
ConnectCondition, IteratorConnectHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor, typename Iterator,
|
||||
typename ConnectCondition, typename IteratorConnectHandler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
iterator_connect_op<Protocol, Executor, Iterator,
|
||||
ConnectCondition, IteratorConnectHandler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Executor, typename Protocol,
|
||||
typename Iterator, typename ConnectCondition,
|
||||
typename IteratorConnectHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
iterator_connect_op<Protocol, Executor, Iterator,
|
||||
ConnectCondition, IteratorConnectHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename Executor, typename Protocol,
|
||||
typename Iterator, typename ConnectCondition,
|
||||
typename IteratorConnectHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
iterator_connect_op<Protocol, Executor, Iterator,
|
||||
ConnectCondition, IteratorConnectHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor>
|
||||
class initiate_async_iterator_connect
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_iterator_connect(
|
||||
basic_socket<Protocol, Executor>& s)
|
||||
: socket_(s)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return socket_.get_executor();
|
||||
}
|
||||
|
||||
template <typename IteratorConnectHandler,
|
||||
typename Iterator, typename ConnectCondition>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(IteratorConnectHandler) handler,
|
||||
Iterator begin, Iterator end,
|
||||
const ConnectCondition& connect_condition) const
|
||||
{
|
||||
// If you get an error on the following line it means that your
|
||||
// handler does not meet the documented type requirements for an
|
||||
// IteratorConnectHandler.
|
||||
ACTIV_BOOST_ASIO_ITERATOR_CONNECT_HANDLER_CHECK(
|
||||
IteratorConnectHandler, handler, Iterator) type_check;
|
||||
|
||||
non_const_lvalue<IteratorConnectHandler> handler2(handler);
|
||||
iterator_connect_op<Protocol, Executor, Iterator, ConnectCondition,
|
||||
typename decay<IteratorConnectHandler>::type>(socket_, begin, end,
|
||||
connect_condition, handler2.value)(Boost::system::error_code(), 1);
|
||||
}
|
||||
|
||||
private:
|
||||
basic_socket<Protocol, Executor>& socket_;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename Protocol, typename Executor, typename EndpointSequence,
|
||||
typename ConnectCondition, typename RangeConnectHandler,
|
||||
typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::range_connect_op<Protocol, Executor,
|
||||
EndpointSequence, ConnectCondition, RangeConnectHandler>,
|
||||
DefaultCandidate>
|
||||
: Associator<RangeConnectHandler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<RangeConnectHandler, DefaultCandidate>::type
|
||||
get(const detail::range_connect_op<Protocol, Executor, EndpointSequence,
|
||||
ConnectCondition, RangeConnectHandler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<RangeConnectHandler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<RangeConnectHandler, DefaultCandidate>::type)
|
||||
get(const detail::range_connect_op<Protocol, Executor,
|
||||
EndpointSequence, ConnectCondition, RangeConnectHandler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<RangeConnectHandler, DefaultCandidate>::get(
|
||||
h.handler_, c)))
|
||||
{
|
||||
return Associator<RangeConnectHandler, DefaultCandidate>::get(
|
||||
h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename Protocol, typename Executor, typename Iterator,
|
||||
typename ConnectCondition, typename IteratorConnectHandler,
|
||||
typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::iterator_connect_op<Protocol, Executor,
|
||||
Iterator, ConnectCondition, IteratorConnectHandler>,
|
||||
DefaultCandidate>
|
||||
: Associator<IteratorConnectHandler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<IteratorConnectHandler, DefaultCandidate>::type
|
||||
get(const detail::iterator_connect_op<Protocol, Executor, Iterator,
|
||||
ConnectCondition, IteratorConnectHandler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<IteratorConnectHandler, DefaultCandidate>::get(
|
||||
h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<IteratorConnectHandler, DefaultCandidate>::type)
|
||||
get(const detail::iterator_connect_op<Protocol, Executor,
|
||||
Iterator, ConnectCondition, IteratorConnectHandler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<IteratorConnectHandler, DefaultCandidate>::get(
|
||||
h.handler_, c)))
|
||||
{
|
||||
return Associator<IteratorConnectHandler, DefaultCandidate>::get(
|
||||
h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename Protocol, typename Executor, typename EndpointSequence,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
typename Protocol::endpoint)) RangeConnectToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(RangeConnectToken,
|
||||
void (Boost::system::error_code, typename Protocol::endpoint))
|
||||
async_connect(basic_socket<Protocol, Executor>& s,
|
||||
const EndpointSequence& endpoints,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RangeConnectToken) token,
|
||||
typename constraint<is_endpoint_sequence<
|
||||
EndpointSequence>::value>::type)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<RangeConnectToken,
|
||||
void (Boost::system::error_code, typename Protocol::endpoint)>(
|
||||
declval<detail::initiate_async_range_connect<Protocol, Executor> >(),
|
||||
token, endpoints, declval<detail::default_connect_condition>())))
|
||||
{
|
||||
return async_initiate<RangeConnectToken,
|
||||
void (Boost::system::error_code, typename Protocol::endpoint)>(
|
||||
detail::initiate_async_range_connect<Protocol, Executor>(s),
|
||||
token, endpoints, detail::default_connect_condition());
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
template <typename Protocol, typename Executor, typename Iterator,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
Iterator)) IteratorConnectToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator))
|
||||
async_connect(basic_socket<Protocol, Executor>& s, Iterator begin,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(IteratorConnectToken) token,
|
||||
typename constraint<!is_endpoint_sequence<Iterator>::value>::type)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator)>(
|
||||
declval<detail::initiate_async_iterator_connect<Protocol, Executor> >(),
|
||||
token, begin, Iterator(),
|
||||
declval<detail::default_connect_condition>())))
|
||||
{
|
||||
return async_initiate<IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator)>(
|
||||
detail::initiate_async_iterator_connect<Protocol, Executor>(s),
|
||||
token, begin, Iterator(),
|
||||
detail::default_connect_condition());
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
template <typename Protocol, typename Executor, typename Iterator,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
Iterator)) IteratorConnectToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator))
|
||||
async_connect(basic_socket<Protocol, Executor>& s, Iterator begin, Iterator end,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(IteratorConnectToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator)>(
|
||||
declval<detail::initiate_async_iterator_connect<Protocol, Executor> >(),
|
||||
token, begin, end, declval<detail::default_connect_condition>())))
|
||||
{
|
||||
return async_initiate<IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator)>(
|
||||
detail::initiate_async_iterator_connect<Protocol, Executor>(s),
|
||||
token, begin, end, detail::default_connect_condition());
|
||||
}
|
||||
|
||||
template <typename Protocol, typename Executor,
|
||||
typename EndpointSequence, typename ConnectCondition,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
typename Protocol::endpoint)) RangeConnectToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(RangeConnectToken,
|
||||
void (Boost::system::error_code, typename Protocol::endpoint))
|
||||
async_connect(basic_socket<Protocol, Executor>& s,
|
||||
const EndpointSequence& endpoints, ConnectCondition connect_condition,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RangeConnectToken) token,
|
||||
typename constraint<is_endpoint_sequence<
|
||||
EndpointSequence>::value>::type)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<RangeConnectToken,
|
||||
void (Boost::system::error_code, typename Protocol::endpoint)>(
|
||||
declval<detail::initiate_async_range_connect<Protocol, Executor> >(),
|
||||
token, endpoints, connect_condition)))
|
||||
{
|
||||
return async_initiate<RangeConnectToken,
|
||||
void (Boost::system::error_code, typename Protocol::endpoint)>(
|
||||
detail::initiate_async_range_connect<Protocol, Executor>(s),
|
||||
token, endpoints, connect_condition);
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
template <typename Protocol, typename Executor,
|
||||
typename Iterator, typename ConnectCondition,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
Iterator)) IteratorConnectToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator))
|
||||
async_connect(basic_socket<Protocol, Executor>& s, Iterator begin,
|
||||
ConnectCondition connect_condition,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(IteratorConnectToken) token,
|
||||
typename constraint<!is_endpoint_sequence<Iterator>::value>::type)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator)>(
|
||||
declval<detail::initiate_async_iterator_connect<Protocol, Executor> >(),
|
||||
token, begin, Iterator(), connect_condition)))
|
||||
{
|
||||
return async_initiate<IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator)>(
|
||||
detail::initiate_async_iterator_connect<Protocol, Executor>(s),
|
||||
token, begin, Iterator(), connect_condition);
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
template <typename Protocol, typename Executor,
|
||||
typename Iterator, typename ConnectCondition,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
Iterator)) IteratorConnectToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator))
|
||||
async_connect(basic_socket<Protocol, Executor>& s, Iterator begin,
|
||||
Iterator end, ConnectCondition connect_condition,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(IteratorConnectToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator)>(
|
||||
declval<detail::initiate_async_iterator_connect<Protocol, Executor> >(),
|
||||
token, begin, end, connect_condition)))
|
||||
{
|
||||
return async_initiate<IteratorConnectToken,
|
||||
void (Boost::system::error_code, Iterator)>(
|
||||
detail::initiate_async_iterator_connect<Protocol, Executor>(s),
|
||||
token, begin, end, connect_condition);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_CONNECT_HPP
|
||||
@@ -1,75 +0,0 @@
|
||||
//
|
||||
// impl/connect_pipe.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 ACTIV_BOOST_ASIO_IMPL_CONNECT_PIPE_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_CONNECT_PIPE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_PIPE)
|
||||
|
||||
#include <ActivBoost/asio/connect_pipe.hpp>
|
||||
#include <ActivBoost/asio/detail/throw_error.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
template <typename Executor1, typename Executor2>
|
||||
void connect_pipe(basic_readable_pipe<Executor1>& read_end,
|
||||
basic_writable_pipe<Executor2>& write_end)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
Boost::asio::connect_pipe(read_end, write_end, ec);
|
||||
Boost::asio::detail::throw_error(ec, "connect_pipe");
|
||||
}
|
||||
|
||||
template <typename Executor1, typename Executor2>
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID connect_pipe(basic_readable_pipe<Executor1>& read_end,
|
||||
basic_writable_pipe<Executor2>& write_end, Boost::system::error_code& ec)
|
||||
{
|
||||
detail::native_pipe_handle p[2];
|
||||
detail::create_pipe(p, ec);
|
||||
if (ec)
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
|
||||
read_end.assign(p[0], ec);
|
||||
if (ec)
|
||||
{
|
||||
detail::close_pipe(p[0]);
|
||||
detail::close_pipe(p[1]);
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
write_end.assign(p[1], ec);
|
||||
if (ec)
|
||||
{
|
||||
Boost::system::error_code temp_ec;
|
||||
read_end.close(temp_ec);
|
||||
detail::close_pipe(p[1]);
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_PIPE)
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_CONNECT_PIPE_HPP
|
||||
@@ -1,151 +0,0 @@
|
||||
//
|
||||
// impl/connect_pipe.ipp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2021 Klemens D. Morgenstern
|
||||
// (klemens dot morgenstern at gmx dot net)
|
||||
//
|
||||
// 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 ACTIV_BOOST_ASIO_IMPL_CONNECT_PIPE_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_CONNECT_PIPE_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_PIPE)
|
||||
|
||||
#include <ActivBoost/asio/connect_pipe.hpp>
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_IOCP)
|
||||
# include <cstdio>
|
||||
# if _WIN32_WINNT >= 0x601
|
||||
# include <bcrypt.h>
|
||||
# if !defined(ACTIV_BOOST_ASIO_NO_DEFAULT_LINKED_LIBS)
|
||||
# if defined(_MSC_VER)
|
||||
# pragma comment(lib, "bcrypt.lib")
|
||||
# endif // defined(_MSC_VER)
|
||||
# endif // !defined(ACTIV_BOOST_ASIO_NO_DEFAULT_LINKED_LIBS)
|
||||
# endif // _WIN32_WINNT >= 0x601
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_IOCP)
|
||||
# include <ActivBoost/asio/detail/descriptor_ops.hpp>
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_IOCP)
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
void create_pipe(native_pipe_handle p[2], Boost::system::error_code& ec)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_IOCP)
|
||||
using namespace std; // For sprintf and memcmp.
|
||||
|
||||
static long counter1 = 0;
|
||||
static long counter2 = 0;
|
||||
|
||||
long n1 = ::InterlockedIncrement(&counter1);
|
||||
long n2 = (static_cast<unsigned long>(n1) % 0x10000000) == 0
|
||||
? ::InterlockedIncrement(&counter2)
|
||||
: ::InterlockedExchangeAdd(&counter2, 0);
|
||||
|
||||
wchar_t pipe_name[128];
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_SECURE_RTL)
|
||||
swprintf_s(
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_SECURE_RTL)
|
||||
_snwprintf(
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_SECURE_RTL)
|
||||
pipe_name, 128,
|
||||
L"\\\\.\\pipe\\asio-A0812896-741A-484D-AF23-BE51BF620E22-%u-%ld-%ld",
|
||||
static_cast<unsigned int>(::GetCurrentProcessId()), n1, n2);
|
||||
|
||||
p[0] = ::CreateNamedPipeW(pipe_name,
|
||||
PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
|
||||
0, 1, 8192, 8192, 0, 0);
|
||||
|
||||
if (p[0] == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
ec.assign(last_error, Boost::asio::error::get_system_category());
|
||||
return;
|
||||
}
|
||||
|
||||
p[1] = ::CreateFileW(pipe_name, GENERIC_WRITE, 0,
|
||||
0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
|
||||
|
||||
if (p[1] == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
::CloseHandle(p[0]);
|
||||
ec.assign(last_error, Boost::asio::error::get_system_category());
|
||||
return;
|
||||
}
|
||||
|
||||
# if _WIN32_WINNT >= 0x601
|
||||
unsigned char nonce[16];
|
||||
if (::BCryptGenRandom(0, nonce, sizeof(nonce),
|
||||
BCRYPT_USE_SYSTEM_PREFERRED_RNG) != 0)
|
||||
{
|
||||
ec = Boost::asio::error::connection_aborted;
|
||||
::CloseHandle(p[0]);
|
||||
::CloseHandle(p[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD bytes_written = 0;
|
||||
BOOL ok = ::WriteFile(p[1], nonce, sizeof(nonce), &bytes_written, 0);
|
||||
if (!ok || bytes_written != sizeof(nonce))
|
||||
{
|
||||
ec = Boost::asio::error::connection_aborted;
|
||||
::CloseHandle(p[0]);
|
||||
::CloseHandle(p[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char nonce_check[sizeof(nonce)];
|
||||
DWORD bytes_read = 0;
|
||||
ok = ::ReadFile(p[0], nonce_check, sizeof(nonce), &bytes_read, 0);
|
||||
if (!ok || bytes_read != sizeof(nonce)
|
||||
|| memcmp(nonce, nonce_check, sizeof(nonce)) != 0)
|
||||
{
|
||||
ec = Boost::asio::error::connection_aborted;
|
||||
::CloseHandle(p[0]);
|
||||
::CloseHandle(p[1]);
|
||||
return;
|
||||
}
|
||||
#endif // _WIN32_WINNT >= 0x601
|
||||
|
||||
Boost::asio::error::clear(ec);
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_IOCP)
|
||||
int result = ::pipe(p);
|
||||
detail::descriptor_ops::get_last_error(ec, result != 0);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_IOCP)
|
||||
}
|
||||
|
||||
void close_pipe(native_pipe_handle p)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_IOCP)
|
||||
::CloseHandle(p);
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_IOCP)
|
||||
Boost::system::error_code ignored_ec;
|
||||
detail::descriptor_ops::state_type state = 0;
|
||||
detail::descriptor_ops::close(p, state, ignored_ec);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_IOCP)
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_PIPE)
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_CONNECT_PIPE_IPP
|
||||
@@ -1,204 +0,0 @@
|
||||
//
|
||||
// impl/consign.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 ACTIV_BOOST_ASIO_IMPL_CONSIGN_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_CONSIGN_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#include <ActivBoost/asio/associator.hpp>
|
||||
#include <ActivBoost/asio/async_result.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/type_traits.hpp>
|
||||
#include <ActivBoost/asio/detail/utility.hpp>
|
||||
#include <ActivBoost/asio/detail/variadic_templates.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Class to adapt a consign_t as a completion handler.
|
||||
template <typename Handler, typename... Values>
|
||||
class consign_handler
|
||||
{
|
||||
public:
|
||||
typedef void result_type;
|
||||
|
||||
template <typename H>
|
||||
consign_handler(ACTIV_BOOST_ASIO_MOVE_ARG(H) handler, std::tuple<Values...> values)
|
||||
: handler_(ACTIV_BOOST_ASIO_MOVE_CAST(H)(handler)),
|
||||
values_(ACTIV_BOOST_ASIO_MOVE_CAST(std::tuple<Values...>)(values))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
std::tuple<Values...> values_;
|
||||
};
|
||||
|
||||
template <typename Handler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
consign_handler<Handler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
consign_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
consign_handler<Handler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
consign_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
consign_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename CompletionToken, typename... Values, typename... Signatures>
|
||||
struct async_result<
|
||||
consign_t<CompletionToken, Values...>, Signatures...>
|
||||
: async_result<CompletionToken, Signatures...>
|
||||
{
|
||||
template <typename Initiation>
|
||||
struct init_wrapper
|
||||
{
|
||||
init_wrapper(Initiation init)
|
||||
: initiation_(ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(init))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Handler, typename... Args>
|
||||
void operator()(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
std::tuple<Values...> values,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation_)(
|
||||
detail::consign_handler<
|
||||
typename decay<Handler>::type, Values...>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Handler)(handler),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(std::tuple<Values...>)(values)),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
Initiation initiation_;
|
||||
};
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static ACTIV_BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(CompletionToken, Signatures...,
|
||||
(async_initiate<CompletionToken, Signatures...>(
|
||||
declval<init_wrapper<typename decay<Initiation>::type> >(),
|
||||
declval<CompletionToken&>(),
|
||||
declval<std::tuple<Values...> >(),
|
||||
declval<ACTIV_BOOST_ASIO_MOVE_ARG(Args)>()...)))
|
||||
initiate(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RawCompletionToken) token,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
return async_initiate<CompletionToken, Signatures...>(
|
||||
init_wrapper<typename decay<Initiation>::type>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation)),
|
||||
token.token_,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(std::tuple<Values...>)(token.values_),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename Handler, typename... Values, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::consign_handler<Handler, Values...>, DefaultCandidate>
|
||||
: Associator<Handler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<Handler, DefaultCandidate>::type
|
||||
get(const detail::consign_handler<Handler, Values...>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<Handler, DefaultCandidate>::type)
|
||||
get(const detail::consign_handler<Handler, Values...>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<Handler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_CONSIGN_HPP
|
||||
@@ -1,300 +0,0 @@
|
||||
//
|
||||
// impl/defer.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 ACTIV_BOOST_ASIO_IMPL_DEFER_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_DEFER_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/associated_allocator.hpp>
|
||||
#include <ActivBoost/asio/associated_executor.hpp>
|
||||
#include <ActivBoost/asio/detail/work_dispatcher.hpp>
|
||||
#include <ActivBoost/asio/execution/allocator.hpp>
|
||||
#include <ActivBoost/asio/execution/blocking.hpp>
|
||||
#include <ActivBoost/asio/execution/relationship.hpp>
|
||||
#include <ActivBoost/asio/prefer.hpp>
|
||||
#include <ActivBoost/asio/require.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class initiate_defer
|
||||
{
|
||||
public:
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
execution::is_executor<
|
||||
typename associated_executor<
|
||||
typename decay<CompletionHandler>::type
|
||||
>::type
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_executor<handler_t>::type ex(
|
||||
(get_associated_executor)(handler));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex, execution::blocking.never),
|
||||
execution::relationship.continuation,
|
||||
execution::allocator(alloc)
|
||||
).execute(
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
execution::execute(
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex, execution::blocking.never),
|
||||
execution::relationship.continuation,
|
||||
execution::allocator(alloc)),
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
!execution::is_executor<
|
||||
typename associated_executor<
|
||||
typename decay<CompletionHandler>::type
|
||||
>::type
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_executor<handler_t>::type ex(
|
||||
(get_associated_executor)(handler));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
ex.defer(Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)), alloc);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor>
|
||||
class initiate_defer_with_executor
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_defer_with_executor(const Executor& ex)
|
||||
: ex_(ex)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return ex_;
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
!detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex_, execution::blocking.never),
|
||||
execution::relationship.continuation,
|
||||
execution::allocator(alloc)
|
||||
).execute(
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
execution::execute(
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex_, execution::blocking.never),
|
||||
execution::relationship.continuation,
|
||||
execution::allocator(alloc)),
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typedef typename associated_executor<
|
||||
handler_t, Executor>::type handler_ex_t;
|
||||
handler_ex_t handler_ex((get_associated_executor)(handler, ex_));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex_, execution::blocking.never),
|
||||
execution::relationship.continuation,
|
||||
execution::allocator(alloc)
|
||||
).execute(
|
||||
detail::work_dispatcher<handler_t, handler_ex_t>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), handler_ex));
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
execution::execute(
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex_, execution::blocking.never),
|
||||
execution::relationship.continuation,
|
||||
execution::allocator(alloc)),
|
||||
detail::work_dispatcher<handler_t, handler_ex_t>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), handler_ex));
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
!execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
!detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
ex_.defer(Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)), alloc);
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
!execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typedef typename associated_executor<
|
||||
handler_t, Executor>::type handler_ex_t;
|
||||
handler_ex_t handler_ex((get_associated_executor)(handler, ex_));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
ex_.defer(detail::work_dispatcher<handler_t, handler_ex_t>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler),
|
||||
handler_ex), alloc);
|
||||
}
|
||||
|
||||
private:
|
||||
Executor ex_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(NullaryToken, void()) defer(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(NullaryToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<NullaryToken, void()>(
|
||||
declval<detail::initiate_defer>(), token)))
|
||||
{
|
||||
return async_initiate<NullaryToken, void()>(
|
||||
detail::initiate_defer(), token);
|
||||
}
|
||||
|
||||
template <typename Executor,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(NullaryToken, void()) defer(
|
||||
const Executor& ex, ACTIV_BOOST_ASIO_MOVE_ARG(NullaryToken) token,
|
||||
typename constraint<
|
||||
(execution::is_executor<Executor>::value
|
||||
&& can_require<Executor, execution::blocking_t::never_t>::value)
|
||||
|| is_executor<Executor>::value
|
||||
>::type)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<NullaryToken, void()>(
|
||||
declval<detail::initiate_defer_with_executor<Executor> >(), token)))
|
||||
{
|
||||
return async_initiate<NullaryToken, void()>(
|
||||
detail::initiate_defer_with_executor<Executor>(ex), token);
|
||||
}
|
||||
|
||||
template <typename ExecutionContext,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(NullaryToken, void()) defer(
|
||||
ExecutionContext& ctx, ACTIV_BOOST_ASIO_MOVE_ARG(NullaryToken) token,
|
||||
typename constraint<is_convertible<
|
||||
ExecutionContext&, execution_context&>::value>::type)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<NullaryToken, void()>(
|
||||
declval<detail::initiate_defer_with_executor<
|
||||
typename ExecutionContext::executor_type> >(), token)))
|
||||
{
|
||||
return async_initiate<NullaryToken, void()>(
|
||||
detail::initiate_defer_with_executor<
|
||||
typename ExecutionContext::executor_type>(
|
||||
ctx.get_executor()), token);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_DEFER_HPP
|
||||
@@ -1,107 +0,0 @@
|
||||
//
|
||||
// impl/deferred.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 ACTIV_BOOST_ASIO_IMPL_DEFERRED_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_DEFERRED_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename Signature>
|
||||
class async_result<deferred_t, Signature>
|
||||
{
|
||||
public:
|
||||
template <typename Initiation, typename... InitArgs>
|
||||
static deferred_async_operation<Signature, Initiation, InitArgs...>
|
||||
initiate(ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
deferred_t, ACTIV_BOOST_ASIO_MOVE_ARG(InitArgs)... args)
|
||||
{
|
||||
return deferred_async_operation<
|
||||
Signature, Initiation, InitArgs...>(
|
||||
deferred_init_tag{},
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(InitArgs)(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Function, typename R, typename... Args>
|
||||
class async_result<deferred_function<Function>, R(Args...)>
|
||||
{
|
||||
public:
|
||||
template <typename Initiation, typename... InitArgs>
|
||||
static auto initiate(ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
deferred_function<Function> token,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(InitArgs)... init_args)
|
||||
-> decltype(
|
||||
deferred_sequence<
|
||||
deferred_async_operation<
|
||||
R(Args...), Initiation, InitArgs...>,
|
||||
Function>(deferred_init_tag{},
|
||||
deferred_async_operation<
|
||||
R(Args...), Initiation, InitArgs...>(
|
||||
deferred_init_tag{},
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(InitArgs)(init_args)...),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Function)(token.function_)))
|
||||
{
|
||||
return deferred_sequence<
|
||||
deferred_async_operation<
|
||||
R(Args...), Initiation, InitArgs...>,
|
||||
Function>(deferred_init_tag{},
|
||||
deferred_async_operation<
|
||||
R(Args...), Initiation, InitArgs...>(
|
||||
deferred_init_tag{},
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(InitArgs)(init_args)...),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Function)(token.function_));
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename Handler, typename Tail, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::deferred_sequence_handler<Handler, Tail>,
|
||||
DefaultCandidate>
|
||||
: Associator<Handler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<Handler, DefaultCandidate>::type
|
||||
get(const detail::deferred_sequence_handler<Handler, Tail>& h)
|
||||
ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<Handler, DefaultCandidate>::type)
|
||||
get(const detail::deferred_sequence_handler<Handler, Tail>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<Handler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_DEFERRED_HPP
|
||||
@@ -1,132 +0,0 @@
|
||||
//
|
||||
// impl/detached.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 ACTIV_BOOST_ASIO_IMPL_DETACHED_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_DETACHED_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/async_result.hpp>
|
||||
#include <ActivBoost/asio/detail/variadic_templates.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Class to adapt a detached_t as a completion handler.
|
||||
class detached_handler
|
||||
{
|
||||
public:
|
||||
typedef void result_type;
|
||||
|
||||
detached_handler(detached_t)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(Args...)
|
||||
{
|
||||
}
|
||||
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
void operator()()
|
||||
{
|
||||
}
|
||||
|
||||
#define ACTIV_BOOST_ASIO_PRIVATE_DETACHED_DEF(n) \
|
||||
template <ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
void operator()(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) \
|
||||
{ \
|
||||
} \
|
||||
/**/
|
||||
ACTIV_BOOST_ASIO_VARIADIC_GENERATE(ACTIV_BOOST_ASIO_PRIVATE_DETACHED_DEF)
|
||||
#undef ACTIV_BOOST_ASIO_PRIVATE_DETACHED_DEF
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename Signature>
|
||||
struct async_result<detached_t, Signature>
|
||||
{
|
||||
typedef Boost::asio::detail::detached_handler completion_handler_type;
|
||||
|
||||
typedef void return_type;
|
||||
|
||||
explicit async_result(completion_handler_type&)
|
||||
{
|
||||
}
|
||||
|
||||
void get()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static return_type initiate(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RawCompletionToken),
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation)(
|
||||
detail::detached_handler(detached_t()),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken>
|
||||
static return_type initiate(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RawCompletionToken))
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation)(
|
||||
detail::detached_handler(detached_t()));
|
||||
}
|
||||
|
||||
#define ACTIV_BOOST_ASIO_PRIVATE_INITIATE_DEF(n) \
|
||||
template <typename Initiation, typename RawCompletionToken, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
static return_type initiate( \
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation, \
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RawCompletionToken), \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
|
||||
{ \
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( \
|
||||
detail::detached_handler(detached_t()), \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
|
||||
} \
|
||||
/**/
|
||||
ACTIV_BOOST_ASIO_VARIADIC_GENERATE(ACTIV_BOOST_ASIO_PRIVATE_INITIATE_DEF)
|
||||
#undef ACTIV_BOOST_ASIO_PRIVATE_INITIATE_DEF
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_DETACHED_HPP
|
||||
@@ -1,275 +0,0 @@
|
||||
//
|
||||
// impl/dispatch.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 ACTIV_BOOST_ASIO_IMPL_DISPATCH_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_DISPATCH_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/associated_allocator.hpp>
|
||||
#include <ActivBoost/asio/associated_executor.hpp>
|
||||
#include <ActivBoost/asio/detail/work_dispatcher.hpp>
|
||||
#include <ActivBoost/asio/execution/allocator.hpp>
|
||||
#include <ActivBoost/asio/execution/blocking.hpp>
|
||||
#include <ActivBoost/asio/prefer.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class initiate_dispatch
|
||||
{
|
||||
public:
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
execution::is_executor<
|
||||
typename associated_executor<
|
||||
typename decay<CompletionHandler>::type
|
||||
>::type
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_executor<handler_t>::type ex(
|
||||
(get_associated_executor)(handler));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost::asio::prefer(ex, execution::allocator(alloc)).execute(
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
execution::execute(
|
||||
Boost::asio::prefer(ex, execution::allocator(alloc)),
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
!execution::is_executor<
|
||||
typename associated_executor<
|
||||
typename decay<CompletionHandler>::type
|
||||
>::type
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_executor<handler_t>::type ex(
|
||||
(get_associated_executor)(handler));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
ex.dispatch(Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)), alloc);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor>
|
||||
class initiate_dispatch_with_executor
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_dispatch_with_executor(const Executor& ex)
|
||||
: ex_(ex)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return ex_;
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
!detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost::asio::prefer(ex_, execution::allocator(alloc)).execute(
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
execution::execute(
|
||||
Boost::asio::prefer(ex_, execution::allocator(alloc)),
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typedef typename associated_executor<
|
||||
handler_t, Executor>::type handler_ex_t;
|
||||
handler_ex_t handler_ex((get_associated_executor)(handler, ex_));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost::asio::prefer(ex_, execution::allocator(alloc)).execute(
|
||||
detail::work_dispatcher<handler_t, handler_ex_t>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), handler_ex));
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
execution::execute(
|
||||
Boost::asio::prefer(ex_, execution::allocator(alloc)),
|
||||
detail::work_dispatcher<handler_t, handler_ex_t>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), handler_ex));
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
!execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
!detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
ex_.dispatch(Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)), alloc);
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
!execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typedef typename associated_executor<
|
||||
handler_t, Executor>::type handler_ex_t;
|
||||
handler_ex_t handler_ex((get_associated_executor)(handler, ex_));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
ex_.dispatch(detail::work_dispatcher<handler_t, handler_ex_t>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler),
|
||||
handler_ex), alloc);
|
||||
}
|
||||
|
||||
private:
|
||||
Executor ex_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(NullaryToken, void()) dispatch(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(NullaryToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<NullaryToken, void()>(
|
||||
declval<detail::initiate_dispatch>(), token)))
|
||||
{
|
||||
return async_initiate<NullaryToken, void()>(
|
||||
detail::initiate_dispatch(), token);
|
||||
}
|
||||
|
||||
template <typename Executor,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(NullaryToken, void()) dispatch(
|
||||
const Executor& ex, ACTIV_BOOST_ASIO_MOVE_ARG(NullaryToken) token,
|
||||
typename constraint<
|
||||
execution::is_executor<Executor>::value || is_executor<Executor>::value
|
||||
>::type)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<NullaryToken, void()>(
|
||||
declval<detail::initiate_dispatch_with_executor<Executor> >(), token)))
|
||||
{
|
||||
return async_initiate<NullaryToken, void()>(
|
||||
detail::initiate_dispatch_with_executor<Executor>(ex), token);
|
||||
}
|
||||
|
||||
template <typename ExecutionContext,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(NullaryToken, void()) dispatch(
|
||||
ExecutionContext& ctx, ACTIV_BOOST_ASIO_MOVE_ARG(NullaryToken) token,
|
||||
typename constraint<is_convertible<
|
||||
ExecutionContext&, execution_context&>::value>::type)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<NullaryToken, void()>(
|
||||
declval<detail::initiate_dispatch_with_executor<
|
||||
typename ExecutionContext::executor_type> >(), token)))
|
||||
{
|
||||
return async_initiate<NullaryToken, void()>(
|
||||
detail::initiate_dispatch_with_executor<
|
||||
typename ExecutionContext::executor_type>(
|
||||
ctx.get_executor()), token);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_DISPATCH_HPP
|
||||
@@ -1,130 +0,0 @@
|
||||
//
|
||||
// impl/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 ACTIV_BOOST_ASIO_IMPL_ERROR_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_ERROR_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <string>
|
||||
#include <ActivBoost/asio/error.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace error {
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
|
||||
|
||||
namespace detail {
|
||||
|
||||
class netdb_category : public Boost::system::error_category
|
||||
{
|
||||
public:
|
||||
const char* name() const ACTIV_BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT
|
||||
{
|
||||
return "asio.netdb";
|
||||
}
|
||||
|
||||
std::string message(int value) const
|
||||
{
|
||||
if (value == error::host_not_found)
|
||||
return "Host not found (authoritative)";
|
||||
if (value == error::host_not_found_try_again)
|
||||
return "Host not found (non-authoritative), try again later";
|
||||
if (value == error::no_data)
|
||||
return "The query is valid, but it does not have associated data";
|
||||
if (value == error::no_recovery)
|
||||
return "A non-recoverable error occurred during database lookup";
|
||||
return "asio.netdb error";
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
const Boost::system::error_category& get_netdb_category()
|
||||
{
|
||||
static detail::netdb_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
class addrinfo_category : public Boost::system::error_category
|
||||
{
|
||||
public:
|
||||
const char* name() const ACTIV_BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT
|
||||
{
|
||||
return "asio.addrinfo";
|
||||
}
|
||||
|
||||
std::string message(int value) const
|
||||
{
|
||||
if (value == error::service_not_found)
|
||||
return "Service not found";
|
||||
if (value == error::socket_type_not_supported)
|
||||
return "Socket type not supported";
|
||||
return "asio.addrinfo error";
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
const Boost::system::error_category& get_addrinfo_category()
|
||||
{
|
||||
static detail::addrinfo_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
|
||||
|
||||
namespace detail {
|
||||
|
||||
class misc_category : public Boost::system::error_category
|
||||
{
|
||||
public:
|
||||
const char* name() const ACTIV_BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT
|
||||
{
|
||||
return "asio.misc";
|
||||
}
|
||||
|
||||
std::string message(int value) const
|
||||
{
|
||||
if (value == error::already_open)
|
||||
return "Already open";
|
||||
if (value == error::eof)
|
||||
return "End of file";
|
||||
if (value == error::not_found)
|
||||
return "Element not found";
|
||||
if (value == error::fd_set_failure)
|
||||
return "The descriptor does not fit into the select call's fd_set";
|
||||
return "asio.misc error";
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
const Boost::system::error_category& get_misc_category()
|
||||
{
|
||||
static detail::misc_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
} // namespace error
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_ERROR_IPP
|
||||
@@ -1,111 +0,0 @@
|
||||
//
|
||||
// impl/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 ACTIV_BOOST_ASIO_IMPL_EXECUTION_CONTEXT_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_EXECUTION_CONTEXT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <ActivBoost/asio/detail/scoped_ptr.hpp>
|
||||
#include <ActivBoost/asio/detail/service_registry.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename Service>
|
||||
inline Service& use_service(execution_context& e)
|
||||
{
|
||||
// Check that Service meets the necessary type requirements.
|
||||
(void)static_cast<execution_context::service*>(static_cast<Service*>(0));
|
||||
|
||||
return e.service_registry_->template use_service<Service>();
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Service, typename... Args>
|
||||
Service& make_service(execution_context& e, ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
detail::scoped_ptr<Service> svc(
|
||||
new Service(e, ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...));
|
||||
e.service_registry_->template add_service<Service>(svc.get());
|
||||
Service& result = *svc;
|
||||
svc.release();
|
||||
return result;
|
||||
}
|
||||
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Service>
|
||||
Service& make_service(execution_context& e)
|
||||
{
|
||||
detail::scoped_ptr<Service> svc(new Service(e));
|
||||
e.service_registry_->template add_service<Service>(svc.get());
|
||||
Service& result = *svc;
|
||||
svc.release();
|
||||
return result;
|
||||
}
|
||||
|
||||
#define ACTIV_BOOST_ASIO_PRIVATE_MAKE_SERVICE_DEF(n) \
|
||||
template <typename Service, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
Service& make_service(execution_context& e, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
|
||||
{ \
|
||||
detail::scoped_ptr<Service> svc( \
|
||||
new Service(e, ACTIV_BOOST_ASIO_VARIADIC_MOVE_ARGS(n))); \
|
||||
e.service_registry_->template add_service<Service>(svc.get()); \
|
||||
Service& result = *svc; \
|
||||
svc.release(); \
|
||||
return result; \
|
||||
} \
|
||||
/**/
|
||||
ACTIV_BOOST_ASIO_VARIADIC_GENERATE(ACTIV_BOOST_ASIO_PRIVATE_MAKE_SERVICE_DEF)
|
||||
#undef ACTIV_BOOST_ASIO_PRIVATE_MAKE_SERVICE_DEF
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Service>
|
||||
inline void add_service(execution_context& e, Service* svc)
|
||||
{
|
||||
// Check that Service meets the necessary type requirements.
|
||||
(void)static_cast<execution_context::service*>(static_cast<Service*>(0));
|
||||
|
||||
e.service_registry_->template add_service<Service>(svc);
|
||||
}
|
||||
|
||||
template <typename Service>
|
||||
inline bool has_service(execution_context& e)
|
||||
{
|
||||
// Check that Service meets the necessary type requirements.
|
||||
(void)static_cast<execution_context::service*>(static_cast<Service*>(0));
|
||||
|
||||
return e.service_registry_->template has_service<Service>();
|
||||
}
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
inline execution_context& execution_context::service::context()
|
||||
{
|
||||
return owner_;
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_EXECUTION_CONTEXT_HPP
|
||||
@@ -1,84 +0,0 @@
|
||||
//
|
||||
// impl/execution_context.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 ACTIV_BOOST_ASIO_IMPL_EXECUTION_CONTEXT_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_EXECUTION_CONTEXT_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/execution_context.hpp>
|
||||
#include <ActivBoost/asio/detail/service_registry.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
execution_context::execution_context()
|
||||
: service_registry_(new Boost::asio::detail::service_registry(*this))
|
||||
{
|
||||
}
|
||||
|
||||
execution_context::~execution_context()
|
||||
{
|
||||
shutdown();
|
||||
destroy();
|
||||
delete service_registry_;
|
||||
}
|
||||
|
||||
void execution_context::shutdown()
|
||||
{
|
||||
service_registry_->shutdown_services();
|
||||
}
|
||||
|
||||
void execution_context::destroy()
|
||||
{
|
||||
service_registry_->destroy_services();
|
||||
}
|
||||
|
||||
void execution_context::notify_fork(
|
||||
Boost::asio::execution_context::fork_event event)
|
||||
{
|
||||
service_registry_->notify_fork(event);
|
||||
}
|
||||
|
||||
execution_context::service::service(execution_context& owner)
|
||||
: owner_(owner),
|
||||
next_(0)
|
||||
{
|
||||
}
|
||||
|
||||
execution_context::service::~service()
|
||||
{
|
||||
}
|
||||
|
||||
void execution_context::service::notify_fork(execution_context::fork_event)
|
||||
{
|
||||
}
|
||||
|
||||
service_already_exists::service_already_exists()
|
||||
: std::logic_error("Service already exists.")
|
||||
{
|
||||
}
|
||||
|
||||
invalid_service_owner::invalid_service_owner()
|
||||
: std::logic_error("Invalid service owner.")
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_EXECUTION_CONTEXT_IPP
|
||||
@@ -1,302 +0,0 @@
|
||||
//
|
||||
// impl/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 ACTIV_BOOST_ASIO_IMPL_EXECUTOR_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_EXECUTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
#include <ActivBoost/asio/detail/atomic_count.hpp>
|
||||
#include <ActivBoost/asio/detail/global.hpp>
|
||||
#include <ActivBoost/asio/detail/memory.hpp>
|
||||
#include <ActivBoost/asio/executor.hpp>
|
||||
#include <ActivBoost/asio/system_executor.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
// Default polymorphic executor implementation.
|
||||
template <typename Executor, typename Allocator>
|
||||
class executor::impl
|
||||
: public executor::impl_base
|
||||
{
|
||||
public:
|
||||
typedef ACTIV_BOOST_ASIO_REBIND_ALLOC(Allocator, impl) allocator_type;
|
||||
|
||||
static impl_base* create(const Executor& e, Allocator a = Allocator())
|
||||
{
|
||||
raw_mem mem(a);
|
||||
impl* p = new (mem.ptr_) impl(e, a);
|
||||
mem.ptr_ = 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
impl(const Executor& e, const Allocator& a) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: impl_base(false),
|
||||
ref_count_(1),
|
||||
executor_(e),
|
||||
allocator_(a)
|
||||
{
|
||||
}
|
||||
|
||||
impl_base* clone() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
detail::ref_count_up(ref_count_);
|
||||
return const_cast<impl_base*>(static_cast<const impl_base*>(this));
|
||||
}
|
||||
|
||||
void destroy() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
if (detail::ref_count_down(ref_count_))
|
||||
{
|
||||
allocator_type alloc(allocator_);
|
||||
impl* p = this;
|
||||
p->~impl();
|
||||
alloc.deallocate(p, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void on_work_started() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
executor_.on_work_started();
|
||||
}
|
||||
|
||||
void on_work_finished() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
executor_.on_work_finished();
|
||||
}
|
||||
|
||||
execution_context& context() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return executor_.context();
|
||||
}
|
||||
|
||||
void dispatch(ACTIV_BOOST_ASIO_MOVE_ARG(function) f)
|
||||
{
|
||||
executor_.dispatch(ACTIV_BOOST_ASIO_MOVE_CAST(function)(f), allocator_);
|
||||
}
|
||||
|
||||
void post(ACTIV_BOOST_ASIO_MOVE_ARG(function) f)
|
||||
{
|
||||
executor_.post(ACTIV_BOOST_ASIO_MOVE_CAST(function)(f), allocator_);
|
||||
}
|
||||
|
||||
void defer(ACTIV_BOOST_ASIO_MOVE_ARG(function) f)
|
||||
{
|
||||
executor_.defer(ACTIV_BOOST_ASIO_MOVE_CAST(function)(f), allocator_);
|
||||
}
|
||||
|
||||
type_id_result_type target_type() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return type_id<Executor>();
|
||||
}
|
||||
|
||||
void* target() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return &executor_;
|
||||
}
|
||||
|
||||
const void* target() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return &executor_;
|
||||
}
|
||||
|
||||
bool equals(const impl_base* e) const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
if (this == e)
|
||||
return true;
|
||||
if (target_type() != e->target_type())
|
||||
return false;
|
||||
return executor_ == *static_cast<const Executor*>(e->target());
|
||||
}
|
||||
|
||||
private:
|
||||
mutable detail::atomic_count ref_count_;
|
||||
Executor executor_;
|
||||
Allocator allocator_;
|
||||
|
||||
struct raw_mem
|
||||
{
|
||||
allocator_type allocator_;
|
||||
impl* ptr_;
|
||||
|
||||
explicit raw_mem(const Allocator& a)
|
||||
: allocator_(a),
|
||||
ptr_(allocator_.allocate(1))
|
||||
{
|
||||
}
|
||||
|
||||
~raw_mem()
|
||||
{
|
||||
if (ptr_)
|
||||
allocator_.deallocate(ptr_, 1);
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
raw_mem(const raw_mem&);
|
||||
raw_mem operator=(const raw_mem&);
|
||||
};
|
||||
};
|
||||
|
||||
// Polymorphic executor specialisation for system_executor.
|
||||
template <typename Allocator>
|
||||
class executor::impl<system_executor, Allocator>
|
||||
: public executor::impl_base
|
||||
{
|
||||
public:
|
||||
static impl_base* create(const system_executor&,
|
||||
const Allocator& = Allocator())
|
||||
{
|
||||
return &detail::global<impl<system_executor, std::allocator<void> > >();
|
||||
}
|
||||
|
||||
impl()
|
||||
: impl_base(true)
|
||||
{
|
||||
}
|
||||
|
||||
impl_base* clone() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return const_cast<impl_base*>(static_cast<const impl_base*>(this));
|
||||
}
|
||||
|
||||
void destroy() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
void on_work_started() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
executor_.on_work_started();
|
||||
}
|
||||
|
||||
void on_work_finished() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
executor_.on_work_finished();
|
||||
}
|
||||
|
||||
execution_context& context() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return executor_.context();
|
||||
}
|
||||
|
||||
void dispatch(ACTIV_BOOST_ASIO_MOVE_ARG(function) f)
|
||||
{
|
||||
executor_.dispatch(ACTIV_BOOST_ASIO_MOVE_CAST(function)(f),
|
||||
std::allocator<void>());
|
||||
}
|
||||
|
||||
void post(ACTIV_BOOST_ASIO_MOVE_ARG(function) f)
|
||||
{
|
||||
executor_.post(ACTIV_BOOST_ASIO_MOVE_CAST(function)(f),
|
||||
std::allocator<void>());
|
||||
}
|
||||
|
||||
void defer(ACTIV_BOOST_ASIO_MOVE_ARG(function) f)
|
||||
{
|
||||
executor_.defer(ACTIV_BOOST_ASIO_MOVE_CAST(function)(f),
|
||||
std::allocator<void>());
|
||||
}
|
||||
|
||||
type_id_result_type target_type() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return type_id<system_executor>();
|
||||
}
|
||||
|
||||
void* target() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return &executor_;
|
||||
}
|
||||
|
||||
const void* target() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return &executor_;
|
||||
}
|
||||
|
||||
bool equals(const impl_base* e) const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return this == e;
|
||||
}
|
||||
|
||||
private:
|
||||
system_executor executor_;
|
||||
};
|
||||
|
||||
template <typename Executor>
|
||||
executor::executor(Executor e)
|
||||
: impl_(impl<Executor, std::allocator<void> >::create(e))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Executor, typename Allocator>
|
||||
executor::executor(allocator_arg_t, const Allocator& a, Executor e)
|
||||
: impl_(impl<Executor, Allocator>::create(e, a))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Function, typename Allocator>
|
||||
void executor::dispatch(ACTIV_BOOST_ASIO_MOVE_ARG(Function) f,
|
||||
const Allocator& a) const
|
||||
{
|
||||
impl_base* i = get_impl();
|
||||
if (i->fast_dispatch_)
|
||||
system_executor().dispatch(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a);
|
||||
else
|
||||
i->dispatch(function(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a));
|
||||
}
|
||||
|
||||
template <typename Function, typename Allocator>
|
||||
void executor::post(ACTIV_BOOST_ASIO_MOVE_ARG(Function) f,
|
||||
const Allocator& a) const
|
||||
{
|
||||
get_impl()->post(function(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a));
|
||||
}
|
||||
|
||||
template <typename Function, typename Allocator>
|
||||
void executor::defer(ACTIV_BOOST_ASIO_MOVE_ARG(Function) f,
|
||||
const Allocator& a) const
|
||||
{
|
||||
get_impl()->defer(function(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a));
|
||||
}
|
||||
|
||||
template <typename Executor>
|
||||
Executor* executor::target() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return impl_ && impl_->target_type() == type_id<Executor>()
|
||||
? static_cast<Executor*>(impl_->target()) : 0;
|
||||
}
|
||||
|
||||
template <typename Executor>
|
||||
const Executor* executor::target() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return impl_ && impl_->target_type() == type_id<Executor>()
|
||||
? static_cast<Executor*>(impl_->target()) : 0;
|
||||
}
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_EXECUTOR_HPP
|
||||
@@ -1,45 +0,0 @@
|
||||
//
|
||||
// impl/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 ACTIV_BOOST_ASIO_IMPL_EXECUTOR_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_EXECUTOR_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
#include <ActivBoost/asio/executor.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
bad_executor::bad_executor() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char* bad_executor::what() const ACTIV_BOOST_ASIO_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
return "bad executor";
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_EXECUTOR_IPP
|
||||
@@ -1,64 +0,0 @@
|
||||
//
|
||||
// impl/handler_alloc_hook.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 ACTIV_BOOST_ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/detail/memory.hpp>
|
||||
#include <ActivBoost/asio/detail/thread_context.hpp>
|
||||
#include <ActivBoost/asio/detail/thread_info_base.hpp>
|
||||
#include <ActivBoost/asio/handler_alloc_hook.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size, ...)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
(void)size;
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#elif !defined(ACTIV_BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
return detail::thread_info_base::allocate(
|
||||
detail::thread_context::top_of_thread_call_stack(), size);
|
||||
#else // !defined(ACTIV_BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
return aligned_new(ACTIV_BOOST_ASIO_DEFAULT_ALIGN, size);
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
}
|
||||
|
||||
asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size, ...)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
(void)pointer;
|
||||
(void)size;
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#elif !defined(ACTIV_BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
detail::thread_info_base::deallocate(
|
||||
detail::thread_context::top_of_thread_call_stack(), pointer, size);
|
||||
#else // !defined(ACTIV_BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
(void)size;
|
||||
aligned_delete(pointer);
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP
|
||||
@@ -1,452 +0,0 @@
|
||||
//
|
||||
// impl/io_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 ACTIV_BOOST_ASIO_IMPL_IO_CONTEXT_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_IO_CONTEXT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/completion_handler.hpp>
|
||||
#include <ActivBoost/asio/detail/executor_op.hpp>
|
||||
#include <ActivBoost/asio/detail/fenced_block.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <ActivBoost/asio/detail/non_const_lvalue.hpp>
|
||||
#include <ActivBoost/asio/detail/service_registry.hpp>
|
||||
#include <ActivBoost/asio/detail/throw_error.hpp>
|
||||
#include <ActivBoost/asio/detail/type_traits.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename Service>
|
||||
inline Service& use_service(io_context& ioc)
|
||||
{
|
||||
// Check that Service meets the necessary type requirements.
|
||||
(void)static_cast<execution_context::service*>(static_cast<Service*>(0));
|
||||
(void)static_cast<const execution_context::id*>(&Service::id);
|
||||
|
||||
return ioc.service_registry_->template use_service<Service>(ioc);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline detail::io_context_impl& use_service<detail::io_context_impl>(
|
||||
io_context& ioc)
|
||||
{
|
||||
return ioc.impl_;
|
||||
}
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
inline io_context::executor_type
|
||||
io_context::get_executor() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return executor_type(*this);
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_CHRONO)
|
||||
|
||||
template <typename Rep, typename Period>
|
||||
std::size_t io_context::run_for(
|
||||
const chrono::duration<Rep, Period>& rel_time)
|
||||
{
|
||||
return this->run_until(chrono::steady_clock::now() + rel_time);
|
||||
}
|
||||
|
||||
template <typename Clock, typename Duration>
|
||||
std::size_t io_context::run_until(
|
||||
const chrono::time_point<Clock, Duration>& abs_time)
|
||||
{
|
||||
std::size_t n = 0;
|
||||
while (this->run_one_until(abs_time))
|
||||
if (n != (std::numeric_limits<std::size_t>::max)())
|
||||
++n;
|
||||
return n;
|
||||
}
|
||||
|
||||
template <typename Rep, typename Period>
|
||||
std::size_t io_context::run_one_for(
|
||||
const chrono::duration<Rep, Period>& rel_time)
|
||||
{
|
||||
return this->run_one_until(chrono::steady_clock::now() + rel_time);
|
||||
}
|
||||
|
||||
template <typename Clock, typename Duration>
|
||||
std::size_t io_context::run_one_until(
|
||||
const chrono::time_point<Clock, Duration>& abs_time)
|
||||
{
|
||||
typename Clock::time_point now = Clock::now();
|
||||
while (now < abs_time)
|
||||
{
|
||||
typename Clock::duration rel_time = abs_time - now;
|
||||
if (rel_time > chrono::seconds(1))
|
||||
rel_time = chrono::seconds(1);
|
||||
|
||||
Boost::system::error_code ec;
|
||||
std::size_t s = impl_.wait_one(
|
||||
static_cast<long>(chrono::duration_cast<
|
||||
chrono::microseconds>(rel_time).count()), ec);
|
||||
Boost::asio::detail::throw_error(ec);
|
||||
|
||||
if (s || impl_.stopped())
|
||||
return s;
|
||||
|
||||
now = Clock::now();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_CHRONO)
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
inline void io_context::reset()
|
||||
{
|
||||
restart();
|
||||
}
|
||||
|
||||
struct io_context::initiate_dispatch
|
||||
{
|
||||
template <typename LegacyCompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(LegacyCompletionHandler) handler,
|
||||
io_context* self) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a LegacyCompletionHandler.
|
||||
ACTIV_BOOST_ASIO_LEGACY_COMPLETION_HANDLER_CHECK(
|
||||
LegacyCompletionHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<LegacyCompletionHandler> handler2(handler);
|
||||
if (self->impl_.can_dispatch())
|
||||
{
|
||||
detail::fenced_block b(detail::fenced_block::full);
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
handler2.value, handler2.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Allocate and construct an operation to wrap the handler.
|
||||
typedef detail::completion_handler<
|
||||
typename decay<LegacyCompletionHandler>::type, executor_type> op;
|
||||
typename op::ptr p = { detail::addressof(handler2.value),
|
||||
op::ptr::allocate(handler2.value), 0 };
|
||||
p.p = new (p.v) op(handler2.value, self->get_executor());
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*self, *p.p,
|
||||
"io_context", self, 0, "dispatch"));
|
||||
|
||||
self->impl_.do_dispatch(p.p);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename LegacyCompletionHandler>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(LegacyCompletionHandler, void ())
|
||||
io_context::dispatch(ACTIV_BOOST_ASIO_MOVE_ARG(LegacyCompletionHandler) handler)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<LegacyCompletionHandler, void ()>(
|
||||
declval<initiate_dispatch>(), handler, this)))
|
||||
{
|
||||
return async_initiate<LegacyCompletionHandler, void ()>(
|
||||
initiate_dispatch(), handler, this);
|
||||
}
|
||||
|
||||
struct io_context::initiate_post
|
||||
{
|
||||
template <typename LegacyCompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(LegacyCompletionHandler) handler,
|
||||
io_context* self) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a LegacyCompletionHandler.
|
||||
ACTIV_BOOST_ASIO_LEGACY_COMPLETION_HANDLER_CHECK(
|
||||
LegacyCompletionHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<LegacyCompletionHandler> handler2(handler);
|
||||
|
||||
bool is_continuation =
|
||||
Boost_asio_handler_cont_helpers::is_continuation(handler2.value);
|
||||
|
||||
// Allocate and construct an operation to wrap the handler.
|
||||
typedef detail::completion_handler<
|
||||
typename decay<LegacyCompletionHandler>::type, executor_type> op;
|
||||
typename op::ptr p = { detail::addressof(handler2.value),
|
||||
op::ptr::allocate(handler2.value), 0 };
|
||||
p.p = new (p.v) op(handler2.value, self->get_executor());
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*self, *p.p,
|
||||
"io_context", self, 0, "post"));
|
||||
|
||||
self->impl_.post_immediate_completion(p.p, is_continuation);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename LegacyCompletionHandler>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(LegacyCompletionHandler, void ())
|
||||
io_context::post(ACTIV_BOOST_ASIO_MOVE_ARG(LegacyCompletionHandler) handler)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<LegacyCompletionHandler, void ()>(
|
||||
declval<initiate_post>(), handler, this)))
|
||||
{
|
||||
return async_initiate<LegacyCompletionHandler, void ()>(
|
||||
initiate_post(), handler, this);
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
unspecified
|
||||
#else
|
||||
inline detail::wrapped_handler<io_context&, Handler>
|
||||
#endif
|
||||
io_context::wrap(Handler handler)
|
||||
{
|
||||
return detail::wrapped_handler<io_context&, Handler>(*this, handler);
|
||||
}
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
template <typename Allocator, uintptr_t Bits>
|
||||
io_context::basic_executor_type<Allocator, Bits>&
|
||||
io_context::basic_executor_type<Allocator, Bits>::operator=(
|
||||
const basic_executor_type& other) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
static_cast<Allocator&>(*this) = static_cast<const Allocator&>(other);
|
||||
io_context* old_io_context = context_ptr();
|
||||
target_ = other.target_;
|
||||
if (Bits & outstanding_work_tracked)
|
||||
{
|
||||
if (context_ptr())
|
||||
context_ptr()->impl_.work_started();
|
||||
if (old_io_context)
|
||||
old_io_context->impl_.work_finished();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
template <typename Allocator, uintptr_t Bits>
|
||||
io_context::basic_executor_type<Allocator, Bits>&
|
||||
io_context::basic_executor_type<Allocator, Bits>::operator=(
|
||||
basic_executor_type&& other) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
static_cast<Allocator&>(*this) = static_cast<Allocator&&>(other);
|
||||
io_context* old_io_context = context_ptr();
|
||||
target_ = other.target_;
|
||||
if (Bits & outstanding_work_tracked)
|
||||
{
|
||||
other.target_ = 0;
|
||||
if (old_io_context)
|
||||
old_io_context->impl_.work_finished();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
template <typename Allocator, uintptr_t Bits>
|
||||
inline bool io_context::basic_executor_type<Allocator,
|
||||
Bits>::running_in_this_thread() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return context_ptr()->impl_.can_dispatch();
|
||||
}
|
||||
|
||||
template <typename Allocator, uintptr_t Bits>
|
||||
template <typename Function>
|
||||
void io_context::basic_executor_type<Allocator, Bits>::execute(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
// Invoke immediately if the blocking.possibly property is enabled and we are
|
||||
// already inside the thread pool.
|
||||
if ((bits() & blocking_never) == 0 && context_ptr()->impl_.can_dispatch())
|
||||
{
|
||||
// Make a local, non-const copy of the function.
|
||||
function_type tmp(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_STD_EXCEPTION_PTR) \
|
||||
&& !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
try
|
||||
{
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
// && !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
detail::fenced_block b(detail::fenced_block::full);
|
||||
Boost_asio_handler_invoke_helpers::invoke(tmp, tmp);
|
||||
return;
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_STD_EXCEPTION_PTR) \
|
||||
&& !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
context_ptr()->impl_.capture_current_exception();
|
||||
return;
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
// && !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef detail::executor_op<function_type, Allocator, detail::operation> op;
|
||||
typename op::ptr p = {
|
||||
detail::addressof(static_cast<const Allocator&>(*this)),
|
||||
op::ptr::allocate(static_cast<const Allocator&>(*this)), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f),
|
||||
static_cast<const Allocator&>(*this));
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*context_ptr(), *p.p,
|
||||
"io_context", context_ptr(), 0, "execute"));
|
||||
|
||||
context_ptr()->impl_.post_immediate_completion(p.p,
|
||||
(bits() & relationship_continuation) != 0);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
template <typename Allocator, uintptr_t Bits>
|
||||
inline io_context& io_context::basic_executor_type<
|
||||
Allocator, Bits>::context() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return *context_ptr();
|
||||
}
|
||||
|
||||
template <typename Allocator, uintptr_t Bits>
|
||||
inline void io_context::basic_executor_type<Allocator,
|
||||
Bits>::on_work_started() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
context_ptr()->impl_.work_started();
|
||||
}
|
||||
|
||||
template <typename Allocator, uintptr_t Bits>
|
||||
inline void io_context::basic_executor_type<Allocator,
|
||||
Bits>::on_work_finished() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
context_ptr()->impl_.work_finished();
|
||||
}
|
||||
|
||||
template <typename Allocator, uintptr_t Bits>
|
||||
template <typename Function, typename OtherAllocator>
|
||||
void io_context::basic_executor_type<Allocator, Bits>::dispatch(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
// Invoke immediately if we are already inside the thread pool.
|
||||
if (context_ptr()->impl_.can_dispatch())
|
||||
{
|
||||
// Make a local, non-const copy of the function.
|
||||
function_type tmp(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f));
|
||||
|
||||
detail::fenced_block b(detail::fenced_block::full);
|
||||
Boost_asio_handler_invoke_helpers::invoke(tmp, tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef detail::executor_op<function_type,
|
||||
OtherAllocator, detail::operation> op;
|
||||
typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a);
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*context_ptr(), *p.p,
|
||||
"io_context", context_ptr(), 0, "dispatch"));
|
||||
|
||||
context_ptr()->impl_.post_immediate_completion(p.p, false);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
|
||||
template <typename Allocator, uintptr_t Bits>
|
||||
template <typename Function, typename OtherAllocator>
|
||||
void io_context::basic_executor_type<Allocator, Bits>::post(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef detail::executor_op<function_type,
|
||||
OtherAllocator, detail::operation> op;
|
||||
typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a);
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*context_ptr(), *p.p,
|
||||
"io_context", context_ptr(), 0, "post"));
|
||||
|
||||
context_ptr()->impl_.post_immediate_completion(p.p, false);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
|
||||
template <typename Allocator, uintptr_t Bits>
|
||||
template <typename Function, typename OtherAllocator>
|
||||
void io_context::basic_executor_type<Allocator, Bits>::defer(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef detail::executor_op<function_type,
|
||||
OtherAllocator, detail::operation> op;
|
||||
typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a);
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*context_ptr(), *p.p,
|
||||
"io_context", context_ptr(), 0, "defer"));
|
||||
|
||||
context_ptr()->impl_.post_immediate_completion(p.p, true);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
inline io_context::work::work(Boost::asio::io_context& io_context)
|
||||
: io_context_impl_(io_context.impl_)
|
||||
{
|
||||
io_context_impl_.work_started();
|
||||
}
|
||||
|
||||
inline io_context::work::work(const work& other)
|
||||
: io_context_impl_(other.io_context_impl_)
|
||||
{
|
||||
io_context_impl_.work_started();
|
||||
}
|
||||
|
||||
inline io_context::work::~work()
|
||||
{
|
||||
io_context_impl_.work_finished();
|
||||
}
|
||||
|
||||
inline Boost::asio::io_context& io_context::work::get_io_context()
|
||||
{
|
||||
return static_cast<Boost::asio::io_context&>(io_context_impl_.context());
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
inline Boost::asio::io_context& io_context::service::get_io_context()
|
||||
{
|
||||
return static_cast<Boost::asio::io_context&>(context());
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_IO_CONTEXT_HPP
|
||||
@@ -1,177 +0,0 @@
|
||||
//
|
||||
// impl/io_context.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 ACTIV_BOOST_ASIO_IMPL_IO_CONTEXT_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_IO_CONTEXT_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/io_context.hpp>
|
||||
#include <ActivBoost/asio/detail/concurrency_hint.hpp>
|
||||
#include <ActivBoost/asio/detail/limits.hpp>
|
||||
#include <ActivBoost/asio/detail/scoped_ptr.hpp>
|
||||
#include <ActivBoost/asio/detail/service_registry.hpp>
|
||||
#include <ActivBoost/asio/detail/throw_error.hpp>
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_IOCP)
|
||||
# include <ActivBoost/asio/detail/win_iocp_io_context.hpp>
|
||||
#else
|
||||
# include <ActivBoost/asio/detail/scheduler.hpp>
|
||||
#endif
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
io_context::io_context()
|
||||
: impl_(add_impl(new impl_type(*this,
|
||||
ACTIV_BOOST_ASIO_CONCURRENCY_HINT_DEFAULT, false)))
|
||||
{
|
||||
}
|
||||
|
||||
io_context::io_context(int concurrency_hint)
|
||||
: impl_(add_impl(new impl_type(*this, concurrency_hint == 1
|
||||
? ACTIV_BOOST_ASIO_CONCURRENCY_HINT_1 : concurrency_hint, false)))
|
||||
{
|
||||
}
|
||||
|
||||
io_context::impl_type& io_context::add_impl(io_context::impl_type* impl)
|
||||
{
|
||||
Boost::asio::detail::scoped_ptr<impl_type> scoped_impl(impl);
|
||||
Boost::asio::add_service<impl_type>(*this, scoped_impl.get());
|
||||
return *scoped_impl.release();
|
||||
}
|
||||
|
||||
io_context::~io_context()
|
||||
{
|
||||
}
|
||||
|
||||
io_context::count_type io_context::run()
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
count_type s = impl_.run(ec);
|
||||
Boost::asio::detail::throw_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
io_context::count_type io_context::run(Boost::system::error_code& ec)
|
||||
{
|
||||
return impl_.run(ec);
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
io_context::count_type io_context::run_one()
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
count_type s = impl_.run_one(ec);
|
||||
Boost::asio::detail::throw_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
io_context::count_type io_context::run_one(Boost::system::error_code& ec)
|
||||
{
|
||||
return impl_.run_one(ec);
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
io_context::count_type io_context::poll()
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
count_type s = impl_.poll(ec);
|
||||
Boost::asio::detail::throw_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
io_context::count_type io_context::poll(Boost::system::error_code& ec)
|
||||
{
|
||||
return impl_.poll(ec);
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
io_context::count_type io_context::poll_one()
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
count_type s = impl_.poll_one(ec);
|
||||
Boost::asio::detail::throw_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
io_context::count_type io_context::poll_one(Boost::system::error_code& ec)
|
||||
{
|
||||
return impl_.poll_one(ec);
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
void io_context::stop()
|
||||
{
|
||||
impl_.stop();
|
||||
}
|
||||
|
||||
bool io_context::stopped() const
|
||||
{
|
||||
return impl_.stopped();
|
||||
}
|
||||
|
||||
void io_context::restart()
|
||||
{
|
||||
impl_.restart();
|
||||
}
|
||||
|
||||
io_context::service::service(Boost::asio::io_context& owner)
|
||||
: execution_context::service(owner)
|
||||
{
|
||||
}
|
||||
|
||||
io_context::service::~service()
|
||||
{
|
||||
}
|
||||
|
||||
void io_context::service::shutdown()
|
||||
{
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
shutdown_service();
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
void io_context::service::shutdown_service()
|
||||
{
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
void io_context::service::notify_fork(io_context::fork_event ev)
|
||||
{
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
fork_service(ev);
|
||||
#else // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
(void)ev;
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
void io_context::service::fork_service(io_context::fork_event)
|
||||
{
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_IO_CONTEXT_IPP
|
||||
@@ -1,51 +0,0 @@
|
||||
//
|
||||
// impl/multiple_exceptions.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 ACTIV_BOOST_ASIO_IMPL_MULTIPLE_EXCEPTIONS_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_MULTIPLE_EXCEPTIONS_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/multiple_exceptions.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
|
||||
multiple_exceptions::multiple_exceptions(
|
||||
std::exception_ptr first) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
: first_(ACTIV_BOOST_ASIO_MOVE_CAST(std::exception_ptr)(first))
|
||||
{
|
||||
}
|
||||
|
||||
const char* multiple_exceptions::what() const ACTIV_BOOST_ASIO_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
return "multiple exceptions";
|
||||
}
|
||||
|
||||
std::exception_ptr multiple_exceptions::first_exception() const
|
||||
{
|
||||
return first_;
|
||||
}
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_MULTIPLE_EXCEPTIONS_IPP
|
||||
@@ -1,300 +0,0 @@
|
||||
//
|
||||
// impl/post.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 ACTIV_BOOST_ASIO_IMPL_POST_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_POST_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/associated_allocator.hpp>
|
||||
#include <ActivBoost/asio/associated_executor.hpp>
|
||||
#include <ActivBoost/asio/detail/work_dispatcher.hpp>
|
||||
#include <ActivBoost/asio/execution/allocator.hpp>
|
||||
#include <ActivBoost/asio/execution/blocking.hpp>
|
||||
#include <ActivBoost/asio/execution/relationship.hpp>
|
||||
#include <ActivBoost/asio/prefer.hpp>
|
||||
#include <ActivBoost/asio/require.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class initiate_post
|
||||
{
|
||||
public:
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
execution::is_executor<
|
||||
typename associated_executor<
|
||||
typename decay<CompletionHandler>::type
|
||||
>::type
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_executor<handler_t>::type ex(
|
||||
(get_associated_executor)(handler));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex, execution::blocking.never),
|
||||
execution::relationship.fork,
|
||||
execution::allocator(alloc)
|
||||
).execute(
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
execution::execute(
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex, execution::blocking.never),
|
||||
execution::relationship.fork,
|
||||
execution::allocator(alloc)),
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
!execution::is_executor<
|
||||
typename associated_executor<
|
||||
typename decay<CompletionHandler>::type
|
||||
>::type
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_executor<handler_t>::type ex(
|
||||
(get_associated_executor)(handler));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
ex.post(Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)), alloc);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor>
|
||||
class initiate_post_with_executor
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_post_with_executor(const Executor& ex)
|
||||
: ex_(ex)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return ex_;
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
!detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex_, execution::blocking.never),
|
||||
execution::relationship.fork,
|
||||
execution::allocator(alloc)
|
||||
).execute(
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
execution::execute(
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex_, execution::blocking.never),
|
||||
execution::relationship.fork,
|
||||
execution::allocator(alloc)),
|
||||
Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)));
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typedef typename associated_executor<
|
||||
handler_t, Executor>::type handler_ex_t;
|
||||
handler_ex_t handler_ex((get_associated_executor)(handler, ex_));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex_, execution::blocking.never),
|
||||
execution::relationship.fork,
|
||||
execution::allocator(alloc)
|
||||
).execute(
|
||||
detail::work_dispatcher<handler_t, handler_ex_t>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), handler_ex));
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
execution::execute(
|
||||
Boost::asio::prefer(
|
||||
Boost::asio::require(ex_, execution::blocking.never),
|
||||
execution::relationship.fork,
|
||||
execution::allocator(alloc)),
|
||||
detail::work_dispatcher<handler_t, handler_ex_t>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), handler_ex));
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
!execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
!detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
ex_.post(Boost::asio::detail::bind_handler(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)), alloc);
|
||||
}
|
||||
|
||||
template <typename CompletionHandler>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
|
||||
typename enable_if<
|
||||
!execution::is_executor<
|
||||
typename conditional<true, executor_type, CompletionHandler>::type
|
||||
>::value
|
||||
>::type* = 0,
|
||||
typename enable_if<
|
||||
detail::is_work_dispatcher_required<
|
||||
typename decay<CompletionHandler>::type,
|
||||
Executor
|
||||
>::value
|
||||
>::type* = 0) const
|
||||
{
|
||||
typedef typename decay<CompletionHandler>::type handler_t;
|
||||
|
||||
typedef typename associated_executor<
|
||||
handler_t, Executor>::type handler_ex_t;
|
||||
handler_ex_t handler_ex((get_associated_executor)(handler, ex_));
|
||||
|
||||
typename associated_allocator<handler_t>::type alloc(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
ex_.post(detail::work_dispatcher<handler_t, handler_ex_t>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler),
|
||||
handler_ex), alloc);
|
||||
}
|
||||
|
||||
private:
|
||||
Executor ex_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(NullaryToken, void()) post(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(NullaryToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<NullaryToken, void()>(
|
||||
declval<detail::initiate_post>(), token)))
|
||||
{
|
||||
return async_initiate<NullaryToken, void()>(
|
||||
detail::initiate_post(), token);
|
||||
}
|
||||
|
||||
template <typename Executor,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken>
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(NullaryToken, void()) post(
|
||||
const Executor& ex, ACTIV_BOOST_ASIO_MOVE_ARG(NullaryToken) token,
|
||||
typename constraint<
|
||||
(execution::is_executor<Executor>::value
|
||||
&& can_require<Executor, execution::blocking_t::never_t>::value)
|
||||
|| is_executor<Executor>::value
|
||||
>::type)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<NullaryToken, void()>(
|
||||
declval<detail::initiate_post_with_executor<Executor> >(), token)))
|
||||
{
|
||||
return async_initiate<NullaryToken, void()>(
|
||||
detail::initiate_post_with_executor<Executor>(ex), token);
|
||||
}
|
||||
|
||||
template <typename ExecutionContext,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(NullaryToken, void()) post(
|
||||
ExecutionContext& ctx, ACTIV_BOOST_ASIO_MOVE_ARG(NullaryToken) token,
|
||||
typename constraint<is_convertible<
|
||||
ExecutionContext&, execution_context&>::value>::type)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<NullaryToken, void()>(
|
||||
declval<detail::initiate_post_with_executor<
|
||||
typename ExecutionContext::executor_type> >(), token)))
|
||||
{
|
||||
return async_initiate<NullaryToken, void()>(
|
||||
detail::initiate_post_with_executor<
|
||||
typename ExecutionContext::executor_type>(
|
||||
ctx.get_executor()), token);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_POST_HPP
|
||||
@@ -1,227 +0,0 @@
|
||||
//
|
||||
// impl/prepend.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 ACTIV_BOOST_ASIO_IMPL_PREPEND_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_PREPEND_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#include <ActivBoost/asio/associator.hpp>
|
||||
#include <ActivBoost/asio/async_result.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/type_traits.hpp>
|
||||
#include <ActivBoost/asio/detail/utility.hpp>
|
||||
#include <ActivBoost/asio/detail/variadic_templates.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Class to adapt a prepend_t as a completion handler.
|
||||
template <typename Handler, typename... Values>
|
||||
class prepend_handler
|
||||
{
|
||||
public:
|
||||
typedef void result_type;
|
||||
|
||||
template <typename H>
|
||||
prepend_handler(ACTIV_BOOST_ASIO_MOVE_ARG(H) handler, std::tuple<Values...> values)
|
||||
: handler_(ACTIV_BOOST_ASIO_MOVE_CAST(H)(handler)),
|
||||
values_(ACTIV_BOOST_ASIO_MOVE_CAST(std::tuple<Values...>)(values))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
this->invoke(
|
||||
index_sequence_for<Values...>{},
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
template <std::size_t... I, typename... Args>
|
||||
void invoke(index_sequence<I...>, ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Values)(std::get<I>(values_))...,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
std::tuple<Values...> values_;
|
||||
};
|
||||
|
||||
template <typename Handler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
prepend_handler<Handler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
prepend_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
prepend_handler<Handler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
prepend_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
prepend_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Signature, typename... Values>
|
||||
struct prepend_signature;
|
||||
|
||||
template <typename R, typename... Args, typename... Values>
|
||||
struct prepend_signature<R(Args...), Values...>
|
||||
{
|
||||
typedef R type(Values..., typename decay<Args>::type...);
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename CompletionToken, typename... Values, typename Signature>
|
||||
struct async_result<
|
||||
prepend_t<CompletionToken, Values...>, Signature>
|
||||
: async_result<CompletionToken,
|
||||
typename detail::prepend_signature<
|
||||
Signature, Values...>::type>
|
||||
{
|
||||
typedef typename detail::prepend_signature<
|
||||
Signature, Values...>::type signature;
|
||||
|
||||
template <typename Initiation>
|
||||
struct init_wrapper
|
||||
{
|
||||
init_wrapper(Initiation init)
|
||||
: initiation_(ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(init))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Handler, typename... Args>
|
||||
void operator()(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
std::tuple<Values...> values,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation_)(
|
||||
detail::prepend_handler<
|
||||
typename decay<Handler>::type, Values...>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Handler)(handler),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(std::tuple<Values...>)(values)),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
Initiation initiation_;
|
||||
};
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static ACTIV_BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(CompletionToken, signature,
|
||||
(async_initiate<CompletionToken, signature>(
|
||||
declval<init_wrapper<typename decay<Initiation>::type> >(),
|
||||
declval<CompletionToken&>(),
|
||||
declval<std::tuple<Values...> >(),
|
||||
declval<ACTIV_BOOST_ASIO_MOVE_ARG(Args)>()...)))
|
||||
initiate(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RawCompletionToken) token,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
return async_initiate<CompletionToken, signature>(
|
||||
init_wrapper<typename decay<Initiation>::type>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation)),
|
||||
token.token_,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(std::tuple<Values...>)(token.values_),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename Handler, typename... Values, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::prepend_handler<Handler, Values...>, DefaultCandidate>
|
||||
: Associator<Handler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<Handler, DefaultCandidate>::type
|
||||
get(const detail::prepend_handler<Handler, Values...>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<Handler, DefaultCandidate>::type)
|
||||
get(const detail::prepend_handler<Handler, Values...>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<Handler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_PREPEND_HPP
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,776 +0,0 @@
|
||||
//
|
||||
// impl/read_at.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 ACTIV_BOOST_ASIO_IMPL_READ_AT_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_READ_AT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <algorithm>
|
||||
#include <ActivBoost/asio/associator.hpp>
|
||||
#include <ActivBoost/asio/buffer.hpp>
|
||||
#include <ActivBoost/asio/detail/array_fwd.hpp>
|
||||
#include <ActivBoost/asio/detail/base_from_cancellation_state.hpp>
|
||||
#include <ActivBoost/asio/detail/base_from_completion_cond.hpp>
|
||||
#include <ActivBoost/asio/detail/bind_handler.hpp>
|
||||
#include <ActivBoost/asio/detail/consuming_buffers.hpp>
|
||||
#include <ActivBoost/asio/detail/dependent_type.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_tracking.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <ActivBoost/asio/detail/non_const_lvalue.hpp>
|
||||
#include <ActivBoost/asio/detail/throw_error.hpp>
|
||||
#include <ActivBoost/asio/error.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
|
||||
typename MutableBufferIterator, typename CompletionCondition>
|
||||
std::size_t read_at_buffer_sequence(SyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, const MutableBufferSequence& buffers,
|
||||
const MutableBufferIterator&, CompletionCondition completion_condition,
|
||||
Boost::system::error_code& ec)
|
||||
{
|
||||
ec = Boost::system::error_code();
|
||||
Boost::asio::detail::consuming_buffers<mutable_buffer,
|
||||
MutableBufferSequence, MutableBufferIterator> tmp(buffers);
|
||||
while (!tmp.empty())
|
||||
{
|
||||
if (std::size_t max_size = detail::adapt_completion_condition_result(
|
||||
completion_condition(ec, tmp.total_consumed())))
|
||||
{
|
||||
tmp.consume(d.read_some_at(offset + tmp.total_consumed(),
|
||||
tmp.prepare(max_size), ec));
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return tmp.total_consumed();
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
|
||||
typename CompletionCondition>
|
||||
std::size_t read_at(SyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, const MutableBufferSequence& buffers,
|
||||
CompletionCondition completion_condition, Boost::system::error_code& ec)
|
||||
{
|
||||
return detail::read_at_buffer_sequence(d, offset, buffers,
|
||||
Boost::asio::buffer_sequence_begin(buffers),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition), ec);
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
|
||||
inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, const MutableBufferSequence& buffers)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = read_at(
|
||||
d, offset, buffers, transfer_all(), ec);
|
||||
Boost::asio::detail::throw_error(ec, "read_at");
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
|
||||
inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, const MutableBufferSequence& buffers,
|
||||
Boost::system::error_code& ec)
|
||||
{
|
||||
return read_at(d, offset, buffers, transfer_all(), ec);
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
|
||||
typename CompletionCondition>
|
||||
inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, const MutableBufferSequence& buffers,
|
||||
CompletionCondition completion_condition)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = read_at(d, offset, buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition), ec);
|
||||
Boost::asio::detail::throw_error(ec, "read_at");
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXTENSIONS)
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_IOSTREAM)
|
||||
|
||||
template <typename SyncRandomAccessReadDevice, typename Allocator,
|
||||
typename CompletionCondition>
|
||||
std::size_t read_at(SyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b,
|
||||
CompletionCondition completion_condition, Boost::system::error_code& ec)
|
||||
{
|
||||
ec = Boost::system::error_code();
|
||||
std::size_t total_transferred = 0;
|
||||
std::size_t max_size = detail::adapt_completion_condition_result(
|
||||
completion_condition(ec, total_transferred));
|
||||
std::size_t bytes_available = read_size_helper(b, max_size);
|
||||
while (bytes_available > 0)
|
||||
{
|
||||
std::size_t bytes_transferred = d.read_some_at(
|
||||
offset + total_transferred, b.prepare(bytes_available), ec);
|
||||
b.commit(bytes_transferred);
|
||||
total_transferred += bytes_transferred;
|
||||
max_size = detail::adapt_completion_condition_result(
|
||||
completion_condition(ec, total_transferred));
|
||||
bytes_available = read_size_helper(b, max_size);
|
||||
}
|
||||
return total_transferred;
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessReadDevice, typename Allocator>
|
||||
inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = read_at(
|
||||
d, offset, b, transfer_all(), ec);
|
||||
Boost::asio::detail::throw_error(ec, "read_at");
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessReadDevice, typename Allocator>
|
||||
inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b,
|
||||
Boost::system::error_code& ec)
|
||||
{
|
||||
return read_at(d, offset, b, transfer_all(), ec);
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessReadDevice, typename Allocator,
|
||||
typename CompletionCondition>
|
||||
inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b,
|
||||
CompletionCondition completion_condition)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = read_at(d, offset, b,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition), ec);
|
||||
Boost::asio::detail::throw_error(ec, "read_at");
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_IOSTREAM)
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_EXTENSIONS)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename AsyncRandomAccessReadDevice,
|
||||
typename MutableBufferSequence, typename MutableBufferIterator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
class read_at_op
|
||||
: public base_from_cancellation_state<ReadHandler>,
|
||||
base_from_completion_cond<CompletionCondition>
|
||||
{
|
||||
public:
|
||||
read_at_op(AsyncRandomAccessReadDevice& device,
|
||||
uint64_t offset, const MutableBufferSequence& buffers,
|
||||
CompletionCondition& completion_condition, ReadHandler& handler)
|
||||
: base_from_cancellation_state<ReadHandler>(
|
||||
handler, enable_partial_cancellation()),
|
||||
base_from_completion_cond<CompletionCondition>(completion_condition),
|
||||
device_(device),
|
||||
offset_(offset),
|
||||
buffers_(buffers),
|
||||
start_(0),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
read_at_op(const read_at_op& other)
|
||||
: base_from_cancellation_state<ReadHandler>(other),
|
||||
base_from_completion_cond<CompletionCondition>(other),
|
||||
device_(other.device_),
|
||||
offset_(other.offset_),
|
||||
buffers_(other.buffers_),
|
||||
start_(other.start_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
read_at_op(read_at_op&& other)
|
||||
: base_from_cancellation_state<ReadHandler>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(base_from_cancellation_state<
|
||||
ReadHandler>)(other)),
|
||||
base_from_completion_cond<CompletionCondition>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(base_from_completion_cond<
|
||||
CompletionCondition>)(other)),
|
||||
device_(other.device_),
|
||||
offset_(other.offset_),
|
||||
buffers_(ACTIV_BOOST_ASIO_MOVE_CAST(buffers_type)(other.buffers_)),
|
||||
start_(other.start_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()(Boost::system::error_code ec,
|
||||
std::size_t bytes_transferred, int start = 0)
|
||||
{
|
||||
std::size_t max_size;
|
||||
switch (start_ = start)
|
||||
{
|
||||
case 1:
|
||||
max_size = this->check_for_completion(ec, buffers_.total_consumed());
|
||||
for (;;)
|
||||
{
|
||||
{
|
||||
ACTIV_BOOST_ASIO_HANDLER_LOCATION((__FILE__, __LINE__, "async_read_at"));
|
||||
device_.async_read_some_at(
|
||||
offset_ + buffers_.total_consumed(), buffers_.prepare(max_size),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(read_at_op)(*this));
|
||||
}
|
||||
return; default:
|
||||
buffers_.consume(bytes_transferred);
|
||||
if ((!ec && bytes_transferred == 0) || buffers_.empty())
|
||||
break;
|
||||
max_size = this->check_for_completion(ec, buffers_.total_consumed());
|
||||
if (max_size == 0)
|
||||
break;
|
||||
if (this->cancelled() != cancellation_type::none)
|
||||
{
|
||||
ec = Boost::asio::error::operation_aborted;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(ReadHandler)(handler_)(
|
||||
static_cast<const Boost::system::error_code&>(ec),
|
||||
static_cast<const std::size_t&>(buffers_.total_consumed()));
|
||||
}
|
||||
}
|
||||
|
||||
//private:
|
||||
typedef Boost::asio::detail::consuming_buffers<mutable_buffer,
|
||||
MutableBufferSequence, MutableBufferIterator> buffers_type;
|
||||
|
||||
AsyncRandomAccessReadDevice& device_;
|
||||
uint64_t offset_;
|
||||
buffers_type buffers_;
|
||||
int start_;
|
||||
ReadHandler handler_;
|
||||
};
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice,
|
||||
typename MutableBufferSequence, typename MutableBufferIterator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
||||
MutableBufferIterator, CompletionCondition, ReadHandler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice,
|
||||
typename MutableBufferSequence, typename MutableBufferIterator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
||||
MutableBufferIterator, CompletionCondition, ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice,
|
||||
typename MutableBufferSequence, typename MutableBufferIterator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
||||
MutableBufferIterator, CompletionCondition, ReadHandler>* this_handler)
|
||||
{
|
||||
return this_handler->start_ == 0 ? true
|
||||
: Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename AsyncRandomAccessReadDevice,
|
||||
typename MutableBufferSequence, typename MutableBufferIterator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
||||
MutableBufferIterator, CompletionCondition, ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename AsyncRandomAccessReadDevice,
|
||||
typename MutableBufferSequence, typename MutableBufferIterator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
||||
MutableBufferIterator, CompletionCondition, ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice,
|
||||
typename MutableBufferSequence, typename MutableBufferIterator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
inline void start_read_at_op(AsyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, const MutableBufferSequence& buffers,
|
||||
const MutableBufferIterator&, CompletionCondition& completion_condition,
|
||||
ReadHandler& handler)
|
||||
{
|
||||
detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
||||
MutableBufferIterator, CompletionCondition, ReadHandler>(
|
||||
d, offset, buffers, completion_condition, handler)(
|
||||
Boost::system::error_code(), 0, 1);
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice>
|
||||
class initiate_async_read_at
|
||||
{
|
||||
public:
|
||||
typedef typename AsyncRandomAccessReadDevice::executor_type executor_type;
|
||||
|
||||
explicit initiate_async_read_at(AsyncRandomAccessReadDevice& device)
|
||||
: device_(device)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return device_.get_executor();
|
||||
}
|
||||
|
||||
template <typename ReadHandler, typename MutableBufferSequence,
|
||||
typename CompletionCondition>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
|
||||
uint64_t offset, const MutableBufferSequence& buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(CompletionCondition) completion_cond) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a ReadHandler.
|
||||
ACTIV_BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
non_const_lvalue<ReadHandler> handler2(handler);
|
||||
non_const_lvalue<CompletionCondition> completion_cond2(completion_cond);
|
||||
start_read_at_op(device_, offset, buffers,
|
||||
Boost::asio::buffer_sequence_begin(buffers),
|
||||
completion_cond2.value, handler2.value);
|
||||
}
|
||||
|
||||
private:
|
||||
AsyncRandomAccessReadDevice& device_;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
|
||||
typename MutableBufferIterator, typename CompletionCondition,
|
||||
typename ReadHandler, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
||||
MutableBufferIterator, CompletionCondition, ReadHandler>,
|
||||
DefaultCandidate>
|
||||
: Associator<ReadHandler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<ReadHandler, DefaultCandidate>::type
|
||||
get(const detail::read_at_op<AsyncRandomAccessReadDevice,
|
||||
MutableBufferSequence, MutableBufferIterator,
|
||||
CompletionCondition, ReadHandler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<ReadHandler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<ReadHandler, DefaultCandidate>::type)
|
||||
get(const detail::read_at_op<AsyncRandomAccessReadDevice,
|
||||
MutableBufferSequence, MutableBufferIterator,
|
||||
CompletionCondition, ReadHandler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice,
|
||||
typename MutableBufferSequence, typename CompletionCondition,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) ReadToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
async_read_at(AsyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, const MutableBufferSequence& buffers,
|
||||
CompletionCondition completion_condition,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(ReadToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<ReadToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_read_at<AsyncRandomAccessReadDevice> >(),
|
||||
token, offset, buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition))))
|
||||
{
|
||||
return async_initiate<ReadToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_read_at<AsyncRandomAccessReadDevice>(d),
|
||||
token, offset, buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition));
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) ReadToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
async_read_at(AsyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, const MutableBufferSequence& buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(ReadToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<ReadToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_read_at<AsyncRandomAccessReadDevice> >(),
|
||||
token, offset, buffers, transfer_all())))
|
||||
{
|
||||
return async_initiate<ReadToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_read_at<AsyncRandomAccessReadDevice>(d),
|
||||
token, offset, buffers, transfer_all());
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXTENSIONS)
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_IOSTREAM)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
class read_at_streambuf_op
|
||||
: public base_from_cancellation_state<ReadHandler>,
|
||||
base_from_completion_cond<CompletionCondition>
|
||||
{
|
||||
public:
|
||||
read_at_streambuf_op(AsyncRandomAccessReadDevice& device,
|
||||
uint64_t offset, basic_streambuf<Allocator>& streambuf,
|
||||
CompletionCondition& completion_condition, ReadHandler& handler)
|
||||
: base_from_cancellation_state<ReadHandler>(
|
||||
handler, enable_partial_cancellation()),
|
||||
base_from_completion_cond<CompletionCondition>(completion_condition),
|
||||
device_(device),
|
||||
offset_(offset),
|
||||
streambuf_(streambuf),
|
||||
start_(0),
|
||||
total_transferred_(0),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
read_at_streambuf_op(const read_at_streambuf_op& other)
|
||||
: base_from_cancellation_state<ReadHandler>(other),
|
||||
base_from_completion_cond<CompletionCondition>(other),
|
||||
device_(other.device_),
|
||||
offset_(other.offset_),
|
||||
streambuf_(other.streambuf_),
|
||||
start_(other.start_),
|
||||
total_transferred_(other.total_transferred_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
read_at_streambuf_op(read_at_streambuf_op&& other)
|
||||
: base_from_cancellation_state<ReadHandler>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(base_from_cancellation_state<
|
||||
ReadHandler>)(other)),
|
||||
base_from_completion_cond<CompletionCondition>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(base_from_completion_cond<
|
||||
CompletionCondition>)(other)),
|
||||
device_(other.device_),
|
||||
offset_(other.offset_),
|
||||
streambuf_(other.streambuf_),
|
||||
start_(other.start_),
|
||||
total_transferred_(other.total_transferred_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()(Boost::system::error_code ec,
|
||||
std::size_t bytes_transferred, int start = 0)
|
||||
{
|
||||
std::size_t max_size, bytes_available;
|
||||
switch (start_ = start)
|
||||
{
|
||||
case 1:
|
||||
max_size = this->check_for_completion(ec, total_transferred_);
|
||||
bytes_available = read_size_helper(streambuf_, max_size);
|
||||
for (;;)
|
||||
{
|
||||
{
|
||||
ACTIV_BOOST_ASIO_HANDLER_LOCATION((__FILE__, __LINE__, "async_read_at"));
|
||||
device_.async_read_some_at(offset_ + total_transferred_,
|
||||
streambuf_.prepare(bytes_available),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(read_at_streambuf_op)(*this));
|
||||
}
|
||||
return; default:
|
||||
total_transferred_ += bytes_transferred;
|
||||
streambuf_.commit(bytes_transferred);
|
||||
max_size = this->check_for_completion(ec, total_transferred_);
|
||||
bytes_available = read_size_helper(streambuf_, max_size);
|
||||
if ((!ec && bytes_transferred == 0) || bytes_available == 0)
|
||||
break;
|
||||
if (this->cancelled() != cancellation_type::none)
|
||||
{
|
||||
ec = Boost::asio::error::operation_aborted;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(ReadHandler)(handler_)(
|
||||
static_cast<const Boost::system::error_code&>(ec),
|
||||
static_cast<const std::size_t&>(total_transferred_));
|
||||
}
|
||||
}
|
||||
|
||||
//private:
|
||||
AsyncRandomAccessReadDevice& device_;
|
||||
uint64_t offset_;
|
||||
Boost::asio::basic_streambuf<Allocator>& streambuf_;
|
||||
int start_;
|
||||
std::size_t total_transferred_;
|
||||
ReadHandler handler_;
|
||||
};
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
||||
CompletionCondition, ReadHandler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
||||
CompletionCondition, ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
||||
typename CompletionCondition, typename ReadHandler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
||||
CompletionCondition, ReadHandler>* this_handler)
|
||||
{
|
||||
return this_handler->start_ == 0 ? true
|
||||
: Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename AsyncRandomAccessReadDevice,
|
||||
typename Allocator, typename CompletionCondition, typename ReadHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
||||
CompletionCondition, ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename AsyncRandomAccessReadDevice,
|
||||
typename Allocator, typename CompletionCondition, typename ReadHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
||||
CompletionCondition, ReadHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice>
|
||||
class initiate_async_read_at_streambuf
|
||||
{
|
||||
public:
|
||||
typedef typename AsyncRandomAccessReadDevice::executor_type executor_type;
|
||||
|
||||
explicit initiate_async_read_at_streambuf(
|
||||
AsyncRandomAccessReadDevice& device)
|
||||
: device_(device)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return device_.get_executor();
|
||||
}
|
||||
|
||||
template <typename ReadHandler,
|
||||
typename Allocator, typename CompletionCondition>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
|
||||
uint64_t offset, basic_streambuf<Allocator>* b,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(CompletionCondition) completion_cond) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a ReadHandler.
|
||||
ACTIV_BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
non_const_lvalue<ReadHandler> handler2(handler);
|
||||
non_const_lvalue<CompletionCondition> completion_cond2(completion_cond);
|
||||
read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
||||
CompletionCondition, typename decay<ReadHandler>::type>(
|
||||
device_, offset, *b, completion_cond2.value, handler2.value)(
|
||||
Boost::system::error_code(), 0, 1);
|
||||
}
|
||||
|
||||
private:
|
||||
AsyncRandomAccessReadDevice& device_;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename AsyncRandomAccessReadDevice, typename Executor,
|
||||
typename CompletionCondition, typename ReadHandler,
|
||||
typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::read_at_streambuf_op<AsyncRandomAccessReadDevice,
|
||||
Executor, CompletionCondition, ReadHandler>,
|
||||
DefaultCandidate>
|
||||
: Associator<ReadHandler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<ReadHandler, DefaultCandidate>::type
|
||||
get(const detail::read_at_streambuf_op<AsyncRandomAccessReadDevice,
|
||||
Executor, CompletionCondition, ReadHandler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<ReadHandler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<ReadHandler, DefaultCandidate>::type)
|
||||
get(const detail::read_at_streambuf_op<AsyncRandomAccessReadDevice,
|
||||
Executor, CompletionCondition, ReadHandler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice,
|
||||
typename Allocator, typename CompletionCondition,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) ReadToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
async_read_at(AsyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b,
|
||||
CompletionCondition completion_condition,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(ReadToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<ReadToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_read_at_streambuf<
|
||||
AsyncRandomAccessReadDevice> >(),
|
||||
token, offset, &b,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition))))
|
||||
{
|
||||
return async_initiate<ReadToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_read_at_streambuf<AsyncRandomAccessReadDevice>(d),
|
||||
token, offset, &b,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition));
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) ReadToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
async_read_at(AsyncRandomAccessReadDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(ReadToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<ReadToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_read_at_streambuf<
|
||||
AsyncRandomAccessReadDevice> >(),
|
||||
token, offset, &b, transfer_all())))
|
||||
{
|
||||
return async_initiate<ReadToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_read_at_streambuf<AsyncRandomAccessReadDevice>(d),
|
||||
token, offset, &b, transfer_all());
|
||||
}
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_IOSTREAM)
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_EXTENSIONS)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_READ_AT_HPP
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,620 +0,0 @@
|
||||
|
||||
// impl/redirect_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 ACTIV_BOOST_ASIO_IMPL_REDIRECT_ERROR_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_REDIRECT_ERROR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/associator.hpp>
|
||||
#include <ActivBoost/asio/async_result.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/type_traits.hpp>
|
||||
#include <ActivBoost/asio/detail/variadic_templates.hpp>
|
||||
#include <ActivBoost/system/system_error.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Class to adapt a redirect_error_t as a completion handler.
|
||||
template <typename Handler>
|
||||
class redirect_error_handler
|
||||
{
|
||||
public:
|
||||
typedef void result_type;
|
||||
|
||||
template <typename CompletionToken>
|
||||
redirect_error_handler(redirect_error_t<CompletionToken> e)
|
||||
: ec_(e.ec_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(CompletionToken)(e.token_))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename RedirectedHandler>
|
||||
redirect_error_handler(Boost::system::error_code& ec,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RedirectedHandler) h)
|
||||
: ec_(ec),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(RedirectedHandler)(h))
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)();
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Arg, typename... Args>
|
||||
typename enable_if<
|
||||
!is_same<typename decay<Arg>::type, Boost::system::error_code>::value
|
||||
>::type
|
||||
operator()(ACTIV_BOOST_ASIO_MOVE_ARG(Arg) arg, ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Arg)(arg),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(const Boost::system::error_code& ec,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ec_ = ec;
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Arg>
|
||||
typename enable_if<
|
||||
!is_same<typename decay<Arg>::type, Boost::system::error_code>::value
|
||||
>::type
|
||||
operator()(ACTIV_BOOST_ASIO_MOVE_ARG(Arg) arg)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Arg)(arg));
|
||||
}
|
||||
|
||||
void operator()(const Boost::system::error_code& ec)
|
||||
{
|
||||
ec_ = ec;
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)();
|
||||
}
|
||||
|
||||
#define ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF(n) \
|
||||
template <typename Arg, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
typename enable_if< \
|
||||
!is_same<typename decay<Arg>::type, Boost::system::error_code>::value \
|
||||
>::type \
|
||||
operator()(ACTIV_BOOST_ASIO_MOVE_ARG(Arg) arg, ACTIV_BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
|
||||
{ \
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)( \
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Arg)(arg), \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
|
||||
} \
|
||||
\
|
||||
template <ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
void operator()(const Boost::system::error_code& ec, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
|
||||
{ \
|
||||
ec_ = ec; \
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)( \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
|
||||
} \
|
||||
/**/
|
||||
ACTIV_BOOST_ASIO_VARIADIC_GENERATE(ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF)
|
||||
#undef ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
//private:
|
||||
Boost::system::error_code& ec_;
|
||||
Handler handler_;
|
||||
};
|
||||
|
||||
template <typename Handler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
redirect_error_handler<Handler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
redirect_error_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
redirect_error_handler<Handler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
redirect_error_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
redirect_error_handler<Handler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Signature>
|
||||
struct redirect_error_signature
|
||||
{
|
||||
typedef Signature type;
|
||||
};
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<R(Boost::system::error_code, Args...)>
|
||||
{
|
||||
typedef R type(Args...);
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<R(const Boost::system::error_code&, Args...)>
|
||||
{
|
||||
typedef R type(Args...);
|
||||
};
|
||||
|
||||
# if defined(ACTIV_BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<R(Boost::system::error_code, Args...) &>
|
||||
{
|
||||
typedef R type(Args...) &;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<R(const Boost::system::error_code&, Args...) &>
|
||||
{
|
||||
typedef R type(Args...) &;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<R(Boost::system::error_code, Args...) &&>
|
||||
{
|
||||
typedef R type(Args...) &&;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<R(const Boost::system::error_code&, Args...) &&>
|
||||
{
|
||||
typedef R type(Args...) &&;
|
||||
};
|
||||
|
||||
# if defined(ACTIV_BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<
|
||||
R(Boost::system::error_code, Args...) noexcept>
|
||||
{
|
||||
typedef R type(Args...) & noexcept;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<
|
||||
R(const Boost::system::error_code&, Args...) noexcept>
|
||||
{
|
||||
typedef R type(Args...) & noexcept;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<
|
||||
R(Boost::system::error_code, Args...) & noexcept>
|
||||
{
|
||||
typedef R type(Args...) & noexcept;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<
|
||||
R(const Boost::system::error_code&, Args...) & noexcept>
|
||||
{
|
||||
typedef R type(Args...) & noexcept;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<
|
||||
R(Boost::system::error_code, Args...) && noexcept>
|
||||
{
|
||||
typedef R type(Args...) && noexcept;
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct redirect_error_signature<
|
||||
R(const Boost::system::error_code&, Args...) && noexcept>
|
||||
{
|
||||
typedef R type(Args...) && noexcept;
|
||||
};
|
||||
|
||||
# endif // defined(ACTIV_BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
# endif // defined(ACTIV_BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<R(Boost::system::error_code)>
|
||||
{
|
||||
typedef R type();
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<R(const Boost::system::error_code&)>
|
||||
{
|
||||
typedef R type();
|
||||
};
|
||||
|
||||
#define ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF(n) \
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(Boost::system::error_code, ACTIV_BOOST_ASIO_VARIADIC_TARGS(n))> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)); \
|
||||
}; \
|
||||
\
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(const Boost::system::error_code&, ACTIV_BOOST_ASIO_VARIADIC_TARGS(n))> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)); \
|
||||
}; \
|
||||
/**/
|
||||
ACTIV_BOOST_ASIO_VARIADIC_GENERATE(ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF)
|
||||
#undef ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF
|
||||
|
||||
# if defined(ACTIV_BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<R(Boost::system::error_code) &>
|
||||
{
|
||||
typedef R type() &;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<R(const Boost::system::error_code&) &>
|
||||
{
|
||||
typedef R type() &;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<R(Boost::system::error_code) &&>
|
||||
{
|
||||
typedef R type() &&;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<R(const Boost::system::error_code&) &&>
|
||||
{
|
||||
typedef R type() &&;
|
||||
};
|
||||
|
||||
#define ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF(n) \
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(Boost::system::error_code, ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) &> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) &; \
|
||||
}; \
|
||||
\
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(const Boost::system::error_code&, ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) &> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) &; \
|
||||
}; \
|
||||
\
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(Boost::system::error_code, ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) &&> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) &&; \
|
||||
}; \
|
||||
\
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(const Boost::system::error_code&, ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) &&> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) &&; \
|
||||
}; \
|
||||
/**/
|
||||
ACTIV_BOOST_ASIO_VARIADIC_GENERATE(ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF)
|
||||
#undef ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF
|
||||
|
||||
# if defined(ACTIV_BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<
|
||||
R(Boost::system::error_code) noexcept>
|
||||
{
|
||||
typedef R type() noexcept;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<
|
||||
R(const Boost::system::error_code&) noexcept>
|
||||
{
|
||||
typedef R type() noexcept;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<
|
||||
R(Boost::system::error_code) & noexcept>
|
||||
{
|
||||
typedef R type() & noexcept;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<
|
||||
R(const Boost::system::error_code&) & noexcept>
|
||||
{
|
||||
typedef R type() & noexcept;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<
|
||||
R(Boost::system::error_code) && noexcept>
|
||||
{
|
||||
typedef R type() && noexcept;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct redirect_error_signature<
|
||||
R(const Boost::system::error_code&) && noexcept>
|
||||
{
|
||||
typedef R type() && noexcept;
|
||||
};
|
||||
|
||||
#define ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF(n) \
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(Boost::system::error_code, ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) noexcept> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) noexcept; \
|
||||
}; \
|
||||
\
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(const Boost::system::error_code&, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) noexcept> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) noexcept; \
|
||||
}; \
|
||||
\
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(Boost::system::error_code, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) & noexcept> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) & noexcept; \
|
||||
}; \
|
||||
\
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(const Boost::system::error_code&, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) & noexcept> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) & noexcept; \
|
||||
}; \
|
||||
\
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(Boost::system::error_code, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) && noexcept> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) && noexcept; \
|
||||
}; \
|
||||
\
|
||||
template <typename R, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
struct redirect_error_signature< \
|
||||
R(const Boost::system::error_code&, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) && noexcept> \
|
||||
{ \
|
||||
typedef R type(ACTIV_BOOST_ASIO_VARIADIC_TARGS(n)) && noexcept; \
|
||||
}; \
|
||||
/**/
|
||||
ACTIV_BOOST_ASIO_VARIADIC_GENERATE(ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF)
|
||||
#undef ACTIV_BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF
|
||||
|
||||
# endif // defined(ACTIV_BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
# endif // defined(ACTIV_BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename CompletionToken, typename Signature>
|
||||
struct async_result<redirect_error_t<CompletionToken>, Signature>
|
||||
{
|
||||
typedef typename async_result<CompletionToken,
|
||||
typename detail::redirect_error_signature<Signature>::type>
|
||||
::return_type return_type;
|
||||
|
||||
template <typename Initiation>
|
||||
struct init_wrapper
|
||||
{
|
||||
template <typename Init>
|
||||
init_wrapper(Boost::system::error_code& ec, ACTIV_BOOST_ASIO_MOVE_ARG(Init) init)
|
||||
: ec_(ec),
|
||||
initiation_(ACTIV_BOOST_ASIO_MOVE_CAST(Init)(init))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Handler, typename... Args>
|
||||
void operator()(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation_)(
|
||||
detail::redirect_error_handler<
|
||||
typename decay<Handler>::type>(
|
||||
ec_, ACTIV_BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Handler>
|
||||
void operator()(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Handler) handler)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation_)(
|
||||
detail::redirect_error_handler<
|
||||
typename decay<Handler>::type>(
|
||||
ec_, ACTIV_BOOST_ASIO_MOVE_CAST(Handler)(handler)));
|
||||
}
|
||||
|
||||
#define ACTIV_BOOST_ASIO_PRIVATE_INIT_WRAPPER_DEF(n) \
|
||||
template <typename Handler, ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
void operator()( \
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Handler) handler, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
|
||||
{ \
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation_)( \
|
||||
detail::redirect_error_handler< \
|
||||
typename decay<Handler>::type>( \
|
||||
ec_, ACTIV_BOOST_ASIO_MOVE_CAST(Handler)(handler)), \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
|
||||
} \
|
||||
/**/
|
||||
ACTIV_BOOST_ASIO_VARIADIC_GENERATE(ACTIV_BOOST_ASIO_PRIVATE_INIT_WRAPPER_DEF)
|
||||
#undef ACTIV_BOOST_ASIO_PRIVATE_INIT_WRAPPER_DEF
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
Boost::system::error_code& ec_;
|
||||
Initiation initiation_;
|
||||
};
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static return_type initiate(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RawCompletionToken) token,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
return async_initiate<CompletionToken,
|
||||
typename detail::redirect_error_signature<Signature>::type>(
|
||||
init_wrapper<typename decay<Initiation>::type>(
|
||||
token.ec_, ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation)),
|
||||
token.token_, ACTIV_BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
#else // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken>
|
||||
static return_type initiate(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RawCompletionToken) token)
|
||||
{
|
||||
return async_initiate<CompletionToken,
|
||||
typename detail::redirect_error_signature<Signature>::type>(
|
||||
init_wrapper<typename decay<Initiation>::type>(
|
||||
token.ec_, ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation)),
|
||||
token.token_);
|
||||
}
|
||||
|
||||
#define ACTIV_BOOST_ASIO_PRIVATE_INITIATE_DEF(n) \
|
||||
template <typename Initiation, typename RawCompletionToken, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
static return_type initiate( \
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Initiation) initiation, \
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(RawCompletionToken) token, \
|
||||
ACTIV_BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
|
||||
{ \
|
||||
return async_initiate<CompletionToken, \
|
||||
typename detail::redirect_error_signature<Signature>::type>( \
|
||||
init_wrapper<typename decay<Initiation>::type>( \
|
||||
token.ec_, ACTIV_BOOST_ASIO_MOVE_CAST(Initiation)(initiation)), \
|
||||
token.token_, ACTIV_BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
|
||||
} \
|
||||
/**/
|
||||
ACTIV_BOOST_ASIO_VARIADIC_GENERATE(ACTIV_BOOST_ASIO_PRIVATE_INITIATE_DEF)
|
||||
#undef ACTIV_BOOST_ASIO_PRIVATE_INITIATE_DEF
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
};
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename Handler, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::redirect_error_handler<Handler>, DefaultCandidate>
|
||||
: Associator<Handler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<Handler, DefaultCandidate>::type
|
||||
get(const detail::redirect_error_handler<Handler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<Handler, DefaultCandidate>::type)
|
||||
get(const detail::redirect_error_handler<Handler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<Handler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_REDIRECT_ERROR_HPP
|
||||
@@ -1,61 +0,0 @@
|
||||
//
|
||||
// impl/serial_port_base.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.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 ACTIV_BOOST_ASIO_IMPL_SERIAL_PORT_BASE_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_SERIAL_PORT_BASE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
inline serial_port_base::baud_rate::baud_rate(unsigned int rate)
|
||||
: value_(rate)
|
||||
{
|
||||
}
|
||||
|
||||
inline unsigned int serial_port_base::baud_rate::value() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
inline serial_port_base::flow_control::type
|
||||
serial_port_base::flow_control::value() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
inline serial_port_base::parity::type serial_port_base::parity::value() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
inline serial_port_base::stop_bits::type
|
||||
serial_port_base::stop_bits::value() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
inline unsigned int serial_port_base::character_size::value() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_SERIAL_PORT_BASE_HPP
|
||||
@@ -1,556 +0,0 @@
|
||||
//
|
||||
// impl/serial_port_base.ipp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.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 ACTIV_BOOST_ASIO_IMPL_SERIAL_PORT_BASE_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_SERIAL_PORT_BASE_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_SERIAL_PORT)
|
||||
|
||||
#include <stdexcept>
|
||||
#include <ActivBoost/asio/error.hpp>
|
||||
#include <ActivBoost/asio/serial_port_base.hpp>
|
||||
#include <ActivBoost/asio/detail/throw_exception.hpp>
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
# define ACTIV_BOOST_ASIO_OPTION_STORAGE implementation_defined
|
||||
#elif defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
# define ACTIV_BOOST_ASIO_OPTION_STORAGE DCB
|
||||
#else
|
||||
# define ACTIV_BOOST_ASIO_OPTION_STORAGE termios
|
||||
#endif
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID serial_port_base::baud_rate::store(
|
||||
ACTIV_BOOST_ASIO_OPTION_STORAGE& storage, Boost::system::error_code& ec) const
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
storage.BaudRate = value_;
|
||||
#else
|
||||
speed_t baud;
|
||||
switch (value_)
|
||||
{
|
||||
// Do POSIX-specified rates first.
|
||||
case 0: baud = B0; break;
|
||||
case 50: baud = B50; break;
|
||||
case 75: baud = B75; break;
|
||||
case 110: baud = B110; break;
|
||||
case 134: baud = B134; break;
|
||||
case 150: baud = B150; break;
|
||||
case 200: baud = B200; break;
|
||||
case 300: baud = B300; break;
|
||||
case 600: baud = B600; break;
|
||||
case 1200: baud = B1200; break;
|
||||
case 1800: baud = B1800; break;
|
||||
case 2400: baud = B2400; break;
|
||||
case 4800: baud = B4800; break;
|
||||
case 9600: baud = B9600; break;
|
||||
case 19200: baud = B19200; break;
|
||||
case 38400: baud = B38400; break;
|
||||
// And now the extended ones conditionally.
|
||||
# ifdef B7200
|
||||
case 7200: baud = B7200; break;
|
||||
# endif
|
||||
# ifdef B14400
|
||||
case 14400: baud = B14400; break;
|
||||
# endif
|
||||
# ifdef B57600
|
||||
case 57600: baud = B57600; break;
|
||||
# endif
|
||||
# ifdef B115200
|
||||
case 115200: baud = B115200; break;
|
||||
# endif
|
||||
# ifdef B230400
|
||||
case 230400: baud = B230400; break;
|
||||
# endif
|
||||
# ifdef B460800
|
||||
case 460800: baud = B460800; break;
|
||||
# endif
|
||||
# ifdef B500000
|
||||
case 500000: baud = B500000; break;
|
||||
# endif
|
||||
# ifdef B576000
|
||||
case 576000: baud = B576000; break;
|
||||
# endif
|
||||
# ifdef B921600
|
||||
case 921600: baud = B921600; break;
|
||||
# endif
|
||||
# ifdef B1000000
|
||||
case 1000000: baud = B1000000; break;
|
||||
# endif
|
||||
# ifdef B1152000
|
||||
case 1152000: baud = B1152000; break;
|
||||
# endif
|
||||
# ifdef B2000000
|
||||
case 2000000: baud = B2000000; break;
|
||||
# endif
|
||||
# ifdef B3000000
|
||||
case 3000000: baud = B3000000; break;
|
||||
# endif
|
||||
# ifdef B3500000
|
||||
case 3500000: baud = B3500000; break;
|
||||
# endif
|
||||
# ifdef B4000000
|
||||
case 4000000: baud = B4000000; break;
|
||||
# endif
|
||||
default:
|
||||
ec = Boost::asio::error::invalid_argument;
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
# if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE)
|
||||
::cfsetspeed(&storage, baud);
|
||||
# else
|
||||
::cfsetispeed(&storage, baud);
|
||||
::cfsetospeed(&storage, baud);
|
||||
# endif
|
||||
#endif
|
||||
ec = Boost::system::error_code();
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID serial_port_base::baud_rate::load(
|
||||
const ACTIV_BOOST_ASIO_OPTION_STORAGE& storage, Boost::system::error_code& ec)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
value_ = storage.BaudRate;
|
||||
#else
|
||||
speed_t baud = ::cfgetospeed(&storage);
|
||||
switch (baud)
|
||||
{
|
||||
// First do those specified by POSIX.
|
||||
case B0: value_ = 0; break;
|
||||
case B50: value_ = 50; break;
|
||||
case B75: value_ = 75; break;
|
||||
case B110: value_ = 110; break;
|
||||
case B134: value_ = 134; break;
|
||||
case B150: value_ = 150; break;
|
||||
case B200: value_ = 200; break;
|
||||
case B300: value_ = 300; break;
|
||||
case B600: value_ = 600; break;
|
||||
case B1200: value_ = 1200; break;
|
||||
case B1800: value_ = 1800; break;
|
||||
case B2400: value_ = 2400; break;
|
||||
case B4800: value_ = 4800; break;
|
||||
case B9600: value_ = 9600; break;
|
||||
case B19200: value_ = 19200; break;
|
||||
case B38400: value_ = 38400; break;
|
||||
// Now conditionally handle a bunch of extended rates.
|
||||
# ifdef B7200
|
||||
case B7200: value_ = 7200; break;
|
||||
# endif
|
||||
# ifdef B14400
|
||||
case B14400: value_ = 14400; break;
|
||||
# endif
|
||||
# ifdef B57600
|
||||
case B57600: value_ = 57600; break;
|
||||
# endif
|
||||
# ifdef B115200
|
||||
case B115200: value_ = 115200; break;
|
||||
# endif
|
||||
# ifdef B230400
|
||||
case B230400: value_ = 230400; break;
|
||||
# endif
|
||||
# ifdef B460800
|
||||
case B460800: value_ = 460800; break;
|
||||
# endif
|
||||
# ifdef B500000
|
||||
case B500000: value_ = 500000; break;
|
||||
# endif
|
||||
# ifdef B576000
|
||||
case B576000: value_ = 576000; break;
|
||||
# endif
|
||||
# ifdef B921600
|
||||
case B921600: value_ = 921600; break;
|
||||
# endif
|
||||
# ifdef B1000000
|
||||
case B1000000: value_ = 1000000; break;
|
||||
# endif
|
||||
# ifdef B1152000
|
||||
case B1152000: value_ = 1152000; break;
|
||||
# endif
|
||||
# ifdef B2000000
|
||||
case B2000000: value_ = 2000000; break;
|
||||
# endif
|
||||
# ifdef B3000000
|
||||
case B3000000: value_ = 3000000; break;
|
||||
# endif
|
||||
# ifdef B3500000
|
||||
case B3500000: value_ = 3500000; break;
|
||||
# endif
|
||||
# ifdef B4000000
|
||||
case B4000000: value_ = 4000000; break;
|
||||
# endif
|
||||
default:
|
||||
value_ = 0;
|
||||
ec = Boost::asio::error::invalid_argument;
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
#endif
|
||||
ec = Boost::system::error_code();
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
serial_port_base::flow_control::flow_control(
|
||||
serial_port_base::flow_control::type t)
|
||||
: value_(t)
|
||||
{
|
||||
if (t != none && t != software && t != hardware)
|
||||
{
|
||||
std::out_of_range ex("invalid flow_control value");
|
||||
Boost::asio::detail::throw_exception(ex);
|
||||
}
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID serial_port_base::flow_control::store(
|
||||
ACTIV_BOOST_ASIO_OPTION_STORAGE& storage, Boost::system::error_code& ec) const
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
storage.fOutxCtsFlow = FALSE;
|
||||
storage.fOutxDsrFlow = FALSE;
|
||||
storage.fTXContinueOnXoff = TRUE;
|
||||
storage.fDtrControl = DTR_CONTROL_ENABLE;
|
||||
storage.fDsrSensitivity = FALSE;
|
||||
storage.fOutX = FALSE;
|
||||
storage.fInX = FALSE;
|
||||
storage.fRtsControl = RTS_CONTROL_ENABLE;
|
||||
switch (value_)
|
||||
{
|
||||
case none:
|
||||
break;
|
||||
case software:
|
||||
storage.fOutX = TRUE;
|
||||
storage.fInX = TRUE;
|
||||
break;
|
||||
case hardware:
|
||||
storage.fOutxCtsFlow = TRUE;
|
||||
storage.fRtsControl = RTS_CONTROL_HANDSHAKE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch (value_)
|
||||
{
|
||||
case none:
|
||||
storage.c_iflag &= ~(IXOFF | IXON);
|
||||
# if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE)
|
||||
storage.c_cflag &= ~CRTSCTS;
|
||||
# elif defined(__QNXNTO__)
|
||||
storage.c_cflag &= ~(IHFLOW | OHFLOW);
|
||||
# endif
|
||||
break;
|
||||
case software:
|
||||
storage.c_iflag |= IXOFF | IXON;
|
||||
# if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE)
|
||||
storage.c_cflag &= ~CRTSCTS;
|
||||
# elif defined(__QNXNTO__)
|
||||
storage.c_cflag &= ~(IHFLOW | OHFLOW);
|
||||
# endif
|
||||
break;
|
||||
case hardware:
|
||||
# if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE)
|
||||
storage.c_iflag &= ~(IXOFF | IXON);
|
||||
storage.c_cflag |= CRTSCTS;
|
||||
break;
|
||||
# elif defined(__QNXNTO__)
|
||||
storage.c_iflag &= ~(IXOFF | IXON);
|
||||
storage.c_cflag |= (IHFLOW | OHFLOW);
|
||||
break;
|
||||
# else
|
||||
ec = Boost::asio::error::operation_not_supported;
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
# endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
ec = Boost::system::error_code();
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID serial_port_base::flow_control::load(
|
||||
const ACTIV_BOOST_ASIO_OPTION_STORAGE& storage, Boost::system::error_code& ec)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
if (storage.fOutX && storage.fInX)
|
||||
{
|
||||
value_ = software;
|
||||
}
|
||||
else if (storage.fOutxCtsFlow && storage.fRtsControl == RTS_CONTROL_HANDSHAKE)
|
||||
{
|
||||
value_ = hardware;
|
||||
}
|
||||
else
|
||||
{
|
||||
value_ = none;
|
||||
}
|
||||
#else
|
||||
if (storage.c_iflag & (IXOFF | IXON))
|
||||
{
|
||||
value_ = software;
|
||||
}
|
||||
# if defined(_BSD_SOURCE) || defined(_DEFAULT_SOURCE)
|
||||
else if (storage.c_cflag & CRTSCTS)
|
||||
{
|
||||
value_ = hardware;
|
||||
}
|
||||
# elif defined(__QNXNTO__)
|
||||
else if (storage.c_cflag & IHFLOW && storage.c_cflag & OHFLOW)
|
||||
{
|
||||
value_ = hardware;
|
||||
}
|
||||
# endif
|
||||
else
|
||||
{
|
||||
value_ = none;
|
||||
}
|
||||
#endif
|
||||
ec = Boost::system::error_code();
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
serial_port_base::parity::parity(serial_port_base::parity::type t)
|
||||
: value_(t)
|
||||
{
|
||||
if (t != none && t != odd && t != even)
|
||||
{
|
||||
std::out_of_range ex("invalid parity value");
|
||||
Boost::asio::detail::throw_exception(ex);
|
||||
}
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID serial_port_base::parity::store(
|
||||
ACTIV_BOOST_ASIO_OPTION_STORAGE& storage, Boost::system::error_code& ec) const
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
switch (value_)
|
||||
{
|
||||
case none:
|
||||
storage.fParity = FALSE;
|
||||
storage.Parity = NOPARITY;
|
||||
break;
|
||||
case odd:
|
||||
storage.fParity = TRUE;
|
||||
storage.Parity = ODDPARITY;
|
||||
break;
|
||||
case even:
|
||||
storage.fParity = TRUE;
|
||||
storage.Parity = EVENPARITY;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch (value_)
|
||||
{
|
||||
case none:
|
||||
storage.c_iflag |= IGNPAR;
|
||||
storage.c_cflag &= ~(PARENB | PARODD);
|
||||
break;
|
||||
case even:
|
||||
storage.c_iflag &= ~(IGNPAR | PARMRK);
|
||||
storage.c_iflag |= INPCK;
|
||||
storage.c_cflag |= PARENB;
|
||||
storage.c_cflag &= ~PARODD;
|
||||
break;
|
||||
case odd:
|
||||
storage.c_iflag &= ~(IGNPAR | PARMRK);
|
||||
storage.c_iflag |= INPCK;
|
||||
storage.c_cflag |= (PARENB | PARODD);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
ec = Boost::system::error_code();
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID serial_port_base::parity::load(
|
||||
const ACTIV_BOOST_ASIO_OPTION_STORAGE& storage, Boost::system::error_code& ec)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
if (storage.Parity == EVENPARITY)
|
||||
{
|
||||
value_ = even;
|
||||
}
|
||||
else if (storage.Parity == ODDPARITY)
|
||||
{
|
||||
value_ = odd;
|
||||
}
|
||||
else
|
||||
{
|
||||
value_ = none;
|
||||
}
|
||||
#else
|
||||
if (storage.c_cflag & PARENB)
|
||||
{
|
||||
if (storage.c_cflag & PARODD)
|
||||
{
|
||||
value_ = odd;
|
||||
}
|
||||
else
|
||||
{
|
||||
value_ = even;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value_ = none;
|
||||
}
|
||||
#endif
|
||||
ec = Boost::system::error_code();
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
serial_port_base::stop_bits::stop_bits(
|
||||
serial_port_base::stop_bits::type t)
|
||||
: value_(t)
|
||||
{
|
||||
if (t != one && t != onepointfive && t != two)
|
||||
{
|
||||
std::out_of_range ex("invalid stop_bits value");
|
||||
Boost::asio::detail::throw_exception(ex);
|
||||
}
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID serial_port_base::stop_bits::store(
|
||||
ACTIV_BOOST_ASIO_OPTION_STORAGE& storage, Boost::system::error_code& ec) const
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
switch (value_)
|
||||
{
|
||||
case one:
|
||||
storage.StopBits = ONESTOPBIT;
|
||||
break;
|
||||
case onepointfive:
|
||||
storage.StopBits = ONE5STOPBITS;
|
||||
break;
|
||||
case two:
|
||||
storage.StopBits = TWOSTOPBITS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch (value_)
|
||||
{
|
||||
case one:
|
||||
storage.c_cflag &= ~CSTOPB;
|
||||
break;
|
||||
case two:
|
||||
storage.c_cflag |= CSTOPB;
|
||||
break;
|
||||
default:
|
||||
ec = Boost::asio::error::operation_not_supported;
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
#endif
|
||||
ec = Boost::system::error_code();
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID serial_port_base::stop_bits::load(
|
||||
const ACTIV_BOOST_ASIO_OPTION_STORAGE& storage, Boost::system::error_code& ec)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
if (storage.StopBits == ONESTOPBIT)
|
||||
{
|
||||
value_ = one;
|
||||
}
|
||||
else if (storage.StopBits == ONE5STOPBITS)
|
||||
{
|
||||
value_ = onepointfive;
|
||||
}
|
||||
else if (storage.StopBits == TWOSTOPBITS)
|
||||
{
|
||||
value_ = two;
|
||||
}
|
||||
else
|
||||
{
|
||||
value_ = one;
|
||||
}
|
||||
#else
|
||||
value_ = (storage.c_cflag & CSTOPB) ? two : one;
|
||||
#endif
|
||||
ec = Boost::system::error_code();
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
serial_port_base::character_size::character_size(unsigned int t)
|
||||
: value_(t)
|
||||
{
|
||||
if (t < 5 || t > 8)
|
||||
{
|
||||
std::out_of_range ex("invalid character_size value");
|
||||
Boost::asio::detail::throw_exception(ex);
|
||||
}
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID serial_port_base::character_size::store(
|
||||
ACTIV_BOOST_ASIO_OPTION_STORAGE& storage, Boost::system::error_code& ec) const
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
storage.ByteSize = value_;
|
||||
#else
|
||||
storage.c_cflag &= ~CSIZE;
|
||||
switch (value_)
|
||||
{
|
||||
case 5: storage.c_cflag |= CS5; break;
|
||||
case 6: storage.c_cflag |= CS6; break;
|
||||
case 7: storage.c_cflag |= CS7; break;
|
||||
case 8: storage.c_cflag |= CS8; break;
|
||||
default: break;
|
||||
}
|
||||
#endif
|
||||
ec = Boost::system::error_code();
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID serial_port_base::character_size::load(
|
||||
const ACTIV_BOOST_ASIO_OPTION_STORAGE& storage, Boost::system::error_code& ec)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
value_ = storage.ByteSize;
|
||||
#else
|
||||
if ((storage.c_cflag & CSIZE) == CS5) { value_ = 5; }
|
||||
else if ((storage.c_cflag & CSIZE) == CS6) { value_ = 6; }
|
||||
else if ((storage.c_cflag & CSIZE) == CS7) { value_ = 7; }
|
||||
else if ((storage.c_cflag & CSIZE) == CS8) { value_ = 8; }
|
||||
else
|
||||
{
|
||||
// Hmmm, use 8 for now.
|
||||
value_ = 8;
|
||||
}
|
||||
#endif
|
||||
ec = Boost::system::error_code();
|
||||
ACTIV_BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#undef ACTIV_BOOST_ASIO_OPTION_STORAGE
|
||||
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_SERIAL_PORT)
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_SERIAL_PORT_BASE_IPP
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,95 +0,0 @@
|
||||
//
|
||||
// impl/src.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 ACTIV_BOOST_ASIO_IMPL_SRC_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_SRC_HPP
|
||||
|
||||
#define ACTIV_BOOST_ASIO_SOURCE
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HEADER_ONLY)
|
||||
# error Do not compile Asio library source with ACTIV_BOOST_ASIO_HEADER_ONLY defined
|
||||
#endif
|
||||
|
||||
#include <ActivBoost/asio/impl/any_completion_executor.ipp>
|
||||
#include <ActivBoost/asio/impl/any_io_executor.ipp>
|
||||
#include <ActivBoost/asio/impl/cancellation_signal.ipp>
|
||||
#include <ActivBoost/asio/impl/connect_pipe.ipp>
|
||||
#include <ActivBoost/asio/impl/error.ipp>
|
||||
#include <ActivBoost/asio/impl/execution_context.ipp>
|
||||
#include <ActivBoost/asio/impl/executor.ipp>
|
||||
#include <ActivBoost/asio/impl/handler_alloc_hook.ipp>
|
||||
#include <ActivBoost/asio/impl/io_context.ipp>
|
||||
#include <ActivBoost/asio/impl/multiple_exceptions.ipp>
|
||||
#include <ActivBoost/asio/impl/serial_port_base.ipp>
|
||||
#include <ActivBoost/asio/impl/system_context.ipp>
|
||||
#include <ActivBoost/asio/impl/thread_pool.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/buffer_sequence_adapter.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/descriptor_ops.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/dev_poll_reactor.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/epoll_reactor.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/eventfd_select_interrupter.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/handler_tracking.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/io_uring_descriptor_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/io_uring_file_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/io_uring_socket_service_base.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/io_uring_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/kqueue_reactor.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/null_event.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/pipe_select_interrupter.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/posix_event.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/posix_mutex.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/posix_serial_port_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/posix_thread.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/posix_tss_ptr.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/reactive_descriptor_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/reactive_socket_service_base.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/resolver_service_base.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/scheduler.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/select_reactor.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/service_registry.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/signal_set_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/socket_ops.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/socket_select_interrupter.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/strand_executor_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/strand_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/thread_context.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/throw_error.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/timer_queue_ptime.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/timer_queue_set.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_iocp_file_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_iocp_handle_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_iocp_io_context.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_iocp_serial_port_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_iocp_socket_service_base.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_event.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_mutex.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_object_handle_service.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_static_mutex.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_thread.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/win_tss_ptr.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/winrt_ssocket_service_base.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/winrt_timer_scheduler.ipp>
|
||||
#include <ActivBoost/asio/detail/impl/winsock_init.ipp>
|
||||
#include <ActivBoost/asio/execution/impl/bad_executor.ipp>
|
||||
#include <ActivBoost/asio/execution/impl/receiver_invocation_error.ipp>
|
||||
#include <ActivBoost/asio/experimental/impl/channel_error.ipp>
|
||||
#include <ActivBoost/asio/generic/detail/impl/endpoint.ipp>
|
||||
#include <ActivBoost/asio/ip/impl/address.ipp>
|
||||
#include <ActivBoost/asio/ip/impl/address_v4.ipp>
|
||||
#include <ActivBoost/asio/ip/impl/address_v6.ipp>
|
||||
#include <ActivBoost/asio/ip/impl/host_name.ipp>
|
||||
#include <ActivBoost/asio/ip/impl/network_v4.ipp>
|
||||
#include <ActivBoost/asio/ip/impl/network_v6.ipp>
|
||||
#include <ActivBoost/asio/ip/detail/impl/endpoint.ipp>
|
||||
#include <ActivBoost/asio/local/detail/impl/endpoint.ipp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_SRC_HPP
|
||||
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// impl/system_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 ACTIV_BOOST_ASIO_IMPL_SYSTEM_CONTEXT_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_SYSTEM_CONTEXT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/system_executor.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
inline system_context::executor_type
|
||||
system_context::get_executor() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return system_executor();
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_SYSTEM_CONTEXT_HPP
|
||||
@@ -1,94 +0,0 @@
|
||||
//
|
||||
// impl/system_context.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 ACTIV_BOOST_ASIO_IMPL_SYSTEM_CONTEXT_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_SYSTEM_CONTEXT_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/system_context.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
struct system_context::thread_function
|
||||
{
|
||||
detail::scheduler* scheduler_;
|
||||
|
||||
void operator()()
|
||||
{
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
try
|
||||
{
|
||||
#endif// !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
Boost::system::error_code ec;
|
||||
scheduler_->run(ec);
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::terminate();
|
||||
}
|
||||
#endif// !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
};
|
||||
|
||||
system_context::system_context()
|
||||
: scheduler_(add_scheduler(new detail::scheduler(*this, 0, false)))
|
||||
{
|
||||
scheduler_.work_started();
|
||||
|
||||
thread_function f = { &scheduler_ };
|
||||
num_threads_ = detail::thread::hardware_concurrency() * 2;
|
||||
num_threads_ = num_threads_ ? num_threads_ : 2;
|
||||
threads_.create_threads(f, num_threads_);
|
||||
}
|
||||
|
||||
system_context::~system_context()
|
||||
{
|
||||
scheduler_.work_finished();
|
||||
scheduler_.stop();
|
||||
threads_.join();
|
||||
}
|
||||
|
||||
void system_context::stop()
|
||||
{
|
||||
scheduler_.stop();
|
||||
}
|
||||
|
||||
bool system_context::stopped() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return scheduler_.stopped();
|
||||
}
|
||||
|
||||
void system_context::join()
|
||||
{
|
||||
scheduler_.work_finished();
|
||||
threads_.join();
|
||||
}
|
||||
|
||||
detail::scheduler& system_context::add_scheduler(detail::scheduler* s)
|
||||
{
|
||||
detail::scoped_ptr<detail::scheduler> scoped_impl(s);
|
||||
Boost::asio::add_service<detail::scheduler>(*this, scoped_impl.get());
|
||||
return *scoped_impl.release();
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_SYSTEM_CONTEXT_IPP
|
||||
@@ -1,187 +0,0 @@
|
||||
//
|
||||
// impl/system_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 ACTIV_BOOST_ASIO_IMPL_SYSTEM_EXECUTOR_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_SYSTEM_EXECUTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/executor_op.hpp>
|
||||
#include <ActivBoost/asio/detail/global.hpp>
|
||||
#include <ActivBoost/asio/detail/type_traits.hpp>
|
||||
#include <ActivBoost/asio/system_context.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
template <typename Blocking, typename Relationship, typename Allocator>
|
||||
inline system_context&
|
||||
basic_system_executor<Blocking, Relationship, Allocator>::query(
|
||||
execution::context_t) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return detail::global<system_context>();
|
||||
}
|
||||
|
||||
template <typename Blocking, typename Relationship, typename Allocator>
|
||||
inline std::size_t
|
||||
basic_system_executor<Blocking, Relationship, Allocator>::query(
|
||||
execution::occupancy_t) const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return detail::global<system_context>().num_threads_;
|
||||
}
|
||||
|
||||
template <typename Blocking, typename Relationship, typename Allocator>
|
||||
template <typename Function>
|
||||
inline void
|
||||
basic_system_executor<Blocking, Relationship, Allocator>::do_execute(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, execution::blocking_t::possibly_t) const
|
||||
{
|
||||
// Obtain a non-const instance of the function.
|
||||
detail::non_const_lvalue<Function> f2(f);
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
try
|
||||
{
|
||||
#endif// !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
detail::fenced_block b(detail::fenced_block::full);
|
||||
Boost_asio_handler_invoke_helpers::invoke(f2.value, f2.value);
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::terminate();
|
||||
}
|
||||
#endif// !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
|
||||
template <typename Blocking, typename Relationship, typename Allocator>
|
||||
template <typename Function>
|
||||
inline void
|
||||
basic_system_executor<Blocking, Relationship, Allocator>::do_execute(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, execution::blocking_t::always_t) const
|
||||
{
|
||||
// Obtain a non-const instance of the function.
|
||||
detail::non_const_lvalue<Function> f2(f);
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
try
|
||||
{
|
||||
#endif// !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
detail::fenced_block b(detail::fenced_block::full);
|
||||
Boost_asio_handler_invoke_helpers::invoke(f2.value, f2.value);
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::terminate();
|
||||
}
|
||||
#endif// !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
|
||||
template <typename Blocking, typename Relationship, typename Allocator>
|
||||
template <typename Function>
|
||||
void basic_system_executor<Blocking, Relationship, Allocator>::do_execute(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, execution::blocking_t::never_t) const
|
||||
{
|
||||
system_context& ctx = detail::global<system_context>();
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef typename decay<Function>::type function_type;
|
||||
typedef detail::executor_op<function_type, Allocator> op;
|
||||
typename op::ptr p = { detail::addressof(allocator_),
|
||||
op::ptr::allocate(allocator_), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), allocator_);
|
||||
|
||||
if (is_same<Relationship, execution::relationship_t::continuation_t>::value)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((ctx, *p.p,
|
||||
"system_executor", &ctx, 0, "execute(blk=never,rel=cont)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((ctx, *p.p,
|
||||
"system_executor", &ctx, 0, "execute(blk=never,rel=fork)"));
|
||||
}
|
||||
|
||||
ctx.scheduler_.post_immediate_completion(p.p,
|
||||
is_same<Relationship, execution::relationship_t::continuation_t>::value);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
template <typename Blocking, typename Relationship, typename Allocator>
|
||||
inline system_context& basic_system_executor<
|
||||
Blocking, Relationship, Allocator>::context() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return detail::global<system_context>();
|
||||
}
|
||||
|
||||
template <typename Blocking, typename Relationship, typename Allocator>
|
||||
template <typename Function, typename OtherAllocator>
|
||||
void basic_system_executor<Blocking, Relationship, Allocator>::dispatch(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator&) const
|
||||
{
|
||||
typename decay<Function>::type tmp(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f));
|
||||
Boost_asio_handler_invoke_helpers::invoke(tmp, tmp);
|
||||
}
|
||||
|
||||
template <typename Blocking, typename Relationship, typename Allocator>
|
||||
template <typename Function, typename OtherAllocator>
|
||||
void basic_system_executor<Blocking, Relationship, Allocator>::post(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
system_context& ctx = detail::global<system_context>();
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef detail::executor_op<function_type, OtherAllocator> op;
|
||||
typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a);
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((ctx, *p.p,
|
||||
"system_executor", &this->context(), 0, "post"));
|
||||
|
||||
ctx.scheduler_.post_immediate_completion(p.p, false);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
|
||||
template <typename Blocking, typename Relationship, typename Allocator>
|
||||
template <typename Function, typename OtherAllocator>
|
||||
void basic_system_executor<Blocking, Relationship, Allocator>::defer(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
system_context& ctx = detail::global<system_context>();
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef detail::executor_op<function_type, OtherAllocator> op;
|
||||
typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a);
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((ctx, *p.p,
|
||||
"system_executor", &this->context(), 0, "defer"));
|
||||
|
||||
ctx.scheduler_.post_immediate_completion(p.p, true);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_SYSTEM_EXECUTOR_HPP
|
||||
@@ -1,356 +0,0 @@
|
||||
//
|
||||
// impl/thread_pool.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 ACTIV_BOOST_ASIO_IMPL_THREAD_POOL_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_THREAD_POOL_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/blocking_executor_op.hpp>
|
||||
#include <ActivBoost/asio/detail/bulk_executor_op.hpp>
|
||||
#include <ActivBoost/asio/detail/executor_op.hpp>
|
||||
#include <ActivBoost/asio/detail/fenced_block.hpp>
|
||||
#include <ActivBoost/asio/detail/non_const_lvalue.hpp>
|
||||
#include <ActivBoost/asio/detail/type_traits.hpp>
|
||||
#include <ActivBoost/asio/execution_context.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
inline thread_pool::executor_type
|
||||
thread_pool::get_executor() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return executor_type(*this);
|
||||
}
|
||||
|
||||
inline thread_pool::executor_type
|
||||
thread_pool::executor() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return executor_type(*this);
|
||||
}
|
||||
|
||||
inline thread_pool::scheduler_type
|
||||
thread_pool::scheduler() ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return scheduler_type(*this);
|
||||
}
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
thread_pool::basic_executor_type<Allocator, Bits>&
|
||||
thread_pool::basic_executor_type<Allocator, Bits>::operator=(
|
||||
const basic_executor_type& other) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
thread_pool* old_thread_pool = pool_;
|
||||
pool_ = other.pool_;
|
||||
allocator_ = other.allocator_;
|
||||
bits_ = other.bits_;
|
||||
if (Bits & outstanding_work_tracked)
|
||||
{
|
||||
if (pool_)
|
||||
pool_->scheduler_.work_started();
|
||||
if (old_thread_pool)
|
||||
old_thread_pool->scheduler_.work_finished();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
thread_pool::basic_executor_type<Allocator, Bits>&
|
||||
thread_pool::basic_executor_type<Allocator, Bits>::operator=(
|
||||
basic_executor_type&& other) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
thread_pool* old_thread_pool = pool_;
|
||||
pool_ = other.pool_;
|
||||
allocator_ = std::move(other.allocator_);
|
||||
bits_ = other.bits_;
|
||||
if (Bits & outstanding_work_tracked)
|
||||
{
|
||||
other.pool_ = 0;
|
||||
if (old_thread_pool)
|
||||
old_thread_pool->scheduler_.work_finished();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
inline bool thread_pool::basic_executor_type<Allocator,
|
||||
Bits>::running_in_this_thread() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return pool_->scheduler_.can_dispatch();
|
||||
}
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
template <typename Function>
|
||||
void thread_pool::basic_executor_type<Allocator,
|
||||
Bits>::do_execute(ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, false_type) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
// Invoke immediately if the blocking.possibly property is enabled and we are
|
||||
// already inside the thread pool.
|
||||
if ((bits_ & blocking_never) == 0 && pool_->scheduler_.can_dispatch())
|
||||
{
|
||||
// Make a local, non-const copy of the function.
|
||||
function_type tmp(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f));
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_STD_EXCEPTION_PTR) \
|
||||
&& !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
try
|
||||
{
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
// && !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
detail::fenced_block b(detail::fenced_block::full);
|
||||
Boost_asio_handler_invoke_helpers::invoke(tmp, tmp);
|
||||
return;
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_STD_EXCEPTION_PTR) \
|
||||
&& !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
pool_->scheduler_.capture_current_exception();
|
||||
return;
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
|
||||
// && !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef detail::executor_op<function_type, Allocator> op;
|
||||
typename op::ptr p = { detail::addressof(allocator_),
|
||||
op::ptr::allocate(allocator_), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), allocator_);
|
||||
|
||||
if ((bits_ & relationship_continuation) != 0)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*pool_, *p.p,
|
||||
"thread_pool", pool_, 0, "execute(blk=never,rel=cont)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*pool_, *p.p,
|
||||
"thread_pool", pool_, 0, "execute(blk=never,rel=fork)"));
|
||||
}
|
||||
|
||||
pool_->scheduler_.post_immediate_completion(p.p,
|
||||
(bits_ & relationship_continuation) != 0);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
template <typename Function>
|
||||
void thread_pool::basic_executor_type<Allocator,
|
||||
Bits>::do_execute(ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, true_type) const
|
||||
{
|
||||
// Obtain a non-const instance of the function.
|
||||
detail::non_const_lvalue<Function> f2(f);
|
||||
|
||||
// Invoke immediately if we are already inside the thread pool.
|
||||
if (pool_->scheduler_.can_dispatch())
|
||||
{
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
try
|
||||
{
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
detail::fenced_block b(detail::fenced_block::full);
|
||||
Boost_asio_handler_invoke_helpers::invoke(f2.value, f2.value);
|
||||
return;
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::terminate();
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
|
||||
// Construct an operation to wrap the function.
|
||||
typedef typename decay<Function>::type function_type;
|
||||
detail::blocking_executor_op<function_type> op(f2.value);
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*pool_, op,
|
||||
"thread_pool", pool_, 0, "execute(blk=always)"));
|
||||
|
||||
pool_->scheduler_.post_immediate_completion(&op, false);
|
||||
op.wait();
|
||||
}
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
template <typename Function>
|
||||
void thread_pool::basic_executor_type<Allocator, Bits>::do_bulk_execute(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, std::size_t n, false_type) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
typedef detail::bulk_executor_op<function_type, Allocator> op;
|
||||
|
||||
// Allocate and construct operations to wrap the function.
|
||||
detail::op_queue<detail::scheduler_operation> ops;
|
||||
for (std::size_t i = 0; i < n; ++i)
|
||||
{
|
||||
typename op::ptr p = { detail::addressof(allocator_),
|
||||
op::ptr::allocate(allocator_), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), allocator_, i);
|
||||
ops.push(p.p);
|
||||
|
||||
if ((bits_ & relationship_continuation) != 0)
|
||||
{
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*pool_, *p.p,
|
||||
"thread_pool", pool_, 0, "bulk_execute(blk=never,rel=cont)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*pool_, *p.p,
|
||||
"thread_pool", pool_, 0, "bulk)execute(blk=never,rel=fork)"));
|
||||
}
|
||||
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
|
||||
pool_->scheduler_.post_immediate_completions(n,
|
||||
ops, (bits_ & relationship_continuation) != 0);
|
||||
}
|
||||
|
||||
template <typename Function>
|
||||
struct thread_pool_always_blocking_function_adapter
|
||||
{
|
||||
typename decay<Function>::type* f;
|
||||
std::size_t n;
|
||||
|
||||
void operator()()
|
||||
{
|
||||
for (std::size_t i = 0; i < n; ++i)
|
||||
{
|
||||
(*f)(i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
template <typename Function>
|
||||
void thread_pool::basic_executor_type<Allocator, Bits>::do_bulk_execute(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, std::size_t n, true_type) const
|
||||
{
|
||||
// Obtain a non-const instance of the function.
|
||||
detail::non_const_lvalue<Function> f2(f);
|
||||
|
||||
thread_pool_always_blocking_function_adapter<Function>
|
||||
adapter = { detail::addressof(f2.value), n };
|
||||
|
||||
this->do_execute(adapter, true_type());
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
inline thread_pool& thread_pool::basic_executor_type<
|
||||
Allocator, Bits>::context() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return *pool_;
|
||||
}
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
inline void thread_pool::basic_executor_type<Allocator,
|
||||
Bits>::on_work_started() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
pool_->scheduler_.work_started();
|
||||
}
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
inline void thread_pool::basic_executor_type<Allocator,
|
||||
Bits>::on_work_finished() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
pool_->scheduler_.work_finished();
|
||||
}
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
template <typename Function, typename OtherAllocator>
|
||||
void thread_pool::basic_executor_type<Allocator, Bits>::dispatch(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
// Invoke immediately if we are already inside the thread pool.
|
||||
if (pool_->scheduler_.can_dispatch())
|
||||
{
|
||||
// Make a local, non-const copy of the function.
|
||||
function_type tmp(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f));
|
||||
|
||||
detail::fenced_block b(detail::fenced_block::full);
|
||||
Boost_asio_handler_invoke_helpers::invoke(tmp, tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef detail::executor_op<function_type, OtherAllocator> op;
|
||||
typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a);
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*pool_, *p.p,
|
||||
"thread_pool", pool_, 0, "dispatch"));
|
||||
|
||||
pool_->scheduler_.post_immediate_completion(p.p, false);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
template <typename Function, typename OtherAllocator>
|
||||
void thread_pool::basic_executor_type<Allocator, Bits>::post(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef detail::executor_op<function_type, OtherAllocator> op;
|
||||
typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a);
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*pool_, *p.p,
|
||||
"thread_pool", pool_, 0, "post"));
|
||||
|
||||
pool_->scheduler_.post_immediate_completion(p.p, false);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
|
||||
template <typename Allocator, unsigned int Bits>
|
||||
template <typename Function, typename OtherAllocator>
|
||||
void thread_pool::basic_executor_type<Allocator, Bits>::defer(
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const
|
||||
{
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
// Allocate and construct an operation to wrap the function.
|
||||
typedef detail::executor_op<function_type, OtherAllocator> op;
|
||||
typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
|
||||
p.p = new (p.v) op(ACTIV_BOOST_ASIO_MOVE_CAST(Function)(f), a);
|
||||
|
||||
ACTIV_BOOST_ASIO_HANDLER_CREATION((*pool_, *p.p,
|
||||
"thread_pool", pool_, 0, "defer"));
|
||||
|
||||
pool_->scheduler_.post_immediate_completion(p.p, true);
|
||||
p.v = p.p = 0;
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_THREAD_POOL_HPP
|
||||
@@ -1,143 +0,0 @@
|
||||
//
|
||||
// impl/thread_pool.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 ACTIV_BOOST_ASIO_IMPL_THREAD_POOL_IPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_THREAD_POOL_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <stdexcept>
|
||||
#include <ActivBoost/asio/thread_pool.hpp>
|
||||
#include <ActivBoost/asio/detail/throw_exception.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
struct thread_pool::thread_function
|
||||
{
|
||||
detail::scheduler* scheduler_;
|
||||
|
||||
void operator()()
|
||||
{
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
try
|
||||
{
|
||||
#endif// !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
Boost::system::error_code ec;
|
||||
scheduler_->run(ec);
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::terminate();
|
||||
}
|
||||
#endif// !defined(ACTIV_BOOST_ASIO_NO_EXCEPTIONS)
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
namespace detail {
|
||||
|
||||
inline long default_thread_pool_size()
|
||||
{
|
||||
std::size_t num_threads = thread::hardware_concurrency() * 2;
|
||||
num_threads = num_threads == 0 ? 2 : num_threads;
|
||||
return static_cast<long>(num_threads);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
thread_pool::thread_pool()
|
||||
: scheduler_(add_scheduler(new detail::scheduler(*this, 0, false))),
|
||||
num_threads_(detail::default_thread_pool_size())
|
||||
{
|
||||
scheduler_.work_started();
|
||||
|
||||
thread_function f = { &scheduler_ };
|
||||
threads_.create_threads(f, static_cast<std::size_t>(num_threads_));
|
||||
}
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
namespace detail {
|
||||
|
||||
inline long clamp_thread_pool_size(std::size_t n)
|
||||
{
|
||||
if (n > 0x7FFFFFFF)
|
||||
{
|
||||
std::out_of_range ex("thread pool size");
|
||||
Boost::asio::detail::throw_exception(ex);
|
||||
}
|
||||
return static_cast<long>(n & 0x7FFFFFFF);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
thread_pool::thread_pool(std::size_t num_threads)
|
||||
: scheduler_(add_scheduler(new detail::scheduler(
|
||||
*this, num_threads == 1 ? 1 : 0, false))),
|
||||
num_threads_(detail::clamp_thread_pool_size(num_threads))
|
||||
{
|
||||
scheduler_.work_started();
|
||||
|
||||
thread_function f = { &scheduler_ };
|
||||
threads_.create_threads(f, static_cast<std::size_t>(num_threads_));
|
||||
}
|
||||
|
||||
thread_pool::~thread_pool()
|
||||
{
|
||||
stop();
|
||||
join();
|
||||
}
|
||||
|
||||
void thread_pool::stop()
|
||||
{
|
||||
scheduler_.stop();
|
||||
}
|
||||
|
||||
void thread_pool::attach()
|
||||
{
|
||||
++num_threads_;
|
||||
thread_function f = { &scheduler_ };
|
||||
f();
|
||||
}
|
||||
|
||||
void thread_pool::join()
|
||||
{
|
||||
if (!threads_.empty())
|
||||
{
|
||||
scheduler_.work_finished();
|
||||
threads_.join();
|
||||
}
|
||||
}
|
||||
|
||||
detail::scheduler& thread_pool::add_scheduler(detail::scheduler* s)
|
||||
{
|
||||
detail::scoped_ptr<detail::scheduler> scoped_impl(s);
|
||||
Boost::asio::add_service<detail::scheduler>(*this, scoped_impl.get());
|
||||
return *scoped_impl.release();
|
||||
}
|
||||
|
||||
void thread_pool::wait()
|
||||
{
|
||||
scheduler_.work_finished();
|
||||
threads_.join();
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_THREAD_POOL_IPP
|
||||
@@ -1,303 +0,0 @@
|
||||
//
|
||||
// impl/use_awaitable.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 ACTIV_BOOST_ASIO_IMPL_USE_AWAITABLE_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_USE_AWAITABLE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/detail/config.hpp>
|
||||
#include <ActivBoost/asio/async_result.hpp>
|
||||
#include <ActivBoost/asio/cancellation_signal.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
template <typename Executor, typename T>
|
||||
class awaitable_handler_base
|
||||
: public awaitable_thread<Executor>
|
||||
{
|
||||
public:
|
||||
typedef void result_type;
|
||||
typedef awaitable<T, Executor> awaitable_type;
|
||||
|
||||
// Construct from the entry point of a new thread of execution.
|
||||
awaitable_handler_base(awaitable<awaitable_thread_entry_point, Executor> a,
|
||||
const Executor& ex, cancellation_slot pcs, cancellation_state cs)
|
||||
: awaitable_thread<Executor>(std::move(a), ex, pcs, cs)
|
||||
{
|
||||
}
|
||||
|
||||
// Transfer ownership from another awaitable_thread.
|
||||
explicit awaitable_handler_base(awaitable_thread<Executor>* h)
|
||||
: awaitable_thread<Executor>(std::move(*h))
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
awaitable_frame<T, Executor>* frame() noexcept
|
||||
{
|
||||
return static_cast<awaitable_frame<T, Executor>*>(
|
||||
this->entry_point()->top_of_stack_);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename, typename...>
|
||||
class awaitable_handler;
|
||||
|
||||
template <typename Executor>
|
||||
class awaitable_handler<Executor>
|
||||
: public awaitable_handler_base<Executor, void>
|
||||
{
|
||||
public:
|
||||
using awaitable_handler_base<Executor, void>::awaitable_handler_base;
|
||||
|
||||
void operator()()
|
||||
{
|
||||
this->frame()->attach_thread(this);
|
||||
this->frame()->return_void();
|
||||
this->frame()->clear_cancellation_slot();
|
||||
this->frame()->pop_frame();
|
||||
this->pump();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor>
|
||||
class awaitable_handler<Executor, Boost::system::error_code>
|
||||
: public awaitable_handler_base<Executor, void>
|
||||
{
|
||||
public:
|
||||
using awaitable_handler_base<Executor, void>::awaitable_handler_base;
|
||||
|
||||
void operator()(const Boost::system::error_code& ec)
|
||||
{
|
||||
this->frame()->attach_thread(this);
|
||||
if (ec)
|
||||
this->frame()->set_error(ec);
|
||||
else
|
||||
this->frame()->return_void();
|
||||
this->frame()->clear_cancellation_slot();
|
||||
this->frame()->pop_frame();
|
||||
this->pump();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor>
|
||||
class awaitable_handler<Executor, std::exception_ptr>
|
||||
: public awaitable_handler_base<Executor, void>
|
||||
{
|
||||
public:
|
||||
using awaitable_handler_base<Executor, void>::awaitable_handler_base;
|
||||
|
||||
void operator()(std::exception_ptr ex)
|
||||
{
|
||||
this->frame()->attach_thread(this);
|
||||
if (ex)
|
||||
this->frame()->set_except(ex);
|
||||
else
|
||||
this->frame()->return_void();
|
||||
this->frame()->clear_cancellation_slot();
|
||||
this->frame()->pop_frame();
|
||||
this->pump();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor, typename T>
|
||||
class awaitable_handler<Executor, T>
|
||||
: public awaitable_handler_base<Executor, T>
|
||||
{
|
||||
public:
|
||||
using awaitable_handler_base<Executor, T>::awaitable_handler_base;
|
||||
|
||||
template <typename Arg>
|
||||
void operator()(Arg&& arg)
|
||||
{
|
||||
this->frame()->attach_thread(this);
|
||||
this->frame()->return_value(std::forward<Arg>(arg));
|
||||
this->frame()->clear_cancellation_slot();
|
||||
this->frame()->pop_frame();
|
||||
this->pump();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor, typename T>
|
||||
class awaitable_handler<Executor, Boost::system::error_code, T>
|
||||
: public awaitable_handler_base<Executor, T>
|
||||
{
|
||||
public:
|
||||
using awaitable_handler_base<Executor, T>::awaitable_handler_base;
|
||||
|
||||
template <typename Arg>
|
||||
void operator()(const Boost::system::error_code& ec, Arg&& arg)
|
||||
{
|
||||
this->frame()->attach_thread(this);
|
||||
if (ec)
|
||||
this->frame()->set_error(ec);
|
||||
else
|
||||
this->frame()->return_value(std::forward<Arg>(arg));
|
||||
this->frame()->clear_cancellation_slot();
|
||||
this->frame()->pop_frame();
|
||||
this->pump();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor, typename T>
|
||||
class awaitable_handler<Executor, std::exception_ptr, T>
|
||||
: public awaitable_handler_base<Executor, T>
|
||||
{
|
||||
public:
|
||||
using awaitable_handler_base<Executor, T>::awaitable_handler_base;
|
||||
|
||||
template <typename Arg>
|
||||
void operator()(std::exception_ptr ex, Arg&& arg)
|
||||
{
|
||||
this->frame()->attach_thread(this);
|
||||
if (ex)
|
||||
this->frame()->set_except(ex);
|
||||
else
|
||||
this->frame()->return_value(std::forward<Arg>(arg));
|
||||
this->frame()->clear_cancellation_slot();
|
||||
this->frame()->pop_frame();
|
||||
this->pump();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor, typename... Ts>
|
||||
class awaitable_handler
|
||||
: public awaitable_handler_base<Executor, std::tuple<Ts...>>
|
||||
{
|
||||
public:
|
||||
using awaitable_handler_base<Executor,
|
||||
std::tuple<Ts...>>::awaitable_handler_base;
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(Args&&... args)
|
||||
{
|
||||
this->frame()->attach_thread(this);
|
||||
this->frame()->return_values(std::forward<Args>(args)...);
|
||||
this->frame()->clear_cancellation_slot();
|
||||
this->frame()->pop_frame();
|
||||
this->pump();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor, typename... Ts>
|
||||
class awaitable_handler<Executor, Boost::system::error_code, Ts...>
|
||||
: public awaitable_handler_base<Executor, std::tuple<Ts...>>
|
||||
{
|
||||
public:
|
||||
using awaitable_handler_base<Executor,
|
||||
std::tuple<Ts...>>::awaitable_handler_base;
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(const Boost::system::error_code& ec, Args&&... args)
|
||||
{
|
||||
this->frame()->attach_thread(this);
|
||||
if (ec)
|
||||
this->frame()->set_error(ec);
|
||||
else
|
||||
this->frame()->return_values(std::forward<Args>(args)...);
|
||||
this->frame()->clear_cancellation_slot();
|
||||
this->frame()->pop_frame();
|
||||
this->pump();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Executor, typename... Ts>
|
||||
class awaitable_handler<Executor, std::exception_ptr, Ts...>
|
||||
: public awaitable_handler_base<Executor, std::tuple<Ts...>>
|
||||
{
|
||||
public:
|
||||
using awaitable_handler_base<Executor,
|
||||
std::tuple<Ts...>>::awaitable_handler_base;
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(std::exception_ptr ex, Args&&... args)
|
||||
{
|
||||
this->frame()->attach_thread(this);
|
||||
if (ex)
|
||||
this->frame()->set_except(ex);
|
||||
else
|
||||
this->frame()->return_values(std::forward<Args>(args)...);
|
||||
this->frame()->clear_cancellation_slot();
|
||||
this->frame()->pop_frame();
|
||||
this->pump();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
template <typename T>
|
||||
T dummy_return()
|
||||
{
|
||||
return std::move(*static_cast<T*>(nullptr));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void dummy_return()
|
||||
{
|
||||
}
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
template <typename Executor, typename R, typename... Args>
|
||||
class async_result<use_awaitable_t<Executor>, R(Args...)>
|
||||
{
|
||||
public:
|
||||
typedef typename detail::awaitable_handler<
|
||||
Executor, typename decay<Args>::type...> handler_type;
|
||||
typedef typename handler_type::awaitable_type return_type;
|
||||
|
||||
template <typename Initiation, typename... InitArgs>
|
||||
#if defined(__APPLE_CC__) && (__clang_major__ == 13)
|
||||
__attribute__((noinline))
|
||||
#endif // defined(__APPLE_CC__) && (__clang_major__ == 13)
|
||||
static handler_type* do_init(
|
||||
detail::awaitable_frame_base<Executor>* frame, Initiation& initiation,
|
||||
use_awaitable_t<Executor> u, InitArgs&... args)
|
||||
{
|
||||
(void)u;
|
||||
ACTIV_BOOST_ASIO_HANDLER_LOCATION((u.file_name_, u.line_, u.function_name_));
|
||||
handler_type handler(frame->detach_thread());
|
||||
std::move(initiation)(std::move(handler), std::move(args)...);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename Initiation, typename... InitArgs>
|
||||
static return_type initiate(Initiation initiation,
|
||||
use_awaitable_t<Executor> u, InitArgs... args)
|
||||
{
|
||||
co_await [&] (auto* frame)
|
||||
{
|
||||
return do_init(frame, initiation, u, args...);
|
||||
};
|
||||
|
||||
for (;;) {} // Never reached.
|
||||
#if defined(_MSC_VER)
|
||||
co_return dummy_return<typename return_type::value_type>();
|
||||
#endif // defined(_MSC_VER)
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_USE_AWAITABLE_HPP
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,689 +0,0 @@
|
||||
//
|
||||
// impl/write_at.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 ACTIV_BOOST_ASIO_IMPL_WRITE_AT_HPP
|
||||
#define ACTIV_BOOST_ASIO_IMPL_WRITE_AT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <ActivBoost/asio/associator.hpp>
|
||||
#include <ActivBoost/asio/buffer.hpp>
|
||||
#include <ActivBoost/asio/detail/array_fwd.hpp>
|
||||
#include <ActivBoost/asio/detail/base_from_cancellation_state.hpp>
|
||||
#include <ActivBoost/asio/detail/base_from_completion_cond.hpp>
|
||||
#include <ActivBoost/asio/detail/bind_handler.hpp>
|
||||
#include <ActivBoost/asio/detail/consuming_buffers.hpp>
|
||||
#include <ActivBoost/asio/detail/dependent_type.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_tracking.hpp>
|
||||
#include <ActivBoost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <ActivBoost/asio/detail/non_const_lvalue.hpp>
|
||||
#include <ActivBoost/asio/detail/throw_error.hpp>
|
||||
|
||||
#include <ActivBoost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace Boost {
|
||||
namespace asio {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence,
|
||||
typename ConstBufferIterator, typename CompletionCondition>
|
||||
std::size_t write_at_buffer_sequence(SyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, const ConstBufferSequence& buffers,
|
||||
const ConstBufferIterator&, CompletionCondition completion_condition,
|
||||
Boost::system::error_code& ec)
|
||||
{
|
||||
ec = Boost::system::error_code();
|
||||
Boost::asio::detail::consuming_buffers<const_buffer,
|
||||
ConstBufferSequence, ConstBufferIterator> tmp(buffers);
|
||||
while (!tmp.empty())
|
||||
{
|
||||
if (std::size_t max_size = detail::adapt_completion_condition_result(
|
||||
completion_condition(ec, tmp.total_consumed())))
|
||||
{
|
||||
tmp.consume(d.write_some_at(offset + tmp.total_consumed(),
|
||||
tmp.prepare(max_size), ec));
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return tmp.total_consumed();
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence,
|
||||
typename CompletionCondition>
|
||||
std::size_t write_at(SyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, const ConstBufferSequence& buffers,
|
||||
CompletionCondition completion_condition, Boost::system::error_code& ec)
|
||||
{
|
||||
return detail::write_at_buffer_sequence(d, offset, buffers,
|
||||
Boost::asio::buffer_sequence_begin(buffers),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition), ec);
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence>
|
||||
inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, const ConstBufferSequence& buffers)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = write_at(
|
||||
d, offset, buffers, transfer_all(), ec);
|
||||
Boost::asio::detail::throw_error(ec, "write_at");
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence>
|
||||
inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, const ConstBufferSequence& buffers,
|
||||
Boost::system::error_code& ec)
|
||||
{
|
||||
return write_at(d, offset, buffers, transfer_all(), ec);
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence,
|
||||
typename CompletionCondition>
|
||||
inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, const ConstBufferSequence& buffers,
|
||||
CompletionCondition completion_condition)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = write_at(d, offset, buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition), ec);
|
||||
Boost::asio::detail::throw_error(ec, "write_at");
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXTENSIONS)
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_IOSTREAM)
|
||||
|
||||
template <typename SyncRandomAccessWriteDevice, typename Allocator,
|
||||
typename CompletionCondition>
|
||||
std::size_t write_at(SyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b,
|
||||
CompletionCondition completion_condition, Boost::system::error_code& ec)
|
||||
{
|
||||
std::size_t bytes_transferred = write_at(d, offset, b.data(),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition), ec);
|
||||
b.consume(bytes_transferred);
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessWriteDevice, typename Allocator>
|
||||
inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = write_at(d, offset, b, transfer_all(), ec);
|
||||
Boost::asio::detail::throw_error(ec, "write_at");
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessWriteDevice, typename Allocator>
|
||||
inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b,
|
||||
Boost::system::error_code& ec)
|
||||
{
|
||||
return write_at(d, offset, b, transfer_all(), ec);
|
||||
}
|
||||
|
||||
template <typename SyncRandomAccessWriteDevice, typename Allocator,
|
||||
typename CompletionCondition>
|
||||
inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b,
|
||||
CompletionCondition completion_condition)
|
||||
{
|
||||
Boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = write_at(d, offset, b,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition), ec);
|
||||
Boost::asio::detail::throw_error(ec, "write_at");
|
||||
return bytes_transferred;
|
||||
}
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_IOSTREAM)
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_EXTENSIONS)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename AsyncRandomAccessWriteDevice,
|
||||
typename ConstBufferSequence, typename ConstBufferIterator,
|
||||
typename CompletionCondition, typename WriteHandler>
|
||||
class write_at_op
|
||||
: public base_from_cancellation_state<WriteHandler>,
|
||||
base_from_completion_cond<CompletionCondition>
|
||||
{
|
||||
public:
|
||||
write_at_op(AsyncRandomAccessWriteDevice& device,
|
||||
uint64_t offset, const ConstBufferSequence& buffers,
|
||||
CompletionCondition& completion_condition, WriteHandler& handler)
|
||||
: base_from_cancellation_state<WriteHandler>(
|
||||
handler, enable_partial_cancellation()),
|
||||
base_from_completion_cond<CompletionCondition>(completion_condition),
|
||||
device_(device),
|
||||
offset_(offset),
|
||||
buffers_(buffers),
|
||||
start_(0),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
write_at_op(const write_at_op& other)
|
||||
: base_from_cancellation_state<WriteHandler>(other),
|
||||
base_from_completion_cond<CompletionCondition>(other),
|
||||
device_(other.device_),
|
||||
offset_(other.offset_),
|
||||
buffers_(other.buffers_),
|
||||
start_(other.start_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
write_at_op(write_at_op&& other)
|
||||
: base_from_cancellation_state<WriteHandler>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(base_from_cancellation_state<
|
||||
WriteHandler>)(other)),
|
||||
base_from_completion_cond<CompletionCondition>(
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(base_from_completion_cond<
|
||||
CompletionCondition>)(other)),
|
||||
device_(other.device_),
|
||||
offset_(other.offset_),
|
||||
buffers_(ACTIV_BOOST_ASIO_MOVE_CAST(buffers_type)(other.buffers_)),
|
||||
start_(other.start_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(WriteHandler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()(Boost::system::error_code ec,
|
||||
std::size_t bytes_transferred, int start = 0)
|
||||
{
|
||||
std::size_t max_size;
|
||||
switch (start_ = start)
|
||||
{
|
||||
case 1:
|
||||
max_size = this->check_for_completion(ec, buffers_.total_consumed());
|
||||
for (;;)
|
||||
{
|
||||
{
|
||||
ACTIV_BOOST_ASIO_HANDLER_LOCATION((__FILE__, __LINE__, "async_write_at"));
|
||||
device_.async_write_some_at(
|
||||
offset_ + buffers_.total_consumed(), buffers_.prepare(max_size),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(write_at_op)(*this));
|
||||
}
|
||||
return; default:
|
||||
buffers_.consume(bytes_transferred);
|
||||
if ((!ec && bytes_transferred == 0) || buffers_.empty())
|
||||
break;
|
||||
max_size = this->check_for_completion(ec, buffers_.total_consumed());
|
||||
if (max_size == 0)
|
||||
break;
|
||||
if (this->cancelled() != cancellation_type::none)
|
||||
{
|
||||
ec = Boost::asio::error::operation_aborted;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(WriteHandler)(handler_)(
|
||||
static_cast<const Boost::system::error_code&>(ec),
|
||||
static_cast<const std::size_t&>(buffers_.total_consumed()));
|
||||
}
|
||||
}
|
||||
|
||||
//private:
|
||||
typedef Boost::asio::detail::consuming_buffers<const_buffer,
|
||||
ConstBufferSequence, ConstBufferIterator> buffers_type;
|
||||
|
||||
AsyncRandomAccessWriteDevice& device_;
|
||||
uint64_t offset_;
|
||||
buffers_type buffers_;
|
||||
int start_;
|
||||
WriteHandler handler_;
|
||||
};
|
||||
|
||||
template <typename AsyncRandomAccessWriteDevice,
|
||||
typename ConstBufferSequence, typename ConstBufferIterator,
|
||||
typename CompletionCondition, typename WriteHandler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
|
||||
ConstBufferIterator, CompletionCondition, WriteHandler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessWriteDevice,
|
||||
typename ConstBufferSequence, typename ConstBufferIterator,
|
||||
typename CompletionCondition, typename WriteHandler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
|
||||
ConstBufferIterator, CompletionCondition, WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessWriteDevice,
|
||||
typename ConstBufferSequence, typename ConstBufferIterator,
|
||||
typename CompletionCondition, typename WriteHandler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
|
||||
ConstBufferIterator, CompletionCondition, WriteHandler>* this_handler)
|
||||
{
|
||||
return this_handler->start_ == 0 ? true
|
||||
: Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename AsyncRandomAccessWriteDevice,
|
||||
typename ConstBufferSequence, typename ConstBufferIterator,
|
||||
typename CompletionCondition, typename WriteHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
|
||||
ConstBufferIterator, CompletionCondition, WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename AsyncRandomAccessWriteDevice,
|
||||
typename ConstBufferSequence, typename ConstBufferIterator,
|
||||
typename CompletionCondition, typename WriteHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
|
||||
ConstBufferIterator, CompletionCondition, WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessWriteDevice,
|
||||
typename ConstBufferSequence, typename ConstBufferIterator,
|
||||
typename CompletionCondition, typename WriteHandler>
|
||||
inline void start_write_at_op(AsyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, const ConstBufferSequence& buffers,
|
||||
const ConstBufferIterator&, CompletionCondition& completion_condition,
|
||||
WriteHandler& handler)
|
||||
{
|
||||
detail::write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
|
||||
ConstBufferIterator, CompletionCondition, WriteHandler>(
|
||||
d, offset, buffers, completion_condition, handler)(
|
||||
Boost::system::error_code(), 0, 1);
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessWriteDevice>
|
||||
class initiate_async_write_at
|
||||
{
|
||||
public:
|
||||
typedef typename AsyncRandomAccessWriteDevice::executor_type executor_type;
|
||||
|
||||
explicit initiate_async_write_at(AsyncRandomAccessWriteDevice& device)
|
||||
: device_(device)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return device_.get_executor();
|
||||
}
|
||||
|
||||
template <typename WriteHandler, typename ConstBufferSequence,
|
||||
typename CompletionCondition>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(WriteHandler) handler,
|
||||
uint64_t offset, const ConstBufferSequence& buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(CompletionCondition) completion_cond) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WriteHandler.
|
||||
ACTIV_BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
non_const_lvalue<WriteHandler> handler2(handler);
|
||||
non_const_lvalue<CompletionCondition> completion_cond2(completion_cond);
|
||||
start_write_at_op(device_, offset, buffers,
|
||||
Boost::asio::buffer_sequence_begin(buffers),
|
||||
completion_cond2.value, handler2.value);
|
||||
}
|
||||
|
||||
private:
|
||||
AsyncRandomAccessWriteDevice& device_;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
|
||||
typename ConstBufferIterator, typename CompletionCondition,
|
||||
typename WriteHandler, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
|
||||
ConstBufferIterator, CompletionCondition, WriteHandler>,
|
||||
DefaultCandidate>
|
||||
: Associator<WriteHandler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<WriteHandler, DefaultCandidate>::type
|
||||
get(const detail::write_at_op<AsyncRandomAccessWriteDevice,
|
||||
ConstBufferSequence, ConstBufferIterator,
|
||||
CompletionCondition, WriteHandler>& h) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<WriteHandler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<WriteHandler, DefaultCandidate>::type)
|
||||
get(const detail::write_at_op<AsyncRandomAccessWriteDevice,
|
||||
ConstBufferSequence, ConstBufferIterator,
|
||||
CompletionCondition, WriteHandler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<WriteHandler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<WriteHandler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename AsyncRandomAccessWriteDevice,
|
||||
typename ConstBufferSequence, typename CompletionCondition,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) WriteToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
async_write_at(AsyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, const ConstBufferSequence& buffers,
|
||||
CompletionCondition completion_condition,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(WriteToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<WriteToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_write_at<
|
||||
AsyncRandomAccessWriteDevice> >(),
|
||||
token, offset, buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition))))
|
||||
{
|
||||
return async_initiate<WriteToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_write_at<AsyncRandomAccessWriteDevice>(d),
|
||||
token, offset, buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition));
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) WriteToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
async_write_at(AsyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, const ConstBufferSequence& buffers,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(WriteToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<WriteToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_write_at<
|
||||
AsyncRandomAccessWriteDevice> >(),
|
||||
token, offset, buffers, transfer_all())))
|
||||
{
|
||||
return async_initiate<WriteToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_write_at<AsyncRandomAccessWriteDevice>(d),
|
||||
token, offset, buffers, transfer_all());
|
||||
}
|
||||
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_EXTENSIONS)
|
||||
#if !defined(ACTIV_BOOST_ASIO_NO_IOSTREAM)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename Allocator, typename WriteHandler>
|
||||
class write_at_streambuf_op
|
||||
{
|
||||
public:
|
||||
write_at_streambuf_op(
|
||||
Boost::asio::basic_streambuf<Allocator>& streambuf,
|
||||
WriteHandler& handler)
|
||||
: streambuf_(streambuf),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
write_at_streambuf_op(const write_at_streambuf_op& other)
|
||||
: streambuf_(other.streambuf_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
write_at_streambuf_op(write_at_streambuf_op&& other)
|
||||
: streambuf_(other.streambuf_),
|
||||
handler_(ACTIV_BOOST_ASIO_MOVE_CAST(WriteHandler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ACTIV_BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()(const Boost::system::error_code& ec,
|
||||
const std::size_t bytes_transferred)
|
||||
{
|
||||
streambuf_.consume(bytes_transferred);
|
||||
ACTIV_BOOST_ASIO_MOVE_OR_LVALUE(WriteHandler)(handler_)(ec, bytes_transferred);
|
||||
}
|
||||
|
||||
//private:
|
||||
Boost::asio::basic_streambuf<Allocator>& streambuf_;
|
||||
WriteHandler handler_;
|
||||
};
|
||||
|
||||
template <typename Allocator, typename WriteHandler>
|
||||
inline asio_handler_allocate_is_deprecated
|
||||
asio_handler_allocate(std::size_t size,
|
||||
write_at_streambuf_op<Allocator, WriteHandler>* this_handler)
|
||||
{
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
Boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
|
||||
return asio_handler_allocate_is_no_longer_used();
|
||||
#else // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return Boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Allocator, typename WriteHandler>
|
||||
inline asio_handler_deallocate_is_deprecated
|
||||
asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
write_at_streambuf_op<Allocator, WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_deallocate_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Allocator, typename WriteHandler>
|
||||
inline bool asio_handler_is_continuation(
|
||||
write_at_streambuf_op<Allocator, WriteHandler>* this_handler)
|
||||
{
|
||||
return Boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Allocator, typename WriteHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(Function& function,
|
||||
write_at_streambuf_op<Allocator, WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename Function, typename Allocator, typename WriteHandler>
|
||||
inline asio_handler_invoke_is_deprecated
|
||||
asio_handler_invoke(const Function& function,
|
||||
write_at_streambuf_op<Allocator, WriteHandler>* this_handler)
|
||||
{
|
||||
Boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
#if defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
return asio_handler_invoke_is_no_longer_used();
|
||||
#endif // defined(ACTIV_BOOST_ASIO_NO_DEPRECATED)
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessWriteDevice>
|
||||
class initiate_async_write_at_streambuf
|
||||
{
|
||||
public:
|
||||
typedef typename AsyncRandomAccessWriteDevice::executor_type executor_type;
|
||||
|
||||
explicit initiate_async_write_at_streambuf(
|
||||
AsyncRandomAccessWriteDevice& device)
|
||||
: device_(device)
|
||||
{
|
||||
}
|
||||
|
||||
executor_type get_executor() const ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return device_.get_executor();
|
||||
}
|
||||
|
||||
template <typename WriteHandler,
|
||||
typename Allocator, typename CompletionCondition>
|
||||
void operator()(ACTIV_BOOST_ASIO_MOVE_ARG(WriteHandler) handler,
|
||||
uint64_t offset, basic_streambuf<Allocator>* b,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(CompletionCondition) completion_condition) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WriteHandler.
|
||||
ACTIV_BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
non_const_lvalue<WriteHandler> handler2(handler);
|
||||
async_write_at(device_, offset, b->data(),
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition),
|
||||
write_at_streambuf_op<Allocator, typename decay<WriteHandler>::type>(
|
||||
*b, handler2.value));
|
||||
}
|
||||
|
||||
private:
|
||||
AsyncRandomAccessWriteDevice& device_;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename Executor, typename WriteHandler, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
detail::write_at_streambuf_op<Executor, WriteHandler>,
|
||||
DefaultCandidate>
|
||||
: Associator<WriteHandler, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<WriteHandler, DefaultCandidate>::type
|
||||
get(const detail::write_at_streambuf_op<Executor, WriteHandler>& h)
|
||||
ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return Associator<WriteHandler, DefaultCandidate>::get(h.handler_);
|
||||
}
|
||||
|
||||
static ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
|
||||
typename Associator<WriteHandler, DefaultCandidate>::type)
|
||||
get(const detail::write_at_streambuf_op<Executor, WriteHandler>& h,
|
||||
const DefaultCandidate& c) ACTIV_BOOST_ASIO_NOEXCEPT
|
||||
ACTIV_BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
|
||||
Associator<WriteHandler, DefaultCandidate>::get(h.handler_, c)))
|
||||
{
|
||||
return Associator<WriteHandler, DefaultCandidate>::get(h.handler_, c);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename AsyncRandomAccessWriteDevice,
|
||||
typename Allocator, typename CompletionCondition,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) WriteToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
async_write_at(AsyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b,
|
||||
CompletionCondition completion_condition,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(WriteToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<WriteToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_write_at_streambuf<
|
||||
AsyncRandomAccessWriteDevice> >(),
|
||||
token, offset, &b,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition))))
|
||||
{
|
||||
return async_initiate<WriteToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_write_at_streambuf<
|
||||
AsyncRandomAccessWriteDevice>(d),
|
||||
token, offset, &b,
|
||||
ACTIV_BOOST_ASIO_MOVE_CAST(CompletionCondition)(completion_condition));
|
||||
}
|
||||
|
||||
template <typename AsyncRandomAccessWriteDevice, typename Allocator,
|
||||
ACTIV_BOOST_ASIO_COMPLETION_TOKEN_FOR(void (Boost::system::error_code,
|
||||
std::size_t)) WriteToken>
|
||||
inline ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken,
|
||||
void (Boost::system::error_code, std::size_t))
|
||||
async_write_at(AsyncRandomAccessWriteDevice& d,
|
||||
uint64_t offset, Boost::asio::basic_streambuf<Allocator>& b,
|
||||
ACTIV_BOOST_ASIO_MOVE_ARG(WriteToken) token)
|
||||
ACTIV_BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<WriteToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
declval<detail::initiate_async_write_at_streambuf<
|
||||
AsyncRandomAccessWriteDevice> >(),
|
||||
token, offset, &b, transfer_all())))
|
||||
{
|
||||
return async_initiate<WriteToken,
|
||||
void (Boost::system::error_code, std::size_t)>(
|
||||
detail::initiate_async_write_at_streambuf<
|
||||
AsyncRandomAccessWriteDevice>(d),
|
||||
token, offset, &b, transfer_all());
|
||||
}
|
||||
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_IOSTREAM)
|
||||
#endif // !defined(ACTIV_BOOST_ASIO_NO_EXTENSIONS)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace Boost
|
||||
|
||||
#include <ActivBoost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // ACTIV_BOOST_ASIO_IMPL_WRITE_AT_HPP
|
||||
Reference in new issue
Block a user