summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/include/asio/detail/winrt_ssocket_service_base.hpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/include/asio/detail/winrt_ssocket_service_base.hpp')
-rw-r--r--3rdparty/asio/include/asio/detail/winrt_ssocket_service_base.hpp73
1 files changed, 40 insertions, 33 deletions
diff --git a/3rdparty/asio/include/asio/detail/winrt_ssocket_service_base.hpp b/3rdparty/asio/include/asio/detail/winrt_ssocket_service_base.hpp
index 9192ffbc138..c752da80e2a 100644
--- a/3rdparty/asio/include/asio/detail/winrt_ssocket_service_base.hpp
+++ b/3rdparty/asio/include/asio/detail/winrt_ssocket_service_base.hpp
@@ -2,7 +2,7 @@
// detail/winrt_ssocket_service_base.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2024 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)
@@ -21,7 +21,7 @@
#include "asio/buffer.hpp"
#include "asio/error.hpp"
-#include "asio/io_context.hpp"
+#include "asio/execution_context.hpp"
#include "asio/socket_base.hpp"
#include "asio/detail/buffer_sequence_adapter.hpp"
#include "asio/detail/memory.hpp"
@@ -30,6 +30,12 @@
#include "asio/detail/winrt_socket_recv_op.hpp"
#include "asio/detail/winrt_socket_send_op.hpp"
+#if defined(ASIO_HAS_IOCP)
+# include "asio/detail/win_iocp_io_context.hpp"
+#else // defined(ASIO_HAS_IOCP)
+# include "asio/detail/scheduler.hpp"
+#endif // defined(ASIO_HAS_IOCP)
+
#include "asio/detail/push_options.hpp"
namespace asio {
@@ -61,8 +67,7 @@ public:
};
// Constructor.
- ASIO_DECL winrt_ssocket_service_base(
- asio::io_context& io_context);
+ ASIO_DECL winrt_ssocket_service_base(execution_context& context);
// Destroy all user-defined handler objects owned by the service.
ASIO_DECL void base_shutdown();
@@ -72,7 +77,7 @@ public:
// Move-construct a new socket implementation.
ASIO_DECL void base_move_construct(base_implementation_type& impl,
- base_implementation_type& other_impl);
+ base_implementation_type& other_impl) noexcept;
// Move-assign from another socket implementation.
ASIO_DECL void base_move_assign(base_implementation_type& impl,
@@ -92,6 +97,10 @@ public:
ASIO_DECL asio::error_code close(
base_implementation_type& impl, asio::error_code& ec);
+ // Release ownership of the socket.
+ ASIO_DECL native_handle_type release(
+ base_implementation_type& impl, asio::error_code& ec);
+
// Get the native socket representation.
native_handle_type native_handle(base_implementation_type& impl)
{
@@ -159,14 +168,6 @@ public:
return ec;
}
- // Disable sends or receives on the socket.
- asio::error_code shutdown(base_implementation_type&,
- socket_base::shutdown_type, asio::error_code& ec)
- {
- ec = asio::error::operation_not_supported;
- return ec;
- }
-
// Send the given data to the peer.
template <typename ConstBufferSequence>
std::size_t send(base_implementation_type& impl,
@@ -188,21 +189,21 @@ public:
// Start an asynchronous send. The data being sent must be valid for the
// lifetime of the asynchronous operation.
- template <typename ConstBufferSequence, typename Handler>
+ template <typename ConstBufferSequence, typename Handler, typename IoExecutor>
void async_send(base_implementation_type& impl,
- const ConstBufferSequence& buffers,
- socket_base::message_flags flags, Handler& handler)
+ const ConstBufferSequence& buffers, socket_base::message_flags flags,
+ Handler& handler, const IoExecutor& io_ex)
{
bool is_continuation =
asio_handler_cont_helpers::is_continuation(handler);
// Allocate and construct an operation to wrap the handler.
- typedef winrt_socket_send_op<ConstBufferSequence, Handler> op;
+ typedef winrt_socket_send_op<ConstBufferSequence, Handler, IoExecutor> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
- p.p = new (p.v) op(buffers, handler);
+ p.p = new (p.v) op(buffers, handler, io_ex);
- ASIO_HANDLER_CREATION((io_context_.context(),
+ ASIO_HANDLER_CREATION((scheduler_.context(),
*p.p, "socket", &impl, 0, "async_send"));
start_send_op(impl,
@@ -213,13 +214,13 @@ public:
}
// Start an asynchronous wait until data can be sent without blocking.
- template <typename Handler>
+ template <typename Handler, typename IoExecutor>
void async_send(base_implementation_type&, const null_buffers&,
- socket_base::message_flags, Handler& handler)
+ socket_base::message_flags, Handler& handler, const IoExecutor& io_ex)
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
- io_context_.get_io_context().post(
+ asio::post(io_ex,
detail::bind_handler(handler, ec, bytes_transferred));
}
@@ -244,21 +245,22 @@ public:
// Start an asynchronous receive. The buffer for the data being received
// must be valid for the lifetime of the asynchronous operation.
- template <typename MutableBufferSequence, typename Handler>
+ template <typename MutableBufferSequence,
+ typename Handler, typename IoExecutor>
void async_receive(base_implementation_type& impl,
- const MutableBufferSequence& buffers,
- socket_base::message_flags flags, Handler& handler)
+ const MutableBufferSequence& buffers, socket_base::message_flags flags,
+ Handler& handler, const IoExecutor& io_ex)
{
bool is_continuation =
asio_handler_cont_helpers::is_continuation(handler);
// Allocate and construct an operation to wrap the handler.
- typedef winrt_socket_recv_op<MutableBufferSequence, Handler> op;
+ typedef winrt_socket_recv_op<MutableBufferSequence, Handler, IoExecutor> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
- p.p = new (p.v) op(buffers, handler);
+ p.p = new (p.v) op(buffers, handler, io_ex);
- ASIO_HANDLER_CREATION((io_context_.context(),
+ ASIO_HANDLER_CREATION((scheduler_.context(),
*p.p, "socket", &impl, 0, "async_receive"));
start_receive_op(impl,
@@ -269,13 +271,13 @@ public:
}
// Wait until data can be received without blocking.
- template <typename Handler>
+ template <typename Handler, typename IoExecutor>
void async_receive(base_implementation_type&, const null_buffers&,
- socket_base::message_flags, Handler& handler)
+ socket_base::message_flags, Handler& handler, const IoExecutor& io_ex)
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
- io_context_.get_io_context().post(
+ asio::post(io_ex,
detail::bind_handler(handler, ec, bytes_transferred));
}
@@ -328,8 +330,13 @@ protected:
winrt_async_op<Windows::Storage::Streams::IBuffer^>* op,
bool is_continuation);
- // The io_context implementation used for delivering completions.
- io_context_impl& io_context_;
+ // The scheduler implementation used for delivering completions.
+#if defined(ASIO_HAS_IOCP)
+ typedef class win_iocp_io_context scheduler_impl;
+#else
+ typedef class scheduler scheduler_impl;
+#endif
+ scheduler_impl& scheduler_;
// The manager that keeps track of outstanding operations.
winrt_async_manager& async_manager_;