OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::network::socket_selector Class Reference

Waits on a group of blocking sockets to be ready for read operations. More...

#include <socket_selector.hpp>

Public Member Functions

 socket_selector ()=default
 Constructs an empty socket selector.
 
 ~socket_selector ()
 
 socket_selector (const socket_selector &)=delete
 
auto operator= (const socket_selector &) -> socket_selector &=delete
 
 socket_selector (socket_selector &&)=delete
 
auto operator= (socket_selector &&) -> socket_selector &=delete
 
auto init () -> bool
 Sets-up the socket selector.
 
auto add (const socket &sock) -> bool
 Adds a socket to the selector so that it is checked for events after a call to wait.
 
auto wait () -> bool
 Blocks until at least one socket in the selector is ready to perform a read operation.
 
void unblock ()
 Unblocks a blocked wait() call.
 

Detailed Description

Waits on a group of blocking sockets to be ready for read operations.

Utility class for waiting on multiple blocking sockets. Users add sockets to the selector and block on a wait call. The call unblocks when any of the sockets in the selector are ready to receive data.

Definition at line 21 of file socket_selector.hpp.

Constructor & Destructor Documentation

◆ socket_selector() [1/3]

cbdc::network::socket_selector::socket_selector ( )
default

Constructs an empty socket selector.

◆ ~socket_selector()

cbdc::network::socket_selector::~socket_selector ( )

Definition at line 67 of file socket_selector.cpp.

References unblock().

Here is the call graph for this function:

◆ socket_selector() [2/3]

cbdc::network::socket_selector::socket_selector ( const socket_selector & )
delete

◆ socket_selector() [3/3]

cbdc::network::socket_selector::socket_selector ( socket_selector && )
delete

Member Function Documentation

◆ add()

auto cbdc::network::socket_selector::add ( const socket & sock) -> bool

Adds a socket to the selector so that it is checked for events after a call to wait.

Parameters
sockthe socket to add to the selector
Returns
true if there was space in the selector to add the socket

Definition at line 12 of file socket_selector.cpp.

◆ init()

auto cbdc::network::socket_selector::init ( ) -> bool

Sets-up the socket selector.

Must be called before the selector is used.

Returns
true if the setup was successful.

Definition at line 49 of file socket_selector.cpp.

◆ operator=() [1/2]

auto cbdc::network::socket_selector::operator= ( const socket_selector & ) -> socket_selector &=delete
delete

◆ operator=() [2/2]

auto cbdc::network::socket_selector::operator= ( socket_selector && ) -> socket_selector &=delete
delete

◆ unblock()

void cbdc::network::socket_selector::unblock ( )

Unblocks a blocked wait() call.

Definition at line 58 of file socket_selector.cpp.

Referenced by cbdc::network::connection_manager::close(), and ~socket_selector().

◆ wait()

auto cbdc::network::socket_selector::wait ( ) -> bool

Blocks until at least one socket in the selector is ready to perform a read operation.

Returns
true if there is a ready socket

Definition at line 16 of file socket_selector.cpp.


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