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  PollData
 payload for poll. 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 , Busy , Suspended }
 operation lifecycle state. More...
 
enum class  Opcode : uint8_t {
  Poll , Accept , Connect , Read ,
  Write , ReadFixed , WriteFixed , RecvMsg ,
  SendMsg , Recv , Send
}
 operation code. More...
 

Public Member Functions

 IoOperation ()=default
 default constructor.
 
 IoOperation (const IoOperation &other) noexcept
 copy constructor.
 
IoOperationoperator= (const IoOperation &other) noexcept
 copy assignment operator.
 
int fd () const noexcept
 return the file descriptor associated with this operation.
 

Static Public Member Functions

static IoOperation makePoll (int fd, uint32_t events, CompletionHandler *handler) noexcept
 build a poll operation.
 
static IoOperation makePollMulti (int fd, uint32_t events, CompletionHandler *handler) noexcept
 build a multishot poll operation, staying armed until cancelled or failed.
 
static IoOperation makeAccept (int fd, sockaddr *addr, socklen_t *addrlen, int flags, CompletionHandler *handler) noexcept
 build an accept operation.
 
static IoOperation makeAcceptMulti (int fd, int flags, CompletionHandler *handler) noexcept
 build a multishot 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 makeRecvmsgMulti (int fd, uint16_t group, msghdr *msg, int flags, CompletionHandler *handler) noexcept
 build a multishot 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 makeRecvMulti (int fd, uint16_t group, int flags, CompletionHandler *handler) noexcept
 build a multishot 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.
 
std::atomic< Statestate {State::Idle}
 operation state.
 
State resume {State::Idle}
 state to restore when the current hold is released.
 
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).
 
bool multishot = false
 rearm the operation after each completion.
 
bool more = false
 true while a multishot operation stays armed.
 
uint16_t group = 0
 provided buffer group.
 
CompletionHandlerhandler = nullptr
 handler to dispatch to on completion.
 
Data data = {}
 operation code specific payload.
 
IoRingBufferring = nullptr
 buffer ring bound to this operation.
 

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
Poll 

wait for readiness on a file descriptor.

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 is in flight.

Busy 

a completion is in progress.

Suspended 

operation has been suspended.

Constructor & Destructor Documentation

◆ IoOperation() [1/2]

join::IoOperation::IoOperation ( )
default

default constructor.

◆ IoOperation() [2/2]

IoOperation::IoOperation ( const IoOperation & other)
noexcept

copy constructor.

Parameters
otherother object to copy.

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.

◆ makeAcceptMulti()

IoOperation IoOperation::makeAcceptMulti ( int fd,
int flags,
CompletionHandler * handler )
staticnoexcept

build a multishot accept operation.

Parameters
fdlistening socket file descriptor.
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.

◆ makePoll()

IoOperation IoOperation::makePoll ( int fd,
uint32_t events,
CompletionHandler * handler )
staticnoexcept

build a poll operation.

Parameters
fdfile descriptor to watch.
eventsrequested events, POLLIN or POLLOUT.
handlerhandler to notify on completion.
Returns
initialized IoOperation.

◆ makePollMulti()

IoOperation IoOperation::makePollMulti ( int fd,
uint32_t events,
CompletionHandler * handler )
staticnoexcept

build a multishot poll operation, staying armed until cancelled or failed.

Parameters
fdfile descriptor to watch.
eventsrequested events, POLLIN or POLLOUT.
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.

◆ makeRecvmsgMulti()

IoOperation IoOperation::makeRecvmsgMulti ( int fd,
uint16_t group,
msghdr * msg,
int flags,
CompletionHandler * handler )
staticnoexcept

build a multishot receive-message operation.

Parameters
fdsocket file descriptor.
groupprovided buffer group, the selected buffer is only valid during the callback.
msgmessage header.
flagsrecv flags.
handlerhandler to notify on completion.
Returns
initialized IoOperation.

◆ makeRecvMulti()

IoOperation IoOperation::makeRecvMulti ( int fd,
uint16_t group,
int flags,
CompletionHandler * handler )
staticnoexcept

build a multishot receive operation.

Parameters
fdsocket file descriptor.
groupprovided buffer group, the selected buffer is only valid during the callback.
flagsrecv flags.
handlerhandler to notify on completion.
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.

◆ operator=()

IoOperation & IoOperation::operator= ( const IoOperation & other)
noexcept

copy assignment operator.

Parameters
otherother object to copy.
Returns
current object.

Member Data Documentation

◆ code

uint8_t join::IoOperation::code = 0

operation code.

◆ data

Data join::IoOperation::data = {}

operation code specific payload.

◆ group

uint16_t join::IoOperation::group = 0

provided buffer group.

◆ 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).

◆ more

bool join::IoOperation::more = false

true while a multishot operation stays armed.

◆ multishot

bool join::IoOperation::multishot = false

rearm the operation after each completion.

◆ resume

State join::IoOperation::resume {State::Idle}

state to restore when the current hold is released.

◆ ring

IoRingBuffer* join::IoOperation::ring = nullptr

buffer ring bound to this operation.

◆ state

std::atomic<State> join::IoOperation::state {State::Idle}

operation state.


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