update boost on linux
This commit is contained in:
@@ -1,283 +0,0 @@
|
||||
//
|
||||
// windows/basic_handle.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_WINDOWS_BASIC_HANDLE_HPP
|
||||
#define BOOST_ASIO_WINDOWS_BASIC_HANDLE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
|
||||
|| defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \
|
||||
|| defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace windows {
|
||||
|
||||
/// Provides Windows handle functionality.
|
||||
/**
|
||||
* The windows::basic_handle class template provides the ability to wrap a
|
||||
* Windows handle.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*/
|
||||
template <typename HandleService>
|
||||
class basic_handle
|
||||
: public basic_io_object<HandleService>
|
||||
{
|
||||
public:
|
||||
/// (Deprecated: Use native_handle_type.) The native representation of a
|
||||
/// handle.
|
||||
typedef typename HandleService::native_handle_type native_type;
|
||||
|
||||
/// The native representation of a handle.
|
||||
typedef typename HandleService::native_handle_type native_handle_type;
|
||||
|
||||
/// A basic_handle is always the lowest layer.
|
||||
typedef basic_handle<HandleService> lowest_layer_type;
|
||||
|
||||
/// Construct a basic_handle without opening it.
|
||||
/**
|
||||
* This constructor creates a handle without opening it.
|
||||
*
|
||||
* @param io_service The io_service object that the handle will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the handle.
|
||||
*/
|
||||
explicit basic_handle(boost::asio::io_service& io_service)
|
||||
: basic_io_object<HandleService>(io_service)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_handle on an existing native handle.
|
||||
/**
|
||||
* This constructor creates a handle object to hold an existing native handle.
|
||||
*
|
||||
* @param io_service The io_service object that the handle will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the handle.
|
||||
*
|
||||
* @param handle A native handle.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_handle(boost::asio::io_service& io_service,
|
||||
const native_handle_type& handle)
|
||||
: basic_io_object<HandleService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->get_service().assign(this->get_implementation(), handle, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_handle from another.
|
||||
/**
|
||||
* This constructor moves a handle from one object to another.
|
||||
*
|
||||
* @param other The other basic_handle object from which the move will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_handle(io_service&) constructor.
|
||||
*/
|
||||
basic_handle(basic_handle&& other)
|
||||
: basic_io_object<HandleService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_handle)(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_handle from another.
|
||||
/**
|
||||
* This assignment operator moves a handle from one object to another.
|
||||
*
|
||||
* @param other The other basic_handle object from which the move will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_handle(io_service&) constructor.
|
||||
*/
|
||||
basic_handle& operator=(basic_handle&& other)
|
||||
{
|
||||
basic_io_object<HandleService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_handle)(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a reference to the lowest layer in a stack of
|
||||
* layers. Since a basic_handle cannot contain any further layers, it simply
|
||||
* returns a reference to itself.
|
||||
*
|
||||
* @return A reference to the lowest layer in the stack of layers. Ownership
|
||||
* is not transferred to the caller.
|
||||
*/
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Get a const reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a const reference to the lowest layer in a stack of
|
||||
* layers. Since a basic_handle cannot contain any further layers, it simply
|
||||
* returns a reference to itself.
|
||||
*
|
||||
* @return A const reference to the lowest layer in the stack of layers.
|
||||
* Ownership is not transferred to the caller.
|
||||
*/
|
||||
const lowest_layer_type& lowest_layer() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Assign an existing native handle to the handle.
|
||||
/*
|
||||
* This function opens the handle to hold an existing native handle.
|
||||
*
|
||||
* @param handle A native handle.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void assign(const native_handle_type& handle)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->get_service().assign(this->get_implementation(), handle, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Assign an existing native handle to the handle.
|
||||
/*
|
||||
* This function opens the handle to hold an existing native handle.
|
||||
*
|
||||
* @param handle A native handle.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
boost::system::error_code assign(const native_handle_type& handle,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().assign(this->get_implementation(), handle, ec);
|
||||
}
|
||||
|
||||
/// Determine whether the handle is open.
|
||||
bool is_open() const
|
||||
{
|
||||
return this->get_service().is_open(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Close the handle.
|
||||
/**
|
||||
* This function is used to close the handle. Any asynchronous read or write
|
||||
* operations will be cancelled immediately, and will complete with the
|
||||
* boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void close()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->get_service().close(this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "close");
|
||||
}
|
||||
|
||||
/// Close the handle.
|
||||
/**
|
||||
* This function is used to close the handle. Any asynchronous read or write
|
||||
* operations will be cancelled immediately, and will complete with the
|
||||
* boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
boost::system::error_code close(boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().close(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// (Deprecated: Use native_handle().) Get the native handle representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* handle. This is intended to allow access to native handle functionality
|
||||
* that is not otherwise provided.
|
||||
*/
|
||||
native_type native()
|
||||
{
|
||||
return this->get_service().native_handle(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Get the native handle representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* handle. This is intended to allow access to native handle functionality
|
||||
* that is not otherwise provided.
|
||||
*/
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
return this->get_service().native_handle(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the handle.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read or write operations
|
||||
* to finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void cancel()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->get_service().cancel(this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the handle.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read or write operations
|
||||
* to finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
boost::system::error_code cancel(boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().cancel(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Protected destructor to prevent deletion through this type.
|
||||
~basic_handle()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace windows
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
|
||||
// || defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
|
||||
// || defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // BOOST_ASIO_WINDOWS_BASIC_HANDLE_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// windows/basic_object_handle.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2011 Boris Schaeling (boris@highscore.de)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
@@ -21,10 +21,17 @@
|
||||
#if defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/detail/io_object_impl.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/detail/win_object_handle_service.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/windows/basic_handle.hpp>
|
||||
#include <boost/asio/windows/object_handle_service.hpp>
|
||||
#include <boost/asio/execution_context.hpp>
|
||||
#include <boost/asio/executor.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
# include <utility>
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -34,86 +41,284 @@ namespace windows {
|
||||
|
||||
/// Provides object-oriented handle functionality.
|
||||
/**
|
||||
* The windows::basic_object_handle class template provides asynchronous and
|
||||
* blocking object-oriented handle functionality.
|
||||
* The windows::basic_object_handle class provides asynchronous and blocking
|
||||
* object-oriented handle functionality.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*/
|
||||
template <typename ObjectHandleService = object_handle_service>
|
||||
template <typename Executor = executor>
|
||||
class basic_object_handle
|
||||
: public basic_handle<ObjectHandleService>
|
||||
{
|
||||
public:
|
||||
/// The native representation of a handle.
|
||||
typedef typename ObjectHandleService::native_handle_type native_handle_type;
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Construct a basic_object_handle without opening it.
|
||||
/// The native representation of a handle.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef boost::asio::detail::win_object_handle_service::native_handle_type
|
||||
native_handle_type;
|
||||
#endif
|
||||
|
||||
/// An object handle is always the lowest layer.
|
||||
typedef basic_object_handle lowest_layer_type;
|
||||
|
||||
/// Construct an object handle without opening it.
|
||||
/**
|
||||
* This constructor creates an object handle without opening it.
|
||||
*
|
||||
* @param io_service The io_service object that the object handle will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the handle.
|
||||
* @param ex The I/O executor that the object handle will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* object handle.
|
||||
*/
|
||||
explicit basic_object_handle(boost::asio::io_service& io_service)
|
||||
: basic_handle<ObjectHandleService>(io_service)
|
||||
explicit basic_object_handle(const executor_type& ex)
|
||||
: impl_(ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_object_handle on an existing native handle.
|
||||
/// Construct an object handle without opening it.
|
||||
/**
|
||||
* This constructor creates an object handle without opening it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the object handle will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the object handle.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_object_handle(ExecutionContext& context,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
basic_object_handle
|
||||
>::type* = 0)
|
||||
: impl_(context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct an object handle on an existing native handle.
|
||||
/**
|
||||
* This constructor creates an object handle object to hold an existing native
|
||||
* handle.
|
||||
*
|
||||
* @param io_service The io_service object that the object handle will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the handle.
|
||||
* @param ex The I/O executor that the object handle will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* object handle.
|
||||
*
|
||||
* @param native_handle The new underlying handle implementation.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_object_handle(boost::asio::io_service& io_service,
|
||||
basic_object_handle(const executor_type& ex,
|
||||
const native_handle_type& native_handle)
|
||||
: basic_handle<ObjectHandleService>(io_service, native_handle)
|
||||
: impl_(ex)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(), native_handle, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Construct an object handle on an existing native handle.
|
||||
/**
|
||||
* This constructor creates an object handle object to hold an existing native
|
||||
* handle.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the object handle will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the object handle.
|
||||
*
|
||||
* @param native_handle The new underlying handle implementation.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_object_handle(ExecutionContext& context,
|
||||
const native_handle_type& native_handle,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type* = 0)
|
||||
: impl_(context)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(), native_handle, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_object_handle from another.
|
||||
/// Move-construct an object handle from another.
|
||||
/**
|
||||
* This constructor moves an object handle from one object to another.
|
||||
*
|
||||
* @param other The other basic_object_handle object from which the move will
|
||||
* @param other The other object handle object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_object_handle(io_service&) constructor.
|
||||
* constructed using the @c basic_object_handle(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_object_handle(basic_object_handle&& other)
|
||||
: basic_handle<ObjectHandleService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_object_handle)(other))
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_object_handle from another.
|
||||
/// Move-assign an object handle from another.
|
||||
/**
|
||||
* This assignment operator moves an object handle from one object to another.
|
||||
*
|
||||
* @param other The other basic_object_handle object from which the move will
|
||||
* @param other The other object handle object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_object_handle(io_service&) constructor.
|
||||
* constructed using the @c basic_object_handle(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_object_handle& operator=(basic_object_handle&& other)
|
||||
{
|
||||
basic_handle<ObjectHandleService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_object_handle)(other));
|
||||
impl_ = std::move(other.impl_);
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
executor_type get_executor() BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return impl_.get_executor();
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a reference to the lowest layer in a stack of
|
||||
* layers. Since an object handle cannot contain any further layers, it simply
|
||||
* returns a reference to itself.
|
||||
*
|
||||
* @return A reference to the lowest layer in the stack of layers. Ownership
|
||||
* is not transferred to the caller.
|
||||
*/
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Get a const reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a const reference to the lowest layer in a stack of
|
||||
* layers. Since an object handle cannot contain any further layers, it simply
|
||||
* returns a reference to itself.
|
||||
*
|
||||
* @return A const reference to the lowest layer in the stack of layers.
|
||||
* Ownership is not transferred to the caller.
|
||||
*/
|
||||
const lowest_layer_type& lowest_layer() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Assign an existing native handle to the handle.
|
||||
/*
|
||||
* This function opens the handle to hold an existing native handle.
|
||||
*
|
||||
* @param handle A native handle.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void assign(const native_handle_type& handle)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(), handle, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Assign an existing native handle to the handle.
|
||||
/*
|
||||
* This function opens the handle to hold an existing native handle.
|
||||
*
|
||||
* @param handle A native handle.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
BOOST_ASIO_SYNC_OP_VOID assign(const native_handle_type& handle,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
impl_.get_service().assign(impl_.get_implementation(), handle, ec);
|
||||
BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Determine whether the handle is open.
|
||||
bool is_open() const
|
||||
{
|
||||
return impl_.get_service().is_open(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Close the handle.
|
||||
/**
|
||||
* This function is used to close the handle. Any asynchronous read or write
|
||||
* operations will be cancelled immediately, and will complete with the
|
||||
* boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void close()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "close");
|
||||
}
|
||||
|
||||
/// Close the handle.
|
||||
/**
|
||||
* This function is used to close the handle. Any asynchronous read or write
|
||||
* operations will be cancelled immediately, and will complete with the
|
||||
* boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
BOOST_ASIO_SYNC_OP_VOID close(boost::system::error_code& ec)
|
||||
{
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Get the native handle representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* handle. This is intended to allow access to native handle functionality
|
||||
* that is not otherwise provided.
|
||||
*/
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
return impl_.get_service().native_handle(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the handle.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read or write operations
|
||||
* to finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void cancel()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the handle.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read or write operations
|
||||
* to finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
BOOST_ASIO_SYNC_OP_VOID cancel(boost::system::error_code& ec)
|
||||
{
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the object handle.
|
||||
/**
|
||||
* This function is used to wait for the object handle to be set to the
|
||||
@@ -125,7 +330,7 @@ public:
|
||||
void wait()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->get_service().wait(this->get_implementation(), ec);
|
||||
impl_.get_service().wait(impl_.get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "wait");
|
||||
}
|
||||
|
||||
@@ -139,7 +344,7 @@ public:
|
||||
*/
|
||||
void wait(boost::system::error_code& ec)
|
||||
{
|
||||
this->get_service().wait(this->get_implementation(), ec);
|
||||
impl_.get_service().wait(impl_.get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous wait on the object handle.
|
||||
@@ -154,18 +359,31 @@ public:
|
||||
* const boost::system::error_code& error // Result of operation.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
* not, the handler will not be invoked from within this function. On
|
||||
* immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using boost::asio::post().
|
||||
*/
|
||||
template <typename WaitHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
|
||||
void (boost::system::error_code))
|
||||
async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
|
||||
{
|
||||
return this->get_service().async_wait(this->get_implementation(),
|
||||
BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
|
||||
boost::asio::async_completion<WaitHandler,
|
||||
void (boost::system::error_code)> init(handler);
|
||||
|
||||
impl_.get_service().async_wait(impl_.get_implementation(),
|
||||
init.completion_handler, impl_.get_implementation_executor());
|
||||
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_object_handle(const basic_object_handle&) BOOST_ASIO_DELETED;
|
||||
basic_object_handle& operator=(const basic_object_handle&) BOOST_ASIO_DELETED;
|
||||
|
||||
boost::asio::detail::io_object_impl<
|
||||
boost::asio::detail::win_object_handle_service, Executor> impl_;
|
||||
};
|
||||
|
||||
} // namespace windows
|
||||
|
||||
355
linx64/include/boost/asio/windows/basic_overlapped_handle.hpp
Normal file
355
linx64/include/boost/asio/windows/basic_overlapped_handle.hpp
Normal file
@@ -0,0 +1,355 @@
|
||||
//
|
||||
// windows/basic_overlapped_handle.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_WINDOWS_BASIC_OVERLAPPED_HANDLE_HPP
|
||||
#define BOOST_ASIO_WINDOWS_BASIC_OVERLAPPED_HANDLE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
|
||||
|| defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/detail/io_object_impl.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/detail/win_iocp_handle_service.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/execution_context.hpp>
|
||||
#include <boost/asio/executor.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
# include <utility>
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace windows {
|
||||
|
||||
/// Provides Windows handle functionality for objects that support
|
||||
/// overlapped I/O.
|
||||
/**
|
||||
* The windows::overlapped_handle class provides the ability to wrap a Windows
|
||||
* handle. The underlying object referred to by the handle must support
|
||||
* overlapped I/O.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*/
|
||||
template <typename Executor = executor>
|
||||
class basic_overlapped_handle
|
||||
{
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// The native representation of a handle.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef boost::asio::detail::win_iocp_handle_service::native_handle_type
|
||||
native_handle_type;
|
||||
#endif
|
||||
|
||||
/// An overlapped_handle is always the lowest layer.
|
||||
typedef basic_overlapped_handle lowest_layer_type;
|
||||
|
||||
/// Construct an overlapped handle without opening it.
|
||||
/**
|
||||
* This constructor creates an overlapped handle without opening it.
|
||||
*
|
||||
* @param ex The I/O executor that the overlapped handle will use, by default,
|
||||
* to dispatch handlers for any asynchronous operations performed on the
|
||||
* overlapped handle.
|
||||
*/
|
||||
explicit basic_overlapped_handle(const executor_type& ex)
|
||||
: impl_(ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct an overlapped handle without opening it.
|
||||
/**
|
||||
* This constructor creates an overlapped handle without opening it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the overlapped handle will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the overlapped handle.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_overlapped_handle(ExecutionContext& context,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
basic_overlapped_handle
|
||||
>::type* = 0)
|
||||
: impl_(context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct an overlapped handle on an existing native handle.
|
||||
/**
|
||||
* This constructor creates an overlapped handle object to hold an existing
|
||||
* native handle.
|
||||
*
|
||||
* @param ex The I/O executor that the overlapped handle will use, by default,
|
||||
* to dispatch handlers for any asynchronous operations performed on the
|
||||
* overlapped handle.
|
||||
*
|
||||
* @param native_handle The new underlying handle implementation.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_overlapped_handle(const executor_type& ex,
|
||||
const native_handle_type& native_handle)
|
||||
: impl_(ex)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(), native_handle, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Construct an overlapped handle on an existing native handle.
|
||||
/**
|
||||
* This constructor creates an overlapped handle object to hold an existing
|
||||
* native handle.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the overlapped handle will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the overlapped handle.
|
||||
*
|
||||
* @param native_handle The new underlying handle implementation.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_overlapped_handle(ExecutionContext& context,
|
||||
const native_handle_type& native_handle,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type* = 0)
|
||||
: impl_(context)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(), native_handle, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct an overlapped handle from another.
|
||||
/**
|
||||
* This constructor moves a handle from one object to another.
|
||||
*
|
||||
* @param other The other overlapped handle object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c overlapped_handle(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_overlapped_handle(basic_overlapped_handle&& other)
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign an overlapped handle from another.
|
||||
/**
|
||||
* This assignment operator moves a handle from one object to another.
|
||||
*
|
||||
* @param other The other overlapped handle object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c overlapped_handle(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_overlapped_handle& operator=(basic_overlapped_handle&& other)
|
||||
{
|
||||
impl_ = std::move(other.impl_);
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
executor_type get_executor() BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return impl_.get_executor();
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a reference to the lowest layer in a stack of
|
||||
* layers. Since an overlapped_handle cannot contain any further layers, it
|
||||
* simply returns a reference to itself.
|
||||
*
|
||||
* @return A reference to the lowest layer in the stack of layers. Ownership
|
||||
* is not transferred to the caller.
|
||||
*/
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Get a const reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a const reference to the lowest layer in a stack of
|
||||
* layers. Since an overlapped_handle cannot contain any further layers, it
|
||||
* simply returns a reference to itself.
|
||||
*
|
||||
* @return A const reference to the lowest layer in the stack of layers.
|
||||
* Ownership is not transferred to the caller.
|
||||
*/
|
||||
const lowest_layer_type& lowest_layer() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Assign an existing native handle to the handle.
|
||||
/*
|
||||
* This function opens the handle to hold an existing native handle.
|
||||
*
|
||||
* @param handle A native handle.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void assign(const native_handle_type& handle)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(), handle, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Assign an existing native handle to the handle.
|
||||
/*
|
||||
* This function opens the handle to hold an existing native handle.
|
||||
*
|
||||
* @param handle A native handle.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
BOOST_ASIO_SYNC_OP_VOID assign(const native_handle_type& handle,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
impl_.get_service().assign(impl_.get_implementation(), handle, ec);
|
||||
BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Determine whether the handle is open.
|
||||
bool is_open() const
|
||||
{
|
||||
return impl_.get_service().is_open(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Close the handle.
|
||||
/**
|
||||
* This function is used to close the handle. Any asynchronous read or write
|
||||
* operations will be cancelled immediately, and will complete with the
|
||||
* boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void close()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "close");
|
||||
}
|
||||
|
||||
/// Close the handle.
|
||||
/**
|
||||
* This function is used to close the handle. Any asynchronous read or write
|
||||
* operations will be cancelled immediately, and will complete with the
|
||||
* boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
BOOST_ASIO_SYNC_OP_VOID close(boost::system::error_code& ec)
|
||||
{
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Get the native handle representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* handle. This is intended to allow access to native handle functionality
|
||||
* that is not otherwise provided.
|
||||
*/
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
return impl_.get_service().native_handle(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the handle.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read or write operations
|
||||
* to finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void cancel()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the handle.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read or write operations
|
||||
* to finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
BOOST_ASIO_SYNC_OP_VOID cancel(boost::system::error_code& ec)
|
||||
{
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Protected destructor to prevent deletion through this type.
|
||||
/**
|
||||
* This function destroys the handle, cancelling any outstanding asynchronous
|
||||
* wait operations associated with the handle as if by calling @c cancel.
|
||||
*/
|
||||
~basic_overlapped_handle()
|
||||
{
|
||||
}
|
||||
|
||||
boost::asio::detail::io_object_impl<
|
||||
boost::asio::detail::win_iocp_handle_service, Executor> impl_;
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_overlapped_handle(const basic_overlapped_handle&) BOOST_ASIO_DELETED;
|
||||
basic_overlapped_handle& operator=(
|
||||
const basic_overlapped_handle&) BOOST_ASIO_DELETED;
|
||||
};
|
||||
|
||||
} // namespace windows
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
|
||||
// || defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // BOOST_ASIO_WINDOWS_BASIC_OVERLAPPED_HANDLE_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// windows/basic_random_access_handle.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 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)
|
||||
@@ -16,17 +16,11 @@
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/windows/basic_overlapped_handle.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/windows/basic_handle.hpp>
|
||||
#include <boost/asio/windows/random_access_handle_service.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -35,93 +29,136 @@ namespace windows {
|
||||
|
||||
/// Provides random-access handle functionality.
|
||||
/**
|
||||
* The windows::basic_random_access_handle class template provides asynchronous
|
||||
* and blocking random-access handle functionality.
|
||||
* The windows::basic_random_access_handle class provides asynchronous and
|
||||
* blocking random-access handle functionality.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*/
|
||||
template <typename RandomAccessHandleService = random_access_handle_service>
|
||||
template <typename Executor = executor>
|
||||
class basic_random_access_handle
|
||||
: public basic_handle<RandomAccessHandleService>
|
||||
: public basic_overlapped_handle<Executor>
|
||||
{
|
||||
public:
|
||||
/// (Deprecated: Use native_handle_type.) The native representation of a
|
||||
/// handle.
|
||||
typedef typename RandomAccessHandleService::native_handle_type native_type;
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// The native representation of a handle.
|
||||
typedef typename RandomAccessHandleService::native_handle_type
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef boost::asio::detail::win_iocp_handle_service::native_handle_type
|
||||
native_handle_type;
|
||||
#endif
|
||||
|
||||
/// Construct a basic_random_access_handle without opening it.
|
||||
/// Construct a random-access handle without opening it.
|
||||
/**
|
||||
* This constructor creates a random-access handle without opening it. The
|
||||
* handle needs to be opened before data can be written to or read from it.
|
||||
* This constructor creates a random-access handle without opening it.
|
||||
*
|
||||
* @param io_service The io_service object that the random-access handle will
|
||||
* use to dispatch handlers for any asynchronous operations performed on the
|
||||
* handle.
|
||||
* @param ex The I/O executor that the random-access handle will use, by
|
||||
* default, to dispatch handlers for any asynchronous operations performed on
|
||||
* the random-access handle.
|
||||
*/
|
||||
explicit basic_random_access_handle(boost::asio::io_service& io_service)
|
||||
: basic_handle<RandomAccessHandleService>(io_service)
|
||||
explicit basic_random_access_handle(const executor_type& ex)
|
||||
: basic_overlapped_handle<Executor>(ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_random_access_handle on an existing native handle.
|
||||
/// Construct a random-access handle without opening it.
|
||||
/**
|
||||
* This constructor creates a random-access handle without opening it. The
|
||||
* handle needs to be opened or assigned before data can be sent or received
|
||||
* on it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the random-access handle will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the random-access handle.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_random_access_handle(ExecutionContext& context,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
basic_random_access_handle
|
||||
>::type* = 0)
|
||||
: basic_overlapped_handle<Executor>(context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a random-access handle on an existing native handle.
|
||||
/**
|
||||
* This constructor creates a random-access handle object to hold an existing
|
||||
* native handle.
|
||||
*
|
||||
* @param io_service The io_service object that the random-access handle will
|
||||
* use to dispatch handlers for any asynchronous operations performed on the
|
||||
* handle.
|
||||
* @param ex The I/O executor that the random-access handle will use, by
|
||||
* default, to dispatch handlers for any asynchronous operations performed on
|
||||
* the random-access handle.
|
||||
*
|
||||
* @param handle The new underlying handle implementation.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_random_access_handle(boost::asio::io_service& io_service,
|
||||
basic_random_access_handle(const executor_type& ex,
|
||||
const native_handle_type& handle)
|
||||
: basic_handle<RandomAccessHandleService>(io_service, handle)
|
||||
: basic_overlapped_handle<Executor>(ex, handle)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a random-access handle on an existing native handle.
|
||||
/**
|
||||
* This constructor creates a random-access handle object to hold an existing
|
||||
* native handle.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the random-access handle will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the random-access handle.
|
||||
*
|
||||
* @param handle The new underlying handle implementation.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_random_access_handle(ExecutionContext& context,
|
||||
const native_handle_type& handle,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type* = 0)
|
||||
: basic_overlapped_handle<Executor>(context, handle)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_random_access_handle from another.
|
||||
/// Move-construct a random-access handle from another.
|
||||
/**
|
||||
* This constructor moves a random-access handle from one object to another.
|
||||
*
|
||||
* @param other The other basic_random_access_handle object from which the
|
||||
* @param other The other random-access handle object from which the
|
||||
* move will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_random_access_handle(io_service&)
|
||||
* constructed using the @c basic_random_access_handle(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_random_access_handle(basic_random_access_handle&& other)
|
||||
: basic_handle<RandomAccessHandleService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_random_access_handle)(other))
|
||||
: basic_overlapped_handle<Executor>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_random_access_handle from another.
|
||||
/// Move-assign a random-access handle from another.
|
||||
/**
|
||||
* This assignment operator moves a random-access handle from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_random_access_handle object from which the
|
||||
* @param other The other random-access handle object from which the
|
||||
* move will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_random_access_handle(io_service&)
|
||||
* constructed using the @c basic_random_access_handle(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_random_access_handle& operator=(basic_random_access_handle&& other)
|
||||
{
|
||||
basic_handle<RandomAccessHandleService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_random_access_handle)(other));
|
||||
basic_overlapped_handle<Executor>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
@@ -160,8 +197,8 @@ public:
|
||||
const ConstBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->get_service().write_some_at(
|
||||
this->get_implementation(), offset, buffers, ec);
|
||||
std::size_t s = this->impl_.get_service().write_some_at(
|
||||
this->impl_.get_implementation(), offset, buffers, ec);
|
||||
boost::asio::detail::throw_error(ec, "write_some_at");
|
||||
return s;
|
||||
}
|
||||
@@ -188,8 +225,8 @@ public:
|
||||
std::size_t write_some_at(uint64_t offset,
|
||||
const ConstBufferSequence& buffers, boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().write_some_at(
|
||||
this->get_implementation(), offset, buffers, ec);
|
||||
return this->impl_.get_service().write_some_at(
|
||||
this->impl_.get_implementation(), offset, buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write at the specified offset.
|
||||
@@ -212,9 +249,9 @@ public:
|
||||
* std::size_t bytes_transferred // Number of bytes written.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
* not, the handler will not be invoked from within this function. On
|
||||
* immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using boost::asio::post().
|
||||
*
|
||||
* @note The write operation may not transmit all of the data to the peer.
|
||||
* Consider using the @ref async_write_at function if you need to ensure that
|
||||
@@ -240,8 +277,15 @@ public:
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
return this->get_service().async_write_some_at(this->get_implementation(),
|
||||
offset, buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void (boost::system::error_code, std::size_t)> init(handler);
|
||||
|
||||
this->impl_.get_service().async_write_some_at(
|
||||
this->impl_.get_implementation(), offset,
|
||||
buffers, init.completion_handler,
|
||||
this->impl_.get_implementation_executor());
|
||||
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
/// Read some data from the handle at the specified offset.
|
||||
@@ -279,8 +323,8 @@ public:
|
||||
const MutableBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->get_service().read_some_at(
|
||||
this->get_implementation(), offset, buffers, ec);
|
||||
std::size_t s = this->impl_.get_service().read_some_at(
|
||||
this->impl_.get_implementation(), offset, buffers, ec);
|
||||
boost::asio::detail::throw_error(ec, "read_some_at");
|
||||
return s;
|
||||
}
|
||||
@@ -308,8 +352,8 @@ public:
|
||||
std::size_t read_some_at(uint64_t offset,
|
||||
const MutableBufferSequence& buffers, boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().read_some_at(
|
||||
this->get_implementation(), offset, buffers, ec);
|
||||
return this->impl_.get_service().read_some_at(
|
||||
this->impl_.get_implementation(), offset, buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read at the specified offset.
|
||||
@@ -332,9 +376,9 @@ public:
|
||||
* std::size_t bytes_transferred // Number of bytes read.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
* not, the handler will not be invoked from within this function. On
|
||||
* immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using boost::asio::post().
|
||||
*
|
||||
* @note The read operation may not read all of the requested number of bytes.
|
||||
* Consider using the @ref async_read_at function if you need to ensure that
|
||||
@@ -361,8 +405,15 @@ public:
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
return this->get_service().async_read_some_at(this->get_implementation(),
|
||||
offset, buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
boost::asio::async_completion<ReadHandler,
|
||||
void (boost::system::error_code, std::size_t)> init(handler);
|
||||
|
||||
this->impl_.get_service().async_read_some_at(
|
||||
this->impl_.get_implementation(), offset,
|
||||
buffers, init.completion_handler,
|
||||
this->impl_.get_implementation_executor());
|
||||
|
||||
return init.result.get();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// windows/basic_stream_handle.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 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)
|
||||
@@ -16,17 +16,11 @@
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/windows/basic_overlapped_handle.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/windows/basic_handle.hpp>
|
||||
#include <boost/asio/windows/stream_handle_service.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -35,8 +29,8 @@ namespace windows {
|
||||
|
||||
/// Provides stream-oriented handle functionality.
|
||||
/**
|
||||
* The windows::basic_stream_handle class template provides asynchronous and
|
||||
* blocking stream-oriented handle functionality.
|
||||
* The windows::basic_stream_handle class provides asynchronous and blocking
|
||||
* stream-oriented handle functionality.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
@@ -45,82 +39,126 @@ namespace windows {
|
||||
* @par Concepts:
|
||||
* AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream.
|
||||
*/
|
||||
template <typename StreamHandleService = stream_handle_service>
|
||||
template <typename Executor = executor>
|
||||
class basic_stream_handle
|
||||
: public basic_handle<StreamHandleService>
|
||||
: public basic_overlapped_handle<Executor>
|
||||
{
|
||||
public:
|
||||
/// (Deprecated: Use native_handle_type.) The native representation of a
|
||||
/// handle.
|
||||
typedef typename StreamHandleService::native_handle_type native_type;
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// The native representation of a handle.
|
||||
typedef typename StreamHandleService::native_handle_type native_handle_type;
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef boost::asio::detail::win_iocp_handle_service::native_handle_type
|
||||
native_handle_type;
|
||||
#endif
|
||||
|
||||
/// Construct a basic_stream_handle without opening it.
|
||||
/// Construct a stream handle without opening it.
|
||||
/**
|
||||
* This constructor creates a stream handle without opening it. The handle
|
||||
* needs to be opened and then connected or accepted before data can be sent
|
||||
* or received on it.
|
||||
* This constructor creates a stream handle without opening it.
|
||||
*
|
||||
* @param io_service The io_service object that the stream handle will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the handle.
|
||||
* @param ex The I/O executor that the stream handle will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the stream
|
||||
* handle.
|
||||
*/
|
||||
explicit basic_stream_handle(boost::asio::io_service& io_service)
|
||||
: basic_handle<StreamHandleService>(io_service)
|
||||
explicit basic_stream_handle(const executor_type& ex)
|
||||
: basic_overlapped_handle<Executor>(ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_stream_handle on an existing native handle.
|
||||
/// Construct a stream handle without opening it.
|
||||
/**
|
||||
* This constructor creates a stream handle without opening it. The handle
|
||||
* needs to be opened or assigned before data can be sent or received on it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the stream handle will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the stream handle.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_stream_handle(ExecutionContext& context,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
basic_stream_handle
|
||||
>::type* = 0)
|
||||
: basic_overlapped_handle<Executor>(context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a stream handle on an existing native handle.
|
||||
/**
|
||||
* This constructor creates a stream handle object to hold an existing native
|
||||
* handle.
|
||||
*
|
||||
* @param io_service The io_service object that the stream handle will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the handle.
|
||||
* @param ex The I/O executor that the stream handle will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the stream
|
||||
* handle.
|
||||
*
|
||||
* @param handle The new underlying handle implementation.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_stream_handle(boost::asio::io_service& io_service,
|
||||
const native_handle_type& handle)
|
||||
: basic_handle<StreamHandleService>(io_service, handle)
|
||||
basic_stream_handle(const executor_type& ex, const native_handle_type& handle)
|
||||
: basic_overlapped_handle<Executor>(ex, handle)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a stream handle on an existing native handle.
|
||||
/**
|
||||
* This constructor creates a stream handle object to hold an existing native
|
||||
* handle.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the stream handle will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the stream handle.
|
||||
*
|
||||
* @param handle The new underlying handle implementation.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_stream_handle(ExecutionContext& context,
|
||||
const native_handle_type& handle,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type* = 0)
|
||||
: basic_overlapped_handle<Executor>(context, handle)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_stream_handle from another.
|
||||
/// Move-construct a stream handle from another.
|
||||
/**
|
||||
* This constructor moves a stream handle from one object to another.
|
||||
*
|
||||
* @param other The other basic_stream_handle object from which the move
|
||||
* @param other The other stream handle object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_stream_handle(io_service&) constructor.
|
||||
* constructed using the @c basic_stream_handle(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_stream_handle(basic_stream_handle&& other)
|
||||
: basic_handle<StreamHandleService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_stream_handle)(other))
|
||||
: basic_overlapped_handle<Executor>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_stream_handle from another.
|
||||
/// Move-assign a stream handle from another.
|
||||
/**
|
||||
* This assignment operator moves a stream handle from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_stream_handle object from which the move
|
||||
* will occur.
|
||||
* @param other The other stream handle object from which the move will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_stream_handle(io_service&) constructor.
|
||||
* constructed using the @c basic_stream_handle(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_stream_handle& operator=(basic_stream_handle&& other)
|
||||
{
|
||||
basic_handle<StreamHandleService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_stream_handle)(other));
|
||||
basic_overlapped_handle<Executor>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
@@ -156,8 +194,8 @@ public:
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->get_service().write_some(
|
||||
this->get_implementation(), buffers, ec);
|
||||
std::size_t s = this->impl_.get_service().write_some(
|
||||
this->impl_.get_implementation(), buffers, ec);
|
||||
boost::asio::detail::throw_error(ec, "write_some");
|
||||
return s;
|
||||
}
|
||||
@@ -182,8 +220,8 @@ public:
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().write_some(
|
||||
this->get_implementation(), buffers, ec);
|
||||
return this->impl_.get_service().write_some(
|
||||
this->impl_.get_implementation(), buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write.
|
||||
@@ -204,9 +242,9 @@ public:
|
||||
* std::size_t bytes_transferred // Number of bytes written.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
* not, the handler will not be invoked from within this function. On
|
||||
* immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using boost::asio::post().
|
||||
*
|
||||
* @note The write operation may not transmit all of the data to the peer.
|
||||
* Consider using the @ref async_write function if you need to ensure that all
|
||||
@@ -231,8 +269,15 @@ public:
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
return this->get_service().async_write_some(this->get_implementation(),
|
||||
buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void (boost::system::error_code, std::size_t)> init(handler);
|
||||
|
||||
this->impl_.get_service().async_write_some(
|
||||
this->impl_.get_implementation(),
|
||||
buffers, init.completion_handler,
|
||||
this->impl_.get_implementation_executor());
|
||||
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
/// Read some data from the handle.
|
||||
@@ -267,8 +312,8 @@ public:
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->get_service().read_some(
|
||||
this->get_implementation(), buffers, ec);
|
||||
std::size_t s = this->impl_.get_service().read_some(
|
||||
this->impl_.get_implementation(), buffers, ec);
|
||||
boost::asio::detail::throw_error(ec, "read_some");
|
||||
return s;
|
||||
}
|
||||
@@ -294,8 +339,8 @@ public:
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().read_some(
|
||||
this->get_implementation(), buffers, ec);
|
||||
return this->impl_.get_service().read_some(
|
||||
this->impl_.get_implementation(), buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read.
|
||||
@@ -316,9 +361,9 @@ public:
|
||||
* std::size_t bytes_transferred // Number of bytes read.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
* not, the handler will not be invoked from within this function. On
|
||||
* immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using boost::asio::post().
|
||||
*
|
||||
* @note The read operation may not read all of the requested number of bytes.
|
||||
* Consider using the @ref async_read function if you need to ensure that the
|
||||
@@ -344,8 +389,15 @@ public:
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
return this->get_service().async_read_some(this->get_implementation(),
|
||||
buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
boost::asio::async_completion<ReadHandler,
|
||||
void (boost::system::error_code, std::size_t)> init(handler);
|
||||
|
||||
this->impl_.get_service().async_read_some(
|
||||
this->impl_.get_implementation(),
|
||||
buffers, init.completion_handler,
|
||||
this->impl_.get_implementation_executor());
|
||||
|
||||
return init.result.get();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// windows/object_handle.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2011 Boris Schaeling (boris@highscore.de)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
//
|
||||
// windows/object_handle_service.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2011 Boris Schaeling (boris@highscore.de)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_WINDOWS_OBJECT_HANDLE_SERVICE_HPP
|
||||
#define BOOST_ASIO_WINDOWS_OBJECT_HANDLE_SERVICE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/detail/win_object_handle_service.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace windows {
|
||||
|
||||
/// Default service implementation for an object handle.
|
||||
class object_handle_service
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
: public boost::asio::io_service::service
|
||||
#else
|
||||
: public boost::asio::detail::service_base<object_handle_service>
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The unique service identifier.
|
||||
static boost::asio::io_service::id id;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// The type of the platform-specific implementation.
|
||||
typedef detail::win_object_handle_service service_impl_type;
|
||||
|
||||
public:
|
||||
/// The type of an object handle implementation.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined implementation_type;
|
||||
#else
|
||||
typedef service_impl_type::implementation_type implementation_type;
|
||||
#endif
|
||||
|
||||
/// The native handle type.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef service_impl_type::native_handle_type native_handle_type;
|
||||
#endif
|
||||
|
||||
/// Construct a new object handle service for the specified io_service.
|
||||
explicit object_handle_service(boost::asio::io_service& io_service)
|
||||
: boost::asio::detail::service_base<object_handle_service>(io_service),
|
||||
service_impl_(io_service)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a new object handle implementation.
|
||||
void construct(implementation_type& impl)
|
||||
{
|
||||
service_impl_.construct(impl);
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a new object handle implementation.
|
||||
void move_construct(implementation_type& impl,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
service_impl_.move_construct(impl, other_impl);
|
||||
}
|
||||
|
||||
/// Move-assign from another object handle implementation.
|
||||
void move_assign(implementation_type& impl,
|
||||
object_handle_service& other_service,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Destroy an object handle implementation.
|
||||
void destroy(implementation_type& impl)
|
||||
{
|
||||
service_impl_.destroy(impl);
|
||||
}
|
||||
|
||||
/// Assign an existing native handle to an object handle.
|
||||
boost::system::error_code assign(implementation_type& impl,
|
||||
const native_handle_type& handle, boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.assign(impl, handle, ec);
|
||||
}
|
||||
|
||||
/// Determine whether the handle is open.
|
||||
bool is_open(const implementation_type& impl) const
|
||||
{
|
||||
return service_impl_.is_open(impl);
|
||||
}
|
||||
|
||||
/// Close an object handle implementation.
|
||||
boost::system::error_code close(implementation_type& impl,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.close(impl, ec);
|
||||
}
|
||||
|
||||
/// Get the native handle implementation.
|
||||
native_handle_type native_handle(implementation_type& impl)
|
||||
{
|
||||
return service_impl_.native_handle(impl);
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the handle.
|
||||
boost::system::error_code cancel(implementation_type& impl,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.cancel(impl, ec);
|
||||
}
|
||||
|
||||
// Wait for a signaled state.
|
||||
void wait(implementation_type& impl, boost::system::error_code& ec)
|
||||
{
|
||||
service_impl_.wait(impl, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous wait.
|
||||
template <typename WaitHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
|
||||
void (boost::system::error_code))
|
||||
async_wait(implementation_type& impl,
|
||||
BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
|
||||
{
|
||||
boost::asio::detail::async_result_init<
|
||||
WaitHandler, void (boost::system::error_code)> init(
|
||||
BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
|
||||
|
||||
service_impl_.async_wait(impl, init.handler);
|
||||
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
private:
|
||||
// Destroy all user-defined handler objects owned by the service.
|
||||
void shutdown_service()
|
||||
{
|
||||
service_impl_.shutdown_service();
|
||||
}
|
||||
|
||||
// The platform-specific implementation.
|
||||
service_impl_type service_impl_;
|
||||
};
|
||||
|
||||
} // namespace windows
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // BOOST_ASIO_WINDOWS_OBJECT_HANDLE_SERVICE_HPP
|
||||
41
linx64/include/boost/asio/windows/overlapped_handle.hpp
Normal file
41
linx64/include/boost/asio/windows/overlapped_handle.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// windows/overlapped_handle.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_WINDOWS_OVERLAPPED_HANDLE_HPP
|
||||
#define BOOST_ASIO_WINDOWS_OVERLAPPED_HANDLE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
|
||||
|| defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <boost/asio/windows/basic_overlapped_handle.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace windows {
|
||||
|
||||
/// Typedef for the typical usage of an overlapped handle.
|
||||
typedef basic_overlapped_handle<> overlapped_handle;
|
||||
|
||||
} // namespace windows
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
|
||||
// || defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // BOOST_ASIO_WINDOWS_OVERLAPPED_HANDLE_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// windows/overlapped_ptr.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 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)
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/win_iocp_overlapped_ptr.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -50,10 +50,24 @@ public:
|
||||
}
|
||||
|
||||
/// Construct an overlapped_ptr to contain the specified handler.
|
||||
template <typename Handler>
|
||||
explicit overlapped_ptr(boost::asio::io_service& io_service,
|
||||
BOOST_ASIO_MOVE_ARG(Handler) handler)
|
||||
: impl_(io_service, BOOST_ASIO_MOVE_CAST(Handler)(handler))
|
||||
template <typename ExecutionContext, typename Handler>
|
||||
explicit overlapped_ptr(ExecutionContext& context,
|
||||
BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type* = 0)
|
||||
: impl_(context.get_executor(), BOOST_ASIO_MOVE_CAST(Handler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct an overlapped_ptr to contain the specified handler.
|
||||
template <typename Executor, typename Handler>
|
||||
explicit overlapped_ptr(const Executor& ex,
|
||||
BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
typename enable_if<
|
||||
is_executor<Executor>::value
|
||||
>::type* = 0)
|
||||
: impl_(ex, BOOST_ASIO_MOVE_CAST(Handler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -70,11 +84,24 @@ public:
|
||||
|
||||
/// Reset to contain the specified handler, freeing any current OVERLAPPED
|
||||
/// object.
|
||||
template <typename Handler>
|
||||
void reset(boost::asio::io_service& io_service,
|
||||
BOOST_ASIO_MOVE_ARG(Handler) handler)
|
||||
template <typename ExecutionContext, typename Handler>
|
||||
void reset(ExecutionContext& context, BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type* = 0)
|
||||
{
|
||||
impl_.reset(io_service, BOOST_ASIO_MOVE_CAST(Handler)(handler));
|
||||
impl_.reset(context.get_executor(), BOOST_ASIO_MOVE_CAST(Handler)(handler));
|
||||
}
|
||||
|
||||
/// Reset to contain the specified handler, freeing any current OVERLAPPED
|
||||
/// object.
|
||||
template <typename Executor, typename Handler>
|
||||
void reset(const Executor& ex, BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
typename enable_if<
|
||||
is_executor<Executor>::value
|
||||
>::type* = 0)
|
||||
{
|
||||
impl_.reset(ex, BOOST_ASIO_MOVE_CAST(Handler)(handler));
|
||||
}
|
||||
|
||||
/// Get the contained OVERLAPPED object.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// windows/random_access_handle.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 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)
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
//
|
||||
// windows/random_access_handle_service.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP
|
||||
#define BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/detail/cstdint.hpp>
|
||||
#include <boost/asio/detail/win_iocp_handle_service.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace windows {
|
||||
|
||||
/// Default service implementation for a random-access handle.
|
||||
class random_access_handle_service
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
: public boost::asio::io_service::service
|
||||
#else
|
||||
: public boost::asio::detail::service_base<random_access_handle_service>
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The unique service identifier.
|
||||
static boost::asio::io_service::id id;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// The type of the platform-specific implementation.
|
||||
typedef detail::win_iocp_handle_service service_impl_type;
|
||||
|
||||
public:
|
||||
/// The type of a random-access handle implementation.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined implementation_type;
|
||||
#else
|
||||
typedef service_impl_type::implementation_type implementation_type;
|
||||
#endif
|
||||
|
||||
/// (Deprecated: Use native_handle_type.) The native handle type.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_type;
|
||||
#else
|
||||
typedef service_impl_type::native_handle_type native_type;
|
||||
#endif
|
||||
|
||||
/// The native handle type.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef service_impl_type::native_handle_type native_handle_type;
|
||||
#endif
|
||||
|
||||
/// Construct a new random-access handle service for the specified io_service.
|
||||
explicit random_access_handle_service(boost::asio::io_service& io_service)
|
||||
: boost::asio::detail::service_base<
|
||||
random_access_handle_service>(io_service),
|
||||
service_impl_(io_service)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a new random-access handle implementation.
|
||||
void construct(implementation_type& impl)
|
||||
{
|
||||
service_impl_.construct(impl);
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a new random-access handle implementation.
|
||||
void move_construct(implementation_type& impl,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
service_impl_.move_construct(impl, other_impl);
|
||||
}
|
||||
|
||||
/// Move-assign from another random-access handle implementation.
|
||||
void move_assign(implementation_type& impl,
|
||||
random_access_handle_service& other_service,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Destroy a random-access handle implementation.
|
||||
void destroy(implementation_type& impl)
|
||||
{
|
||||
service_impl_.destroy(impl);
|
||||
}
|
||||
|
||||
/// Assign an existing native handle to a random-access handle.
|
||||
boost::system::error_code assign(implementation_type& impl,
|
||||
const native_handle_type& handle, boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.assign(impl, handle, ec);
|
||||
}
|
||||
|
||||
/// Determine whether the handle is open.
|
||||
bool is_open(const implementation_type& impl) const
|
||||
{
|
||||
return service_impl_.is_open(impl);
|
||||
}
|
||||
|
||||
/// Close a random-access handle implementation.
|
||||
boost::system::error_code close(implementation_type& impl,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.close(impl, ec);
|
||||
}
|
||||
|
||||
/// (Deprecated: Use native_handle().) Get the native handle implementation.
|
||||
native_type native(implementation_type& impl)
|
||||
{
|
||||
return service_impl_.native_handle(impl);
|
||||
}
|
||||
|
||||
/// Get the native handle implementation.
|
||||
native_handle_type native_handle(implementation_type& impl)
|
||||
{
|
||||
return service_impl_.native_handle(impl);
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the handle.
|
||||
boost::system::error_code cancel(implementation_type& impl,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.cancel(impl, ec);
|
||||
}
|
||||
|
||||
/// Write the given data at the specified offset.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some_at(implementation_type& impl, uint64_t offset,
|
||||
const ConstBufferSequence& buffers, boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.write_some_at(impl, offset, buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write at the specified offset.
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
|
||||
void (boost::system::error_code, std::size_t))
|
||||
async_write_some_at(implementation_type& impl,
|
||||
uint64_t offset, const ConstBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
boost::asio::detail::async_result_init<
|
||||
WriteHandler, void (boost::system::error_code, std::size_t)> init(
|
||||
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
|
||||
service_impl_.async_write_some_at(impl, offset, buffers, init.handler);
|
||||
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
/// Read some data from the specified offset.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some_at(implementation_type& impl, uint64_t offset,
|
||||
const MutableBufferSequence& buffers, boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.read_some_at(impl, offset, buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read at the specified offset.
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
||||
void (boost::system::error_code, std::size_t))
|
||||
async_read_some_at(implementation_type& impl,
|
||||
uint64_t offset, const MutableBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
boost::asio::detail::async_result_init<
|
||||
ReadHandler, void (boost::system::error_code, std::size_t)> init(
|
||||
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
|
||||
service_impl_.async_read_some_at(impl, offset, buffers, init.handler);
|
||||
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
private:
|
||||
// Destroy all user-defined handler objects owned by the service.
|
||||
void shutdown_service()
|
||||
{
|
||||
service_impl_.shutdown_service();
|
||||
}
|
||||
|
||||
// The platform-specific implementation.
|
||||
service_impl_type service_impl_;
|
||||
};
|
||||
|
||||
} // namespace windows
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// windows/stream_handle.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 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)
|
||||
|
||||
@@ -1,220 +0,0 @@
|
||||
//
|
||||
// windows/stream_handle_service.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_WINDOWS_STREAM_HANDLE_SERVICE_HPP
|
||||
#define BOOST_ASIO_WINDOWS_STREAM_HANDLE_SERVICE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/detail/win_iocp_handle_service.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace windows {
|
||||
|
||||
/// Default service implementation for a stream handle.
|
||||
class stream_handle_service
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
: public boost::asio::io_service::service
|
||||
#else
|
||||
: public boost::asio::detail::service_base<stream_handle_service>
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The unique service identifier.
|
||||
static boost::asio::io_service::id id;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// The type of the platform-specific implementation.
|
||||
typedef detail::win_iocp_handle_service service_impl_type;
|
||||
|
||||
public:
|
||||
/// The type of a stream handle implementation.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined implementation_type;
|
||||
#else
|
||||
typedef service_impl_type::implementation_type implementation_type;
|
||||
#endif
|
||||
|
||||
/// (Deprecated: Use native_handle_type.) The native handle type.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_type;
|
||||
#else
|
||||
typedef service_impl_type::native_handle_type native_type;
|
||||
#endif
|
||||
|
||||
/// The native handle type.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef service_impl_type::native_handle_type native_handle_type;
|
||||
#endif
|
||||
|
||||
/// Construct a new stream handle service for the specified io_service.
|
||||
explicit stream_handle_service(boost::asio::io_service& io_service)
|
||||
: boost::asio::detail::service_base<stream_handle_service>(io_service),
|
||||
service_impl_(io_service)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a new stream handle implementation.
|
||||
void construct(implementation_type& impl)
|
||||
{
|
||||
service_impl_.construct(impl);
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a new stream handle implementation.
|
||||
void move_construct(implementation_type& impl,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
service_impl_.move_construct(impl, other_impl);
|
||||
}
|
||||
|
||||
/// Move-assign from another stream handle implementation.
|
||||
void move_assign(implementation_type& impl,
|
||||
stream_handle_service& other_service,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Destroy a stream handle implementation.
|
||||
void destroy(implementation_type& impl)
|
||||
{
|
||||
service_impl_.destroy(impl);
|
||||
}
|
||||
|
||||
/// Assign an existing native handle to a stream handle.
|
||||
boost::system::error_code assign(implementation_type& impl,
|
||||
const native_handle_type& handle, boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.assign(impl, handle, ec);
|
||||
}
|
||||
|
||||
/// Determine whether the handle is open.
|
||||
bool is_open(const implementation_type& impl) const
|
||||
{
|
||||
return service_impl_.is_open(impl);
|
||||
}
|
||||
|
||||
/// Close a stream handle implementation.
|
||||
boost::system::error_code close(implementation_type& impl,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.close(impl, ec);
|
||||
}
|
||||
|
||||
/// (Deprecated: Use native_handle().) Get the native handle implementation.
|
||||
native_type native(implementation_type& impl)
|
||||
{
|
||||
return service_impl_.native_handle(impl);
|
||||
}
|
||||
|
||||
/// Get the native handle implementation.
|
||||
native_handle_type native_handle(implementation_type& impl)
|
||||
{
|
||||
return service_impl_.native_handle(impl);
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the handle.
|
||||
boost::system::error_code cancel(implementation_type& impl,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.cancel(impl, ec);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(implementation_type& impl,
|
||||
const ConstBufferSequence& buffers, boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.write_some(impl, buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write.
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
|
||||
void (boost::system::error_code, std::size_t))
|
||||
async_write_some(implementation_type& impl,
|
||||
const ConstBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
boost::asio::detail::async_result_init<
|
||||
WriteHandler, void (boost::system::error_code, std::size_t)> init(
|
||||
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
|
||||
service_impl_.async_write_some(impl, buffers, init.handler);
|
||||
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
/// Read some data from the stream.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(implementation_type& impl,
|
||||
const MutableBufferSequence& buffers, boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.read_some(impl, buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read.
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
||||
void (boost::system::error_code, std::size_t))
|
||||
async_read_some(implementation_type& impl,
|
||||
const MutableBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
boost::asio::detail::async_result_init<
|
||||
ReadHandler, void (boost::system::error_code, std::size_t)> init(
|
||||
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
|
||||
service_impl_.async_read_some(impl, buffers, init.handler);
|
||||
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
private:
|
||||
// Destroy all user-defined handler objects owned by the service.
|
||||
void shutdown_service()
|
||||
{
|
||||
service_impl_.shutdown_service();
|
||||
}
|
||||
|
||||
// The platform-specific implementation.
|
||||
service_impl_type service_impl_;
|
||||
};
|
||||
|
||||
} // namespace windows
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // BOOST_ASIO_WINDOWS_STREAM_HANDLE_SERVICE_HPP
|
||||
Reference in New Issue
Block a user