File indexing completed on 2025-01-30 10:03:46
0001
0002
0003
0004
0005 #ifndef CPPCORO_NET_SOCKET_DISCONNECT_OPERATION_HPP_INCLUDED
0006 #define CPPCORO_NET_SOCKET_DISCONNECT_OPERATION_HPP_INCLUDED
0007
0008 #include <cppcoro/config.hpp>
0009 #include <cppcoro/cancellation_token.hpp>
0010
0011 #if CPPCORO_OS_WINNT
0012 # include <cppcoro/detail/win32.hpp>
0013 # include <cppcoro/detail/win32_overlapped_operation.hpp>
0014
0015 namespace cppcoro
0016 {
0017 namespace net
0018 {
0019 class socket;
0020
0021 class socket_disconnect_operation_impl
0022 {
0023 public:
0024
0025 socket_disconnect_operation_impl(socket& socket) noexcept
0026 : m_socket(socket)
0027 {}
0028
0029 bool try_start(cppcoro::detail::win32_overlapped_operation_base& operation) noexcept;
0030 void cancel(cppcoro::detail::win32_overlapped_operation_base& operation) noexcept;
0031 void get_result(cppcoro::detail::win32_overlapped_operation_base& operation);
0032
0033 private:
0034
0035 socket& m_socket;
0036
0037 };
0038
0039 class socket_disconnect_operation
0040 : public cppcoro::detail::win32_overlapped_operation<socket_disconnect_operation>
0041 {
0042 public:
0043
0044 socket_disconnect_operation(socket& socket) noexcept
0045 : m_impl(socket)
0046 {}
0047
0048 private:
0049
0050 friend class cppcoro::detail::win32_overlapped_operation<socket_disconnect_operation>;
0051
0052 bool try_start() noexcept { return m_impl.try_start(*this); }
0053 void get_result() { m_impl.get_result(*this); }
0054
0055 socket_disconnect_operation_impl m_impl;
0056
0057 };
0058
0059 class socket_disconnect_operation_cancellable
0060 : public cppcoro::detail::win32_overlapped_operation_cancellable<socket_disconnect_operation_cancellable>
0061 {
0062 public:
0063
0064 socket_disconnect_operation_cancellable(socket& socket, cancellation_token&& ct) noexcept
0065 : cppcoro::detail::win32_overlapped_operation_cancellable<socket_disconnect_operation_cancellable>(std::move(ct))
0066 , m_impl(socket)
0067 {}
0068
0069 private:
0070
0071 friend class cppcoro::detail::win32_overlapped_operation_cancellable<socket_disconnect_operation_cancellable>;
0072
0073 bool try_start() noexcept { return m_impl.try_start(*this); }
0074 void cancel() noexcept { m_impl.cancel(*this); }
0075 void get_result() { m_impl.get_result(*this); }
0076
0077 socket_disconnect_operation_impl m_impl;
0078
0079 };
0080 }
0081 }
0082
0083 #endif
0084
0085 #endif