1 #ifndef _NET_POLL_TABLE_H_
2 #define _NET_POLL_TABLE_H_
72 void Add(
int fd,
int mask)
74 fds.push_back(
PollFD(fd, mask));
85 return poll(&(fds[0]), (
int)fds.size(), timeout);
103 vector<PollFD>::iterator i = find(fds.begin(), fds.end(), fd);
104 if(i != fds.end()) fds.erase(i);
114 fds.erase(fds.begin() + n);
This class allows to perfom polls easily over a vector of descriptors.
Definition: poll_table.h:54
int Poll(int timeout=-1)
Peforms a poll over all the descriptors using the associated masks.
Definition: poll_table.h:83
int GetSize() const
Returns the size of the internal vector.
Definition: poll_table.h:91
PollFD(int vfd, int mask)
Initializes the structure.
Definition: poll_table.h:28
bool operator==(int n)
Returns true if the file descriptor is the same as the given value.
Definition: poll_table.h:39
void Remove(int fd)
Removes an item of the internal vector giving its file descriptor.
Definition: poll_table.h:101
PollTable()
Definition: poll_table.h:63
void Add(int fd, int mask)
Adds a new file descriptor and mask to the vector.
Definition: poll_table.h:72
vector< PollFD > fds
Vector with the file descriptors and masks for polling.
Definition: poll_table.h:60
PollFD & operator[](int n)
Indexing operator.
Definition: poll_table.h:120
void RemoveAt(int n)
Remove an item of the internal vector giving its index position.
Definition: poll_table.h:112
virtual ~PollTable()
Definition: poll_table.h:125
Wrapper structure for the structure pollfd used by the kernel poll functions.
Definition: poll_table.h:21