forked from andreasbuhr/cppcoro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocket_disconnect_operation.hpp
More file actions
85 lines (60 loc) · 2.29 KB
/
Copy pathsocket_disconnect_operation.hpp
File metadata and controls
85 lines (60 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) Lewis Baker
// Licenced under MIT license. See LICENSE.txt for details.
///////////////////////////////////////////////////////////////////////////////
#ifndef CPPCORO_NET_SOCKET_DISCONNECT_OPERATION_HPP_INCLUDED
#define CPPCORO_NET_SOCKET_DISCONNECT_OPERATION_HPP_INCLUDED
#include <cppcoro/config.hpp>
#include <cppcoro/cancellation_token.hpp>
#if CPPCORO_OS_WINNT
# include <cppcoro/detail/win32.hpp>
# include <cppcoro/detail/win32_overlapped_operation.hpp>
namespace cppcoro
{
namespace net
{
class socket;
class socket_disconnect_operation_impl
{
public:
socket_disconnect_operation_impl(socket& socket) noexcept
: m_socket(socket)
{}
bool try_start(cppcoro::detail::win32_overlapped_operation_base& operation) noexcept;
void cancel(cppcoro::detail::win32_overlapped_operation_base& operation) noexcept;
void get_result(cppcoro::detail::win32_overlapped_operation_base& operation);
private:
socket& m_socket;
};
class socket_disconnect_operation
: public cppcoro::detail::win32_overlapped_operation<socket_disconnect_operation>
{
public:
socket_disconnect_operation(socket& socket) noexcept
: m_impl(socket)
{}
private:
friend class cppcoro::detail::win32_overlapped_operation<socket_disconnect_operation>;
bool try_start() noexcept { return m_impl.try_start(*this); }
void get_result() { m_impl.get_result(*this); }
socket_disconnect_operation_impl m_impl;
};
class socket_disconnect_operation_cancellable
: public cppcoro::detail::win32_overlapped_operation_cancellable<socket_disconnect_operation_cancellable>
{
public:
socket_disconnect_operation_cancellable(socket& socket, cancellation_token&& ct) noexcept
: cppcoro::detail::win32_overlapped_operation_cancellable<socket_disconnect_operation_cancellable>(std::move(ct))
, m_impl(socket)
{}
private:
friend class cppcoro::detail::win32_overlapped_operation_cancellable<socket_disconnect_operation_cancellable>;
bool try_start() noexcept { return m_impl.try_start(*this); }
void cancel() noexcept { m_impl.cancel(*this); }
void get_result() { m_impl.get_result(*this); }
socket_disconnect_operation_impl m_impl;
};
}
}
#endif // CPPCORO_OS_WINNT
#endif