join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::BasicAsyncStreamAcceptor< Protocol, Proactor > Class Template Reference

asynchronous stream acceptor class. More...

#include <async_acceptor.hpp>

Inheritance diagram for join::BasicAsyncStreamAcceptor< Protocol, Proactor >:
Collaboration diagram for join::BasicAsyncStreamAcceptor< Protocol, Proactor >:

Public Types

using Acceptor = BasicStreamAcceptor<Protocol>
 
using Endpoint = typename Protocol::Endpoint
 
using Socket = typename Protocol::Socket
 
using AsyncAccept = BasicAsyncAccept<Protocol, Proactor>
 
using AcceptHandler = typename AsyncAccept::Accept
 

Public Member Functions

 BasicAsyncStreamAcceptor (Proactor &proactor=ProactorThread::proactor())
 create the acceptor instance.
 
 BasicAsyncStreamAcceptor (const BasicAsyncStreamAcceptor &other)=delete
 copy constructor.
 
BasicAsyncStreamAcceptoroperator= (const BasicAsyncStreamAcceptor &other)=delete
 copy assignment operator.
 
 BasicAsyncStreamAcceptor (BasicAsyncStreamAcceptor &&other)=delete
 move constructor.
 
BasicAsyncStreamAcceptoroperator= (BasicAsyncStreamAcceptor &&other)=delete
 move assignment operator.
 
 ~BasicAsyncStreamAcceptor ()
 destroy the acceptor instance.
 
int create (const Endpoint &endpoint, int flags=SOCK_CLOEXEC|SOCK_NONBLOCK) noexcept
 create acceptor.
 
void close () noexcept
 close acceptor, cancelling the acceptation in flight.
 
ssize_t asyncAccept (AcceptHandler handler, int flags=SOCK_NONBLOCK|SOCK_CLOEXEC, bool flush=true) noexcept
 start an asynchronous acceptation.
 
ssize_t asyncAcceptMulti (AcceptHandler handler, int flags=SOCK_NONBLOCK|SOCK_CLOEXEC, bool flush=true) noexcept
 start an asynchronous multishot acceptation, staying armed until cancelled or failed.
 
int cancel () noexcept
 cancel the acceptation in flight, if any.
 
Endpoint localEndpoint () const
 determine the local endpoint associated with this acceptor.
 
bool opened () const noexcept
 check if the acceptor is opened.
 
int family () const noexcept
 get address family.
 
int type () const noexcept
 get the acceptor communication semantic.
 
int protocol () const noexcept
 get acceptor protocol.
 
int handle () const noexcept
 get acceptor native handle.
 
- Public Member Functions inherited from join::CompletionHandler
 CompletionHandler ()=default
 create instance.
 
 CompletionHandler (const CompletionHandler &other)=default
 copy constructor.
 
CompletionHandleroperator= (const CompletionHandler &other)=default
 copy assignment operator.
 
 CompletionHandler (CompletionHandler &&other)=default
 move constructor.
 
CompletionHandleroperator= (CompletionHandler &&other)=default
 move assignment operator.
 
virtual ~CompletionHandler ()=default
 destroy instance.
 

Protected Member Functions

void onComplete (IoOperation &op, int result) override
 method called when an operation completes.
 
void onCancel (IoOperation &op, int result) override
 method called when an operation is cancelled.
 
virtual void dispatch (IoOperation &op, const std::error_code &code, size_t size) noexcept
 invoke the completion handler of the given operation.
 
void completeAccept (AsyncAccept *accept, const std::error_code &code, size_t handle) noexcept
 invoke the accept completion handler.
 
bool armOp () noexcept
 reserve the accept operation for submission.
 
void disarmOp (IoOperation::State expected) noexcept
 release the accept operation reservation.
 
bool inFlight (const IoOperation &op) const noexcept
 check if an operation is in flight.
 
bool pending (const IoOperation &op) const noexcept
 check if an operation is in flight or completing.
 
- Protected Member Functions inherited from join::CompletionHandler

Detailed Description

template<class Protocol, class Proactor = BasicProactor>
class join::BasicAsyncStreamAcceptor< Protocol, Proactor >

asynchronous stream acceptor class.

Member Typedef Documentation

◆ AcceptHandler

template<class Protocol , class Proactor = BasicProactor>
using join::BasicAsyncStreamAcceptor< Protocol, Proactor >::AcceptHandler = typename AsyncAccept::Accept

◆ Acceptor

template<class Protocol , class Proactor = BasicProactor>
using join::BasicAsyncStreamAcceptor< Protocol, Proactor >::Acceptor = BasicStreamAcceptor<Protocol>

◆ AsyncAccept

template<class Protocol , class Proactor = BasicProactor>
using join::BasicAsyncStreamAcceptor< Protocol, Proactor >::AsyncAccept = BasicAsyncAccept<Protocol, Proactor>

◆ Endpoint

template<class Protocol , class Proactor = BasicProactor>
using join::BasicAsyncStreamAcceptor< Protocol, Proactor >::Endpoint = typename Protocol::Endpoint

◆ Socket

template<class Protocol , class Proactor = BasicProactor>
using join::BasicAsyncStreamAcceptor< Protocol, Proactor >::Socket = typename Protocol::Socket

Constructor & Destructor Documentation

◆ BasicAsyncStreamAcceptor() [1/3]

template<class Protocol , class Proactor = BasicProactor>
join::BasicAsyncStreamAcceptor< Protocol, Proactor >::BasicAsyncStreamAcceptor ( Proactor & proactor = ProactorThread::proactor ())
inlineexplicit

create the acceptor instance.

Parameters
proactorproactor driving the operations.

◆ BasicAsyncStreamAcceptor() [2/3]

template<class Protocol , class Proactor = BasicProactor>
join::BasicAsyncStreamAcceptor< Protocol, Proactor >::BasicAsyncStreamAcceptor ( const BasicAsyncStreamAcceptor< Protocol, Proactor > & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ BasicAsyncStreamAcceptor() [3/3]

template<class Protocol , class Proactor = BasicProactor>
join::BasicAsyncStreamAcceptor< Protocol, Proactor >::BasicAsyncStreamAcceptor ( BasicAsyncStreamAcceptor< Protocol, Proactor > && other)
delete

move constructor.

Parameters
otherother object to move.

◆ ~BasicAsyncStreamAcceptor()

template<class Protocol , class Proactor = BasicProactor>
join::BasicAsyncStreamAcceptor< Protocol, Proactor >::~BasicAsyncStreamAcceptor ( )
inline

destroy the acceptor instance.

Member Function Documentation

◆ armOp()

template<class Protocol , class Proactor = BasicProactor>
bool join::BasicAsyncStreamAcceptor< Protocol, Proactor >::armOp ( )
inlineprotectednoexcept

reserve the accept operation for submission.

Returns
true if the operation was reserved, false if already in flight.

◆ asyncAccept()

template<class Protocol , class Proactor = BasicProactor>
ssize_t join::BasicAsyncStreamAcceptor< Protocol, Proactor >::asyncAccept ( AcceptHandler handler,
int flags = SOCK_NONBLOCK | SOCK_CLOEXEC,
bool flush = true )
inlinenoexcept

start an asynchronous acceptation.

Parameters
handlerhandler invoked on completion.
flagsaccepted socket creation flags.
flushflush the submission queue.
Returns
0 on success, -1 on failure.

◆ asyncAcceptMulti()

template<class Protocol , class Proactor = BasicProactor>
ssize_t join::BasicAsyncStreamAcceptor< Protocol, Proactor >::asyncAcceptMulti ( AcceptHandler handler,
int flags = SOCK_NONBLOCK | SOCK_CLOEXEC,
bool flush = true )
inlinenoexcept

start an asynchronous multishot acceptation, staying armed until cancelled or failed.

Parameters
handlerhandler invoked on each acceptation, the last call reporting more as false.
flagsaccepted socket creation flags.
flushflush the submission queue.
Returns
0 on success, -1 on failure.

◆ cancel()

template<class Protocol , class Proactor = BasicProactor>
int join::BasicAsyncStreamAcceptor< Protocol, Proactor >::cancel ( )
inlinenoexcept

cancel the acceptation in flight, if any.

Returns
0 on success, -1 on failure.

◆ close()

template<class Protocol , class Proactor = BasicProactor>
void join::BasicAsyncStreamAcceptor< Protocol, Proactor >::close ( )
inlinenoexcept

close acceptor, cancelling the acceptation in flight.

◆ completeAccept()

template<class Protocol , class Proactor = BasicProactor>
void join::BasicAsyncStreamAcceptor< Protocol, Proactor >::completeAccept ( AsyncAccept * accept,
const std::error_code & code,
size_t handle )
inlineprotectednoexcept

invoke the accept completion handler.

Parameters
acceptcompleted accept operation.
codeerror code reported by the kernel.
handleaccepted file descriptor.

◆ create()

template<class Protocol , class Proactor = BasicProactor>
int join::BasicAsyncStreamAcceptor< Protocol, Proactor >::create ( const Endpoint & endpoint,
int flags = SOCK_CLOEXEC | SOCK_NONBLOCK )
inlinenoexcept

create acceptor.

Parameters
endpointendpoint to assign to the acceptor.
flagsacceptor socket creation flags.
Returns
0 on success, -1 on failure.

◆ disarmOp()

template<class Protocol , class Proactor = BasicProactor>
void join::BasicAsyncStreamAcceptor< Protocol, Proactor >::disarmOp ( IoOperation::State expected)
inlineprotectednoexcept

release the accept operation reservation.

Parameters
expectedstate the operation is expected to be in.

◆ dispatch()

template<class Protocol , class Proactor = BasicProactor>
virtual void join::BasicAsyncStreamAcceptor< Protocol, Proactor >::dispatch ( IoOperation & op,
const std::error_code & code,
size_t size )
inlineprotectedvirtualnoexcept

invoke the completion handler of the given operation.

Parameters
opcompleted operation.
codeerror code reported by the kernel.
sizeaccepted file descriptor, 0 when the operation failed or was cancelled.

◆ family()

template<class Protocol , class Proactor = BasicProactor>
int join::BasicAsyncStreamAcceptor< Protocol, Proactor >::family ( ) const
inlinenoexcept

get address family.

Returns
address family.

◆ handle()

template<class Protocol , class Proactor = BasicProactor>
int join::BasicAsyncStreamAcceptor< Protocol, Proactor >::handle ( ) const
inlinenoexcept

get acceptor native handle.

Returns
acceptor native handle.

◆ inFlight()

template<class Protocol , class Proactor = BasicProactor>
bool join::BasicAsyncStreamAcceptor< Protocol, Proactor >::inFlight ( const IoOperation & op) const
inlineprotectednoexcept

check if an operation is in flight.

Parameters
opoperation to check.
Returns
true if the operation is in flight, false otherwise.

◆ localEndpoint()

template<class Protocol , class Proactor = BasicProactor>
Endpoint join::BasicAsyncStreamAcceptor< Protocol, Proactor >::localEndpoint ( ) const
inline

determine the local endpoint associated with this acceptor.

Returns
local endpoint.

◆ onCancel()

template<class Protocol , class Proactor = BasicProactor>
void join::BasicAsyncStreamAcceptor< Protocol, Proactor >::onCancel ( IoOperation & op,
int result )
inlineoverrideprotectedvirtual

method called when an operation is cancelled.

Parameters
opcancelled operation.
resultnegative errno.

Reimplemented from join::CompletionHandler.

◆ onComplete()

template<class Protocol , class Proactor = BasicProactor>
void join::BasicAsyncStreamAcceptor< Protocol, Proactor >::onComplete ( IoOperation & op,
int result )
inlineoverrideprotectedvirtual

method called when an operation completes.

Parameters
opcompleted operation.
resultaccepted file descriptor, or negative errno.

Reimplemented from join::CompletionHandler.

◆ opened()

template<class Protocol , class Proactor = BasicProactor>
bool join::BasicAsyncStreamAcceptor< Protocol, Proactor >::opened ( ) const
inlinenoexcept

check if the acceptor is opened.

Returns
true if opened, false otherwise.

◆ operator=() [1/2]

template<class Protocol , class Proactor = BasicProactor>
BasicAsyncStreamAcceptor & join::BasicAsyncStreamAcceptor< Protocol, Proactor >::operator= ( BasicAsyncStreamAcceptor< Protocol, Proactor > && other)
delete

move assignment operator.

Parameters
otherother object to assign.
Returns
assigned object.

◆ operator=() [2/2]

template<class Protocol , class Proactor = BasicProactor>
BasicAsyncStreamAcceptor & join::BasicAsyncStreamAcceptor< Protocol, Proactor >::operator= ( const BasicAsyncStreamAcceptor< Protocol, Proactor > & other)
delete

copy assignment operator.

Parameters
otherother object to assign.
Returns
assigned object.

◆ pending()

template<class Protocol , class Proactor = BasicProactor>
bool join::BasicAsyncStreamAcceptor< Protocol, Proactor >::pending ( const IoOperation & op) const
inlineprotectednoexcept

check if an operation is in flight or completing.

Parameters
opoperation to check.
Returns
true if the operation is in flight or completing, false otherwise.

◆ protocol()

template<class Protocol , class Proactor = BasicProactor>
int join::BasicAsyncStreamAcceptor< Protocol, Proactor >::protocol ( ) const
inlinenoexcept

get acceptor protocol.

Returns
acceptor protocol.

◆ type()

template<class Protocol , class Proactor = BasicProactor>
int join::BasicAsyncStreamAcceptor< Protocol, Proactor >::type ( ) const
inlinenoexcept

get the acceptor communication semantic.

Returns
the acceptor communication semantic.

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