This is the base class for socket engines. The actual implementation is OS specific and the correct implementation is detected by CMake. It is then compiled specifically into DPP so only one implementation can exist in the implementation. All implementations should behave identically to the user, abstracting out implementation-specific behaviours (e.g. difference between edge and level triggered event mechanisms etc).
More...
#include <socketengine.h>
This is the base class for socket engines. The actual implementation is OS specific and the correct implementation is detected by CMake. It is then compiled specifically into DPP so only one implementation can exist in the implementation. All implementations should behave identically to the user, abstracting out implementation-specific behaviours (e.g. difference between edge and level triggered event mechanisms etc).
◆ socket_engine_base() [1/3]
| dpp::socket_engine_base::socket_engine_base |
( |
class cluster * | creator | ) |
|
Default constructor.
- Parameters
-
◆ socket_engine_base() [2/3]
| dpp::socket_engine_base::socket_engine_base |
( |
const socket_engine_base & | | ) |
|
|
delete |
◆ socket_engine_base() [3/3]
| dpp::socket_engine_base::socket_engine_base |
( |
socket_engine_base && | | ) |
|
|
delete |
◆ ~socket_engine_base()
| virtual dpp::socket_engine_base::~socket_engine_base |
( |
| ) |
|
|
virtual |
◆ delete_socket()
| bool dpp::socket_engine_base::delete_socket |
( |
dpp::socket | fd | ) |
|
Delete a socket from the socket engine.
- Note
- This will not remove the socket immediately. It will set the WANT_DELETION flag causing it to be removed as soon as is safe to do so (once all events associated with it are completed).
- Parameters
-
- Returns
- true if socket was queued for deletion
◆ get_fd()
Find a file descriptors socket events.
- Parameters
-
- Returns
- file descriptor or nullptr if doesn't exist
◆ get_stats()
| const socket_stats & dpp::socket_engine_base::get_stats |
( |
| ) |
const |
Get statistics for socket engine.
- Returns
- socket stats
◆ inplace_modify_fd()
| void dpp::socket_engine_base::inplace_modify_fd |
( |
dpp::socket | fd, |
|
|
uint8_t | extra_flags ) |
Merge new flags in with the given file descriptor.
- Parameters
-
| fd | file descriptor |
| extra_flags | extra flags to add |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ process_events()
| virtual void dpp::socket_engine_base::process_events |
( |
| ) |
|
|
pure virtual |
Should be called repeatedly in a loop. Will run for a maximum of 1 second.
◆ prune()
| void dpp::socket_engine_base::prune |
( |
| ) |
|
Iterate through the list of sockets and remove any with WANT_DELETION set. This will also call implementation-specific remove_socket() on each entry to be removed.
◆ register_socket()
| virtual bool dpp::socket_engine_base::register_socket |
( |
const socket_events & | e | ) |
|
|
virtual |
Register a new socket with the socket engine.
- Parameters
-
- Returns
- true if socket was added
◆ remove_socket()
| virtual bool dpp::socket_engine_base::remove_socket |
( |
dpp::socket | fd | ) |
|
|
protectedvirtual |
Called by the prune() function to remove sockets when safe to do so. This is normally at the end or before an iteration of the event loop.
- Parameters
-
| fd | File descriptor to remove |
◆ update_socket()
| virtual bool dpp::socket_engine_base::update_socket |
( |
const socket_events & | e | ) |
|
|
virtual |
Update an existing socket in the socket engine.
- Parameters
-
- Returns
- true if socket was updated
◆ fds
File descriptors, and their states.
◆ fds_mutex
| std::shared_mutex dpp::socket_engine_base::fds_mutex |
|
protected |
◆ owner
| class cluster* dpp::socket_engine_base::owner {nullptr} |
◆ stats
Socket engine statistics.