14 #ifndef THRILL_NET_TCP_SELECT_HEADER 15 #define THRILL_NET_TCP_SELECT_HEADER 17 #include <sys/select.h> 82 { assert(fd >= 0); FD_CLR(fd, &
read_set_);
return *
this; }
86 { assert(fd >= 0); FD_CLR(fd, &
write_set_);
return *
this; }
90 { assert(fd >= 0); FD_CLR(fd, &
except_set_);
return *
this; }
97 int select(
struct timeval* timeout =
nullptr) {
104 if (timeout == std::numeric_limits<double>::infinity())
108 tv.tv_sec =
static_cast<time_t
>(timeout / 1000);
109 tv.tv_usec =
static_cast<time_t
>(
110 (timeout / 1000.0 -
static_cast<double>(tv.tv_sec)) * 1000000);
135 #endif // !THRILL_NET_TCP_SELECT_HEADER Select & ClearException(int fd)
Clear a file descriptor from the exception set.
bool InException(int fd) const
Check if a file descriptor is in the resulting exception set.
static uint_pair max()
return an uint_pair instance containing the largest value possible
bool InWrite(int fd) const
Check if a file descriptor is in the resulting Write set.
Select & ClearWrite(int fd)
Clear a file descriptor from the write set.
Select is an object-oriented wrapper for select().
int max_fd_
maximum file descriptor value in bitsets
int select_timeout(double timeout)
Do a select() with timeout (in ms)
int select(struct timeval *timeout=nullptr)
Do a select(), which modifies the enclosed file descriptor objects.
fd_set except_set_
exception bit-field
fd_set write_set_
write bit-field
Select & SetRead(int fd)
Add a socket to the read and exception selection set.
fd_set read_set_
read bit-field
Select & Clear(int fd)
Clear a file descriptor from all sets.
Select & SetWrite(int fd)
Add a socket to the write and exception selection set.
Select & SetException(int fd)
Add a socket to the exception selection set.
Select & ClearRead(int fd)
Clear a file descriptor from the read set.
bool InRead(int fd) const
Check if a file descriptor is in the resulting read set.