13 #include <sys/epoll.h> 14 #include <boost/exception/info.hpp> 15 #include <boost/noncopyable.hpp> 41 struct PollerError :
virtual std::exception,
virtual boost::exception { };
66 typedef boost::error_info<struct Info_PollerFileDescriptor, int>
93 virtual void respond(
Poller *poller,
int fd) = 0;
132 responder(prs), fd(f) { }
161 static constexpr
int maxEvents = 32;
169 Poller(
int reserveSize = 0);
211 void add(
const PollResponderSptr &prs,
int fd,
int events = EPOLLIN);
262 int wait(std::chrono::milliseconds timeout);
271 return wait(std::chrono::milliseconds(-1));
279 return wait(std::chrono::milliseconds(0));
285 #endif // #ifndef POLLER_HPP Responds to a poll event.
std::vector< ResponderRecord > ResponderVec
Type that holds PollResponder objects and their associated file descriptors.
ResponderVec responders
The responders and their file descriptors.
int fd
The file descriptor.
A simple C++ interface to using Linux's epoll functions.
The call to epoll_create() failed.
std::weak_ptr< PollResponder > responder
The PollResponder held with a weak pointer.
int epfd
The file descriptor provided by epoll_create().
boost::error_info< struct Info_PollerFileDescriptor, int > PollerFileDescriptor
Poller error attribute that includes the value of the file descriptor.
Attempted to use a non-existent PollResponder object.
std::shared_ptr< PollResponder > PollResponderSptr
ResponderRecord(const PollResponderSptr &prs, int f)
int wait()
Waits indefinitely for events, only returning after an event is received.
std::vector< int > flist
Free spot list.
int respond()
Responds to events that are already waiting.
An operation (remove) resulted in an error from an epoll function indicating that the file descriptor...
Holds a PollResponder object and its associated file descriptor.
std::mutex block
Used to allow for thread-safe operation.
The base class for all Poller errors; used for general errors.