25#ifndef JOIN_CORE_IO_OPERATION_HPP
26#define JOIN_CORE_IO_OPERATION_HPP
35#include <sys/socket.h>
42 class CompletionHandler;
225 bool linked =
false) noexcept;
237 bool linked = false) noexcept;
250 bool linked = false) noexcept;
296 bool linked =
false) noexcept;
320 bool linked = false) noexcept;
351 bool linked =
false) noexcept;
374 bool linked = false) noexcept;
390 int fd () const noexcept;
392#ifdef JOIN_HAS_IO_URING
431 static_assert (offsetof (
IoOperation, state) >=
sizeof (uint32_t),
432 "state must survive the arena free list link stored in the first bytes of a released chunk");
completion handler interface class.
Definition proactor.hpp:81
pool of buffers provided to the I/O backend.
Definition io_ring_buffer.hpp:49
Definition acceptor.hpp:32
payload for accept.
Definition io_operation.hpp:133
socklen_t * addrlen
peer address length.
Definition io_operation.hpp:141
int fd
file descriptor.
Definition io_operation.hpp:135
int flags
accept flags.
Definition io_operation.hpp:144
sockaddr * addr
peer address.
Definition io_operation.hpp:138
payload for connect.
Definition io_operation.hpp:172
const sockaddr * addr
remote address.
Definition io_operation.hpp:177
socklen_t addrlen
address length.
Definition io_operation.hpp:180
int fd
file descriptor.
Definition io_operation.hpp:174
payload for sendmsg / recvmsg.
Definition io_operation.hpp:269
int flags
sendmsg / recvmsg flags.
Definition io_operation.hpp:277
uint32_t namelen
reserved name area length.
Definition io_operation.hpp:280
msghdr * msg
message header.
Definition io_operation.hpp:274
uint32_t controllen
reserved control area length.
Definition io_operation.hpp:283
int fd
file descriptor.
Definition io_operation.hpp:271
payload for poll.
Definition io_operation.hpp:103
uint32_t events
requested events.
Definition io_operation.hpp:108
int fd
file descriptor.
Definition io_operation.hpp:105
payload for read / read fixed / write / write fixed.
Definition io_operation.hpp:198
unsigned long len
number of bytes to transfer.
Definition io_operation.hpp:206
bool fixed
use registered buffer (ignored with reactor backend).
Definition io_operation.hpp:212
uint16_t index
registered buffer index (ignored with reactor backend).
Definition io_operation.hpp:209
int fd
file descriptor.
Definition io_operation.hpp:200
void * buf
buffer.
Definition io_operation.hpp:203
payload for recv / send.
Definition io_operation.hpp:326
int fd
file descriptor.
Definition io_operation.hpp:328
unsigned long len
number of bytes to transfer.
Definition io_operation.hpp:334
int flags
send / recv flags.
Definition io_operation.hpp:337
void * buf
buffer.
Definition io_operation.hpp:331
Describes a single asynchronous operation submitted to the Proactor.
Definition io_operation.hpp:48
bool linked
link this SQE to the next one (next executes only if this succeeds, io_uring only).
Definition io_operation.hpp:410
static IoOperation makeWrite(int fd, const void *buf, uint32_t len, CompletionHandler *handler, bool linked=false) noexcept
build a regular write operation.
Definition io_operation.cpp:178
bool more
true while a multishot operation stays armed.
Definition io_operation.hpp:416
uint16_t group
provided buffer group.
Definition io_operation.hpp:419
static IoOperation makeSendmsg(int fd, const msghdr *msg, int flags, CompletionHandler *handler, bool linked=false) noexcept
build a send-message operation.
Definition io_operation.cpp:271
static IoOperation makeConnect(int fd, const sockaddr *addr, socklen_t addrlen, CompletionHandler *handler) noexcept
build a connect operation.
Definition io_operation.cpp:144
static IoOperation makeSend(int fd, const void *buf, uint32_t len, int flags, CompletionHandler *handler, bool linked=false) noexcept
build a send operation.
Definition io_operation.cpp:324
static IoOperation makeReadFixed(int fd, void *buf, uint32_t len, uint16_t index, CompletionHandler *handler, bool linked=false) noexcept
build a fixed-buffer read operation.
Definition io_operation.cpp:197
static IoOperation makeRecvMulti(int fd, uint16_t group, int flags, CompletionHandler *handler) noexcept
build a multishot receive operation.
Definition io_operation.cpp:306
static IoOperation makeWriteFixed(int fd, const void *buf, uint32_t len, uint16_t index, CompletionHandler *handler, bool linked=false) noexcept
build a fixed-buffer write operation.
Definition io_operation.cpp:216
static IoOperation makeRead(int fd, void *buf, uint32_t len, CompletionHandler *handler, bool linked=false) noexcept
build a regular read operation.
Definition io_operation.cpp:160
static IoOperation makePollMulti(int fd, uint32_t events, CompletionHandler *handler) noexcept
build a multishot poll operation, staying armed until cancelled or failed.
Definition io_operation.cpp:95
static IoOperation makeRecvmsgMulti(int fd, uint16_t group, msghdr *msg, int flags, CompletionHandler *handler) noexcept
build a multishot receive-message operation.
Definition io_operation.cpp:251
static IoOperation makeAccept(int fd, sockaddr *addr, socklen_t *addrlen, int flags, CompletionHandler *handler) noexcept
build an accept operation.
Definition io_operation.cpp:110
Data data
operation code specific payload.
Definition io_operation.hpp:425
State
operation lifecycle state.
Definition io_operation.hpp:53
static IoOperation makeRecvmsg(int fd, msghdr *msg, int flags, CompletionHandler *handler, bool linked=false) noexcept
build a receive-message operation.
Definition io_operation.cpp:235
bool multishot
rearm the operation after each completion.
Definition io_operation.hpp:413
static IoOperation makeAcceptMulti(int fd, int flags, CompletionHandler *handler) noexcept
build a multishot accept operation.
Definition io_operation.cpp:127
CompletionHandler * handler
handler to dispatch to on completion.
Definition io_operation.hpp:422
std::atomic< State > state
operation state.
Definition io_operation.hpp:404
static IoOperation makeRecv(int fd, void *buf, uint32_t len, int flags, CompletionHandler *handler, bool linked=false) noexcept
build a receive operation.
Definition io_operation.cpp:288
static IoOperation makePoll(int fd, uint32_t events, CompletionHandler *handler) noexcept
build a poll operation.
Definition io_operation.cpp:81
State resume
state to restore when the current hold is released.
Definition io_operation.hpp:407
IoOperation & operator=(const IoOperation &other) noexcept
copy assignment operator.
Definition io_operation.cpp:59
uint8_t code
operation code.
Definition io_operation.hpp:401
IoRingBuffer * ring
buffer ring bound to this operation.
Definition io_operation.hpp:428
IoOperation() noexcept
default constructor.
Definition io_operation.hpp:81
IoOperation * next
next operation queued on the same descriptor and direction.
Definition io_operation.hpp:397
Opcode
operation code.
Definition io_operation.hpp:64
int fd() const noexcept
return the file descriptor associated with this operation.
Definition io_operation.cpp:342
Definition io_operation.hpp:377
RwData rw
Definition io_operation.hpp:381
MsgData msg
Definition io_operation.hpp:382
PollData poll
Definition io_operation.hpp:378
AcceptData accept
Definition io_operation.hpp:379
StreamData stream
Definition io_operation.hpp:383
ConnectData connect
Definition io_operation.hpp:380