Communicator poller.
More...
#include <poller.h>
◆ Poller()
AsyncBsdSocketLib::Poller::Poller |
( |
| ) |
|
Constructor.
- Exceptions
-
std::runtime_exception | Throws when the poller creation failed |
◆ TryAddListener()
bool AsyncBsdSocketLib::Poller::TryAddListener |
( |
TcpListener * |
tcpListener, |
|
|
std::function< void()> |
callback |
|
) |
| |
Try to add a TCP listener to the poller.
- Parameters
-
tcpListener | TCP listener socket |
callback | Callback to be fired when the socket is ready to accept a client |
- Returns
- True if the socket is added successfully to the poller; otherwise false
◆ TryAddReceiver()
bool AsyncBsdSocketLib::Poller::TryAddReceiver |
( |
Communicator * |
communicator, |
|
|
std::function< void()> |
callback |
|
) |
| |
Try to add a receiver to the poller.
- Parameters
-
communicator | Receiver communicator |
callback | Callback to be fired when the communicator is ready receive data |
- Returns
- True if the communicator is added successfully to the poller; otherwise false
◆ TryAddSender()
bool AsyncBsdSocketLib::Poller::TryAddSender |
( |
Communicator * |
communicator, |
|
|
std::function< void()> |
callback |
|
) |
| |
Try to add a sender to the poller.
- Parameters
-
communicator | Sender communicator |
callback | Callback to be fired when the communicator is ready to send data |
- Returns
- True if the communicator is added successfully to the poller; otherwise false
◆ TryPoll()
bool AsyncBsdSocketLib::Poller::TryPoll |
( |
int |
timeout = 0 | ) |
const |
Try to perform an explicit polling over all the added communicators.
- Parameters
-
timeout | Polling timeout in milliseconds |
- Returns
- True if the polling was successful; otherwise false
- Note
- Zero timeout means immediate return from the polling
-
Timeout '-1' means polling indefinitely until an added communicator becomes available for IO
◆ TryRemoveListener()
bool AsyncBsdSocketLib::Poller::TryRemoveListener |
( |
TcpListener * |
tcpListener | ) |
|
Try to remove the TCP listener from the poller.
- Parameters
-
tcpListener | Previously added TCP listener socket |
- Returns
- True if the socket is removed successfully from the poller; otherwise false
◆ TryRemoveReceiver()
bool AsyncBsdSocketLib::Poller::TryRemoveReceiver |
( |
Communicator * |
communicator | ) |
|
Try to remove the receiver from the poller.
- Parameters
-
communicator | Previously added receiver communicator |
- Returns
- True if the communicator is removed successfully from the poller; otherwise false
◆ TryRemoveSender()
bool AsyncBsdSocketLib::Poller::TryRemoveSender |
( |
Communicator * |
communicator | ) |
|
Try to remove the sender from the poller.
- Parameters
-
communicator | Previously added sender communicator |
- Returns
- True if the communicator is removed successfully from the poller; otherwise false