qb
2.0.0.0
C++17 Actor Framework
|
High-level epoll event poller. More...
#include <epoll.h>
Public Member Functions | |
Poller () | |
Constructor. | |
Poller (Poller const &)=delete | |
Copy constructor (deleted) | |
~Poller () | |
Destructor. | |
template<typename _Func> | |
void | wait (_Func const &func, int const timeout=0) |
Wait for events and process them. | |
Public Member Functions inherited from qb::io::epoll::Proxy | |
Proxy ()=default | |
Default constructor. | |
Proxy (const int epoll) | |
Constructor. | |
Proxy (Proxy const &)=default | |
Copy constructor. | |
int | ctl (item_type &item) const |
Modify an existing file descriptor in the epoll set. | |
int | add (item_type &item) const |
Add a new file descriptor to the epoll set. | |
int | remove (item_type const &item) |
Remove a file descriptor from the epoll set. |
Additional Inherited Members | |
Public Types inherited from qb::io::epoll::Proxy | |
using | item_type = epoll_event |
Type alias for epoll event item. | |
Protected Attributes inherited from qb::io::epoll::Proxy | |
int | _epoll |
The epoll file descriptor. |
High-level epoll event poller.
This template class provides a convenient interface for using epoll to wait for events on multiple file descriptors. It handles the creation and destruction of the epoll file descriptor and provides a simple callback-based interface for event handling.
_MAX_EVENTS | Maximum number of events to handle at once |
|
inline |
Constructor.
Creates a new epoll instance with the specified maximum number of events. Throws a runtime_error if the epoll creation fails.
|
delete |
Copy constructor (deleted)
Epoll file descriptors should not be shared between objects.
|
inline |
Destructor.
Closes the epoll file descriptor.
|
inline |
Wait for events and process them.
This method waits for events on the epoll file descriptor and calls the provided function for each event that occurs.
_Func | Type of the callback function |
func | Callback function to handle events |
timeout | Maximum time to wait in milliseconds (0 = return immediately, -1 = wait indefinitely) |