join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::IoOperation Struct Reference

Describes a single asynchronous operation submitted to the Proactor. More...

#include <io_operation.hpp>

Collaboration diagram for join::IoOperation:

Classes

struct  AcceptData
 payload for accept. More...
 
struct  ConnectData
 payload for connect. More...
 
union  Data
 
struct  MsgData
 payload for sendmsg / recvmsg. More...
 
struct  RwData
 payload for read / read fixed / write / write fixed. More...
 
struct  StreamData
 payload for recv / send. More...
 

Public Types

enum class  State : uint8_t { Idle , Submitted , Cancelling }
 operation lifecycle state. More...
 
enum class  Opcode : uint8_t {
  Accept , Connect , Read , Write ,
  ReadFixed , WriteFixed , RecvMsg , SendMsg ,
  Recv , Send
}
 operation code. More...
 

Public Member Functions

int fd () const noexcept
 return the file descriptor associated with this operation.
 

Static Public Member Functions

static IoOperation makeAccept (int fd, sockaddr *addr, socklen_t *addrlen, int flags, CompletionHandler *handler) noexcept
 build an accept operation.
 
static IoOperation makeConnect (int fd, const sockaddr *addr, socklen_t addrlen, CompletionHandler *handler) noexcept
 build a connect operation.
 
static IoOperation makeRead (int fd, void *buf, uint32_t len, CompletionHandler *handler, bool linked=false) noexcept
 build a regular read operation.
 
static IoOperation makeWrite (int fd, const void *buf, uint32_t len, CompletionHandler *handler, bool linked=false) noexcept
 build a regular write operation.
 
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.
 
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.
 
static IoOperation makeRecvmsg (int fd, msghdr *msg, int flags, CompletionHandler *handler, bool linked=false) noexcept
 build a receive-message operation.
 
static IoOperation makeSendmsg (int fd, const msghdr *msg, int flags, CompletionHandler *handler, bool linked=false) noexcept
 build a send-message operation.
 
static IoOperation makeRecv (int fd, void *buf, uint32_t len, int flags, CompletionHandler *handler, bool linked=false) noexcept
 build a receive operation.
 
static IoOperation makeSend (int fd, const void *buf, uint32_t len, int flags, CompletionHandler *handler, bool linked=false) noexcept
 build a send operation.
 

Public Attributes

uint8_t code = 0
 operation code.
 
State state = State::Idle
 operation state.
 
uint32_t index = 0
 index of this operation in the proactor pending ops (io_uring only).
 
bool linked = false
 link this SQE to the next one (next executes only if this succeeds, io_uring only).
 
CompletionHandlerhandler = nullptr
 handler to dispatch to on completion.
 
Data data = {}
 operation code specific payload.
 

Detailed Description

Describes a single asynchronous operation submitted to the Proactor.

Member Enumeration Documentation

◆ Opcode

enum class join::IoOperation::Opcode : uint8_t
strong

operation code.

Enumerator
Accept 

accept an incoming connection.

Connect 

initiate an outgoing connection.

Read 

read from a file descriptor.

Write 

write to a file descriptor.

ReadFixed 

read using a registered buffer.

WriteFixed 

write using a registered buffer.

RecvMsg 

receive a message with ancillary data.

SendMsg 

send a message with ancillary data.

Recv 

receive data from a socket.

Send 

send data on a socket.

◆ State

enum class join::IoOperation::State : uint8_t
strong

operation lifecycle state.

Enumerator
Idle 

operation is not in flight.

Submitted 

operation has been submitted and is awaiting completion.

Cancelling 

operation has been canceled and is awaiting completion.

Member Function Documentation

◆ fd()

int IoOperation::fd ( ) const
noexcept

return the file descriptor associated with this operation.

Returns
file descriptor, or -1 if opcode is unknown.

◆ makeAccept()

IoOperation IoOperation::makeAccept ( int fd,
sockaddr * addr,
socklen_t * addrlen,
int flags,
CompletionHandler * handler )
staticnoexcept

build an accept operation.

Parameters
fdlistening socket file descriptor.
addrpeer address.
addrlenpeer address length.
flagsaccept flags.
handlerhandler to notify on completion.
Returns
initialized IoOperation.

◆ makeConnect()

IoOperation IoOperation::makeConnect ( int fd,
const sockaddr * addr,
socklen_t addrlen,
CompletionHandler * handler )
staticnoexcept

build a connect operation.

Parameters
fdsocket file descriptor.
addrremote address.
addrlenremote address length.
handlerhandler to notify on completion.
Returns
initialized IoOperation.

◆ makeRead()

IoOperation IoOperation::makeRead ( int fd,
void * buf,
uint32_t len,
CompletionHandler * handler,
bool linked = false )
staticnoexcept

build a regular read operation.

Parameters
fdfile descriptor to read from.
bufdestination buffer.
lennumber of bytes to read.
handlerhandler to notify on completion.
linkedlink this SQE to the next one (io_uring only).
Returns
initialized IoOperation.

◆ makeReadFixed()

IoOperation IoOperation::makeReadFixed ( int fd,
void * buf,
uint32_t len,
uint16_t index,
CompletionHandler * handler,
bool linked = false )
staticnoexcept

build a fixed-buffer read operation.

Parameters
fdfile descriptor to read from.
bufdestination buffer.
lennumber of bytes to read.
indexregistered buffer index.
handlerhandler to notify on completion.
linkedlink this SQE to the next one (io_uring only).
Returns
initialized IoOperation.

◆ makeRecv()

IoOperation IoOperation::makeRecv ( int fd,
void * buf,
uint32_t len,
int flags,
CompletionHandler * handler,
bool linked = false )
staticnoexcept

build a receive operation.

Parameters
fdsocket file descriptor.
bufdestination buffer.
lennumber of bytes to receive.
flagsrecv flags.
handlerhandler to notify on completion.
linkedlink this SQE to the next one (io_uring only).
Returns
initialized IoOperation.

◆ makeRecvmsg()

IoOperation IoOperation::makeRecvmsg ( int fd,
msghdr * msg,
int flags,
CompletionHandler * handler,
bool linked = false )
staticnoexcept

build a receive-message operation.

Parameters
fdsocket file descriptor.
msgmessage header.
flagsrecv flags.
handlerhandler to notify on completion.
linkedlink this SQE to the next one (io_uring only).
Returns
initialized IoOperation.

◆ makeSend()

IoOperation IoOperation::makeSend ( int fd,
const void * buf,
uint32_t len,
int flags,
CompletionHandler * handler,
bool linked = false )
staticnoexcept

build a send operation.

Parameters
fdsocket file descriptor.
bufsource buffer.
lennumber of bytes to send.
flagssend flags.
handlerhandler to notify on completion.
linkedlink this SQE to the next one (io_uring only).
Returns
initialized IoOperation.

◆ makeSendmsg()

IoOperation IoOperation::makeSendmsg ( int fd,
const msghdr * msg,
int flags,
CompletionHandler * handler,
bool linked = false )
staticnoexcept

build a send-message operation.

Parameters
fdsocket file descriptor.
msgmessage header.
flagssend flags.
handlerhandler to notify on completion.
linkedlink this SQE to the next one (io_uring only).
Returns
initialized IoOperation.

◆ makeWrite()

IoOperation IoOperation::makeWrite ( int fd,
const void * buf,
uint32_t len,
CompletionHandler * handler,
bool linked = false )
staticnoexcept

build a regular write operation.

Parameters
fdfile descriptor to write to.
bufsource buffer.
lennumber of bytes to write.
handlerhandler to notify on completion.
linkedlink this SQE to the next one (io_uring only).
Returns
initialized IoOperation.

◆ makeWriteFixed()

IoOperation IoOperation::makeWriteFixed ( int fd,
const void * buf,
uint32_t len,
uint16_t index,
CompletionHandler * handler,
bool linked = false )
staticnoexcept

build a fixed-buffer write operation.

Parameters
fdfile descriptor to write to.
bufsource buffer.
lennumber of bytes to write.
indexregistered buffer index.
handlerhandler to notify on completion.
linkedlink this SQE to the next one (io_uring only).
Returns
initialized IoOperation.

Member Data Documentation

◆ code

uint8_t join::IoOperation::code = 0

operation code.

◆ data

Data join::IoOperation::data = {}

operation code specific payload.

◆ handler

CompletionHandler* join::IoOperation::handler = nullptr

handler to dispatch to on completion.

◆ index

uint32_t join::IoOperation::index = 0

index of this operation in the proactor pending ops (io_uring only).

◆ linked

bool join::IoOperation::linked = false

link this SQE to the next one (next executes only if this succeeds, io_uring only).

◆ state

State join::IoOperation::state = State::Idle

operation state.


The documentation for this struct was generated from the following files: