D++ (DPP)
C++ Discord API Bot Library
|
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>
Public Member Functions | |
socket_engine_base (class cluster *creator) | |
Default constructor. More... | |
socket_engine_base (const socket_engine_base &)=delete | |
Non-copyable. More... | |
socket_engine_base (socket_engine_base &&)=delete | |
Non-copyable. More... | |
socket_engine_base & | operator= (const socket_engine_base &)=delete |
Non-movable. More... | |
socket_engine_base & | operator= (socket_engine_base &&)=delete |
Non-movable. More... | |
virtual | ~socket_engine_base ()=default |
Default destructor. More... | |
virtual void | process_events ()=0 |
Should be called repeatedly in a loop. Will run for a maximum of 1 second. More... | |
virtual bool | register_socket (const socket_events &e) |
Register a new socket with the socket engine. More... | |
virtual bool | update_socket (const socket_events &e) |
Update an existing socket in the socket engine. More... | |
bool | delete_socket (dpp::socket fd) |
Delete a socket from the socket engine. More... | |
void | 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. More... | |
void | inplace_modify_fd (dpp::socket fd, uint8_t extra_flags) |
Merge new flags in with the given file descriptor. More... | |
const socket_stats & | get_stats () const |
Get statistics for socket engine. More... | |
Public Attributes | |
class cluster * | owner {nullptr} |
Owning cluster. More... | |
Protected Member Functions | |
socket_events * | get_fd (dpp::socket fd) |
Find a file descriptors socket events. More... | |
virtual bool | remove_socket (dpp::socket fd) |
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. More... | |
Protected Attributes | |
std::shared_mutex | fds_mutex |
Mutex for fds. More... | |
socket_container | fds |
File descriptors, and their states. More... | |
socket_stats | stats {} |
Socket engine statistics. More... | |
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).
dpp::socket_engine_base::socket_engine_base | ( | class cluster * | creator | ) |
Default constructor.
creator | Owning cluster |
|
delete |
Non-copyable.
|
delete |
Non-copyable.
|
virtualdefault |
Default destructor.
bool dpp::socket_engine_base::delete_socket | ( | dpp::socket | fd | ) |
Delete a socket from the socket engine.
e | File descriptor |
|
protected |
Find a file descriptors socket events.
fd | file descriptor |
const socket_stats & dpp::socket_engine_base::get_stats | ( | ) | const |
Get statistics for socket engine.
void dpp::socket_engine_base::inplace_modify_fd | ( | dpp::socket | fd, |
uint8_t | extra_flags | ||
) |
Merge new flags in with the given file descriptor.
fd | file descriptor |
extra_flags | extra flags to add |
|
delete |
Non-movable.
|
delete |
Non-movable.
|
pure virtual |
Should be called repeatedly in a loop. Will run for a maximum of 1 second.
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.
|
virtual |
Register a new socket with the socket engine.
e | Socket events |
|
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.
fd | File descriptor to remove |
|
virtual |
Update an existing socket in the socket engine.
e | Socket events |
|
protected |
File descriptors, and their states.
|
protected |
Mutex for fds.
class cluster* dpp::socket_engine_base::owner {nullptr} |
Owning cluster.
|
protected |
Socket engine statistics.