This class waits on registered file descriptor for events.
More...
#include <event-poll.hpp>
|
typedef std::function< void(int
fd, Events events)> | Callback |
| Generic function type used as callback for epoll events. More...
|
|
|
typedef std::recursive_mutex | Mutex |
|
This class waits on registered file descriptor for events.
It uses epoll mechanism.
- See Also
- cargo::ipc::epoll::Events
Generic function type used as callback for epoll events.
- Parameters
-
fd | descriptor that triggered the event |
events | event mask that occured |
- See Also
- cargo::ipc::epoll::Events
cargo::ipc::epoll::EventPoll::EventPoll |
( |
| ) |
|
Constructs the EventPoll and initializes the underlaying epoll mechanism.
- Exceptions
-
UtilsException | thrown if epoll initialization failed |
cargo::ipc::epoll::EventPoll::~EventPoll |
( |
| ) |
|
void cargo::ipc::epoll::EventPoll::addFD |
( |
const int |
fd, |
|
|
const Events |
events, |
|
|
Callback && |
callback |
|
) |
| |
Add descriptor and it's watched events.
- Parameters
-
fd | descriptor to watch |
events | events to associate with the descriptor |
callback | callback to call once the event occurs |
- Exceptions
-
UtilsException | thrown if descriptor already registered or add fail |
- See Also
- cargo::ipc::epoll::Events
bool cargo::ipc::epoll::EventPoll::addFDInternal |
( |
const int |
fd, |
|
|
const Events |
events |
|
) |
| |
|
private |
bool cargo::ipc::epoll::EventPoll::dispatchIteration |
( |
const int |
timeoutMs | ) |
|
Wait for events on descriptor on the watch list.
Dispatch at most one signaled FD.
- Parameters
-
timeoutMs | how long should wait in case of no pending events (0 - return immediately, -1 - wait forever) |
- Exceptions
-
UtilsException | if epoll_wait fails |
- Returns
- false on timeout
int cargo::ipc::epoll::EventPoll::getPollFD |
( |
| ) |
const |
Returns epoll handle.
- Returns
- handle or -1 if not initialized
void cargo::ipc::epoll::EventPoll::modifyFD |
( |
const int |
fd, |
|
|
const Events |
events |
|
) |
| |
Modify watched events for descriptor.
- Parameters
-
fd | watched descriptor, already registered |
events | events to associate with the descriptor |
- Exceptions
-
UtilsException | if descriptor not found or epoll modify fail |
- See Also
- cargo::ipc::epoll::Events
bool cargo::ipc::epoll::EventPoll::modifyFDInternal |
( |
const int |
fd, |
|
|
const Events |
events |
|
) |
| |
|
private |
void cargo::ipc::epoll::EventPoll::removeFD |
( |
const int |
fd | ) |
|
Remove descriptor from the watch list.
- Parameters
-
void cargo::ipc::epoll::EventPoll::removeFDInternal |
( |
const int |
fd | ) |
|
|
private |
std::unordered_map<int, std::shared_ptr<Callback> > cargo::ipc::epoll::EventPoll::mCallbacks |
|
private |
Mutex cargo::ipc::epoll::EventPoll::mMutex |
|
private |
const int cargo::ipc::epoll::EventPoll::mPollFD |
|
private |
The documentation for this class was generated from the following files: