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 Proactor>
48 {
50 using Wait = Function<void (const std::error_code&, bool), 16>;
51
54
57 };
58
62 template <class Protocol, class Proactor>
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 Proactor>
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 = Function<void (const std::error_code&, const char*, size_t, const Endpoint&, bool), 16>;
97
100
103
106
108 msghdr msg = {};
109
111 iovec iov = {};
112 };
113
117 template <class Protocol, class Proactor>
119 {
121 using Connect = Function<void (const std::error_code&), 16>;
122
124 using Write = Function<void (const std::error_code&, size_t), 16>;
125
128
131
134
136 msghdr msg = {};
137
139 iovec iov = {};
140 };
141
145 template <class... Ops>
147 {
148 static_assert (sizeof...(Ops) > 0, "traits must describe at least one operation");
149
151 static constexpr size_t maxSize = std::max ({sizeof (Ops)...});
152 };
153
157 template <class Protocol, class Proactor>
160}
161
162#endif
Definition acceptor.hpp:32
asynchronous accept operation.
Definition async_operation.hpp:64
typename Protocol::Socket Socket
Definition async_operation.hpp:66
Accept acceptHandler
handler invoked on completion.
Definition async_operation.hpp:75
Endpoint remote
remote endpoint.
Definition async_operation.hpp:78
socklen_t remoteLen
remote address length.
Definition async_operation.hpp:81
IoOperation op
operation submitted to the proactor.
Definition async_operation.hpp:72
typename Protocol::Endpoint Endpoint
Definition async_operation.hpp:65
asynchronous operation traits.
Definition async_operation.hpp:147
static constexpr size_t maxSize
size of the largest asynchronous operation.
Definition async_operation.hpp:151
asynchronous read operation.
Definition async_operation.hpp:89
typename Protocol::Endpoint Endpoint
Definition async_operation.hpp:90
IoOperation op
operation submitted to the proactor.
Definition async_operation.hpp:99
iovec iov
read scatter gather entry.
Definition async_operation.hpp:111
ReadFrom readFromHandler
handler invoked on completion, reporting the endpoint the data are coming from.
Definition async_operation.hpp:105
msghdr msg
read message header.
Definition async_operation.hpp:108
Read readHandler
handler invoked on completion.
Definition async_operation.hpp:102
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:119
Write writeHandler
handler invoked on completion.
Definition async_operation.hpp:133
msghdr msg
write message header.
Definition async_operation.hpp:136
iovec iov
write scatter gather entry.
Definition async_operation.hpp:139
Connect connectHandler
handler invoked on connection completion.
Definition async_operation.hpp:130
IoOperation op
operation submitted to the proactor.
Definition async_operation.hpp:127
Describes a single asynchronous operation submitted to the Proactor.
Definition io_operation.hpp:47