OSAPIEventWithFd Class
The OSAPIEventWithFd is a Windows and Linux conformant event which is listened to by calling poll() or select() on the caller thread. More...
Header: | #include <OSAPI/Process/OSAPIEventWithFd.h> |
Public Functions
OSAPIEventWithFd() | |
~OSAPIEventWithFd() | |
OSAPIFILEDESCRIPTOR | GetFd() |
bool | IsSignalled() |
void | Reset() |
void | Set() |
Detailed Description
The OSAPIEventWithFd is a Windows and Linux conformant event which is listened to by calling poll() or select() on the caller thread.
Example:
/** * (c)2017 CDP Technologies AS */ // signaller thread: OSAPIEventWithFd osapiEvent; osapiEvent.Set(); ... // listener thread: #include <OSAPI/Process/OSAPIProcess.h> std::vector<OSAPIFILEDESCRIPTOR> fds; fd_set fdset; fds.push_back(osapiEvent->GetFd()); int ret = OSAPISelect(fds, &fdset, 10)); if(ret >= 0) { if(ret > 0) { if(FD_ISSET(osapiEvent->GetFd(), &fdset) { // osapiEvent received! } } } else { // error handling }
See also OSAPIEvent.
Member Function Documentation
OSAPIEventWithFd::OSAPIEventWithFd()
Constructs an event.
OSAPIEventWithFd::~OSAPIEventWithFd()
Destructs the event.
OSAPIFILEDESCRIPTOR OSAPIEventWithFd::GetFd()
Gets the underlying file descriptor of the event, which can be used to wait for event, using poll() or select().
Returns the descriptor
bool OSAPIEventWithFd::IsSignalled()
Returns true
if event is in signaled state, otherwise false
.
void OSAPIEventWithFd::Reset()
Sets the event to nonsignaled state
void OSAPIEventWithFd::Set()
Sets the event
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.