HDK
|
Abstracts the socket file descriptor set for select() or poll() calls. More...
#include <UT_NetFDSet.h>
Classes | |
class | EventInfo |
Public Member Functions | |
UT_NetFDSet (bool fast=false, UT_NetFDMode mode=UT_NetFDMode::NETFD_DEFAULT_MODE) | |
~UT_NetFDSet () | |
bool | add (int fd, UT_NetFDEvent event) |
bool | add (int fd, const UT_SmallArray< UT_NetFDEvent > &events) |
bool | modify (int fd, const UT_SmallArray< UT_NetFDEvent > &events) |
Modify a file descriptor flags. More... | |
void | remove (int fd) |
Remove a file descriptor from the set. More... | |
bool | contains (int fd) const |
Test whether a file descriptor is in the set. More... | |
void | removeAll () |
Removes all added file descriptors for all events (resets the set). More... | |
int | checkEvents (int timeout_ms) const |
bool | isEmpty () const |
Returns true if the set contains no file descriptors. More... | |
bool | isActive (int fd, UT_NetFDEvent event) const |
bool | getInfoWithFD (int fd, EventInfo &info) const |
bool | getAnyEvents (UT_Array< EventInfo > &events, int timeout_ms) const |
void | setMode (UT_NetFDMode mode) |
SYS_NO_DISCARD_RESULT UT_NetFDMode | mode () const |
Static Public Attributes | |
static const int | INDEFINITE_WAIT |
Constants denoting special wait times for checkEvents() More... | |
static const int | NO_WAIT |
Abstracts the socket file descriptor set for select() or poll() calls.
Definition at line 51 of file UT_NetFDSet.h.
UT_NetFDSet::UT_NetFDSet | ( | bool | fast = false , |
UT_NetFDMode | mode = UT_NetFDMode::NETFD_DEFAULT_MODE |
||
) |
Constructor and desctructor.
fast | This informs the fd set to use the performant variant for the platform. This is currently only support on some platforms. |
mode | The mode to run the fd set in. |
UT_NetFDSet::~UT_NetFDSet | ( | ) |
bool UT_NetFDSet::add | ( | int | fd, |
UT_NetFDEvent | event | ||
) |
Adds a file descriptor to the set with the intent of monitoring the given IO event.
bool UT_NetFDSet::add | ( | int | fd, |
const UT_SmallArray< UT_NetFDEvent > & | events | ||
) |
Adds a file descriptor to the set with the intent of monitoring a set of given IO events.
Checks or waits for the IO events on the file descriptors in the set. Essentially it's a wrapper for select() or poll().
timeout_ms | The timeout to wait for connection (in miliseconds). If zero, the call does not wait for the events, but instead checks for the current state of the FDs in the set. If negative, the call blocks indefinitely, waiting for the first event. This is equivalent to passing NULL to select() or -1 to poll() as time value. |
bool UT_NetFDSet::contains | ( | int | fd | ) | const |
Test whether a file descriptor is in the set.
Get all events current events in the set. This will wait up to timeout_ms before returning.
events | The list of all current events in the set. The size of the array is 0..number of fd in set. |
timeout_ms | The maximum amount of time to wait before givin up. The timeout is in ms. |
events
has any events in the list. Get all IO activity from an fd. Returns false if something has gone wrong.
fd | This is the file descriptor to get the io information for. |
info | This is the information about a IO activity from the file descriptor provided. |
bool UT_NetFDSet::isActive | ( | int | fd, |
UT_NetFDEvent | event | ||
) | const |
Returns true if there was any IO activity of the given type on the given file descriptor.
bool UT_NetFDSet::isEmpty | ( | ) | const |
Returns true if the set contains no file descriptors.
|
inline |
Definition at line 142 of file UT_NetFDSet.h.
bool UT_NetFDSet::modify | ( | int | fd, |
const UT_SmallArray< UT_NetFDEvent > & | events | ||
) |
Modify a file descriptor flags.
void UT_NetFDSet::removeAll | ( | ) |
Removes all added file descriptors for all events (resets the set).
|
inline |
In some cases the mode wont be decided until after the fd set is created. The mode CANNOT be changed while the fdset has fd in it!
mode | The mode to run the fd set in. |
Definition at line 141 of file UT_NetFDSet.h.
Constants denoting special wait times for checkEvents()
Definition at line 110 of file UT_NetFDSet.h.
Definition at line 111 of file UT_NetFDSet.h.