|
plptools
|
A simple thread-safe wrapper for select() More...
#include <iowatch.h>
Public Member Functions | |
| IOWatch () | |
| Creates a new instance. More... | |
| ~IOWatch () | |
| Destroys an instance. More... | |
| void | addIO (const int fd) |
| Adds a file descriptor to the set of descriptors. More... | |
| void | remIO (const int fd) |
| Removes a file descriptor from the set of descriptors. More... | |
| bool | watch (const long secs, const long usecs) |
| Performs a select() call. More... | |
Private Attributes | |
| std::mutex | lock_ |
| int | fileDescriptorCount_ |
| int * | fileDescriptors_ |
A simple thread-safe wrapper for select()
IOWatch is a simple wrapper for the select system call. In particular, it takes care of passing the maximum file descriptor argument (arg 1) of select() correctly. IOWatch handles select on read descriptors only.
| IOWatch::IOWatch | ( | ) |
Creates a new instance.
Definition at line 32 of file iowatch.cc.
| IOWatch::~IOWatch | ( | ) |
Destroys an instance.
Definition at line 38 of file iowatch.cc.
| void IOWatch::addIO | ( | const int | fd | ) |
Adds a file descriptor to the set of descriptors.
| fd | The file descriptor to add. |
Definition at line 42 of file iowatch.cc.
| void IOWatch::remIO | ( | const int | fd | ) |
Removes a file descriptor from the set of descriptors.
| fd | The file descriptor to remove. |
Definition at line 54 of file iowatch.cc.
| bool IOWatch::watch | ( | const long | secs, |
| const long | usecs | ||
| ) |
Performs a select() call.
| secs | Number of seconds to wait. |
| usecs | Number of microseconds to wait. |
Definition at line 64 of file iowatch.cc.