join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
async_operation.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_CORE_ASYNC_OPERATION_HPP
26#define JOIN_CORE_ASYNC_OPERATION_HPP
27
28// libjoin.
29#include <join/io_operation.hpp>
30#include <join/function.hpp>
31#include <join/protocol.hpp>
32
33// C++.
34#include <system_error>
35#include <algorithm>
36
37// C.
38#include <sys/socket.h>
39#include <cstddef>
40
41namespace join
42{
46 template <class Protocol, class ProactorType>
48 {
50 using Wait = Function<void (const std::error_code&, bool), 16>;
51
54
57 };
58
62 template <class Protocol, class ProactorType>
64 {
65 using Endpoint = typename Protocol::Endpoint;
66 using Socket = typename Protocol::Socket;
67
69 using Accept = Function<void (Socket&&, const std::error_code&, bool), 16>;
70
73
76
79
81 socklen_t remoteLen = sizeof (struct sockaddr_storage);
82 };
83
87 template <class Protocol, class ProactorType>
89 {
90 using Endpoint = typename Protocol::Endpoint;
91
93 using Read = Function<void (const std::error_code&, const char*, size_t, bool), 16>;
94
96 using ReadFrom =
97 Function<void (const std::error_code&, const char*, size_t, const Endpoint&, const char*, size_t, bool),
98 16>;
99
102
105
108
110 msghdr msg = {};
111
113 iovec iov = {};
114 };
115
119 template <class Protocol, class ProactorType>
121 {
123 using Connect = Function<void (const std::error_code&), 16>;
124
126 using Write = Function<void (const std::error_code&, size_t), 16>;
127
130
133
136
138 msghdr msg = {};
139
141 iovec iov = {};
142 };
143
147 template <class... Ops>
149 {
150 static_assert (sizeof...(Ops) > 0, "traits must describe at least one operation");
151
153 static constexpr size_t maxSize = std::max ({sizeof (Ops)...});
154 };
155
159 template <class Protocol, class ProactorType>
162}
163
164#endif
Definition acceptor.hpp:32
asynchronous accept operation.
Definition async_operation.hpp:64
typename Protocol::Endpoint Endpoint
Definition async_operation.hpp:65
Endpoint remote
remote endpoint.
Definition async_operation.hpp:78
Accept acceptHandler
handler invoked on completion.
Definition async_operation.hpp:75
IoOperation op
operation submitted to the proactor.
Definition async_operation.hpp:72
socklen_t remoteLen
remote address length.
Definition async_operation.hpp:81
typename Protocol::Socket Socket
Definition async_operation.hpp:66
asynchronous operation traits.
Definition async_operation.hpp:149
static constexpr size_t maxSize
size of the largest asynchronous operation.
Definition async_operation.hpp:153
asynchronous read operation.
Definition async_operation.hpp:89
typename Protocol::Endpoint Endpoint
Definition async_operation.hpp:90
ReadFrom readFromHandler
handler invoked on completion, reporting the endpoint the data are coming from.
Definition async_operation.hpp:107
Read readHandler
handler invoked on completion.
Definition async_operation.hpp:104
IoOperation op
operation submitted to the proactor.
Definition async_operation.hpp:101
msghdr msg
read message header.
Definition async_operation.hpp:110
iovec iov
read scatter gather entry.
Definition async_operation.hpp:113
asynchronous wait operation.
Definition async_operation.hpp:48
IoOperation op
operation submitted to the proactor.
Definition async_operation.hpp:53
Wait waitHandler
handler invoked on completion.
Definition async_operation.hpp:56
asynchronous write operation.
Definition async_operation.hpp:121
Connect connectHandler
handler invoked on connection completion.
Definition async_operation.hpp:132
msghdr msg
write message header.
Definition async_operation.hpp:138
Write writeHandler
handler invoked on completion.
Definition async_operation.hpp:135
iovec iov
write scatter gather entry.
Definition async_operation.hpp:141
IoOperation op
operation submitted to the proactor.
Definition async_operation.hpp:129
Describes a single asynchronous operation submitted to the Proactor.
Definition io_operation.hpp:48