16 if (pipe(wakeupPipe)) {
17 wakeupPipe[0] = wakeupPipe[1] = -1;
18 perror(
"Failed to open wakeup pipe");
36 if (write(wakeupPipe[1], &dummy,
sizeof(dummy)) == -1) {
46 struct pollfd fds[2] = {
47 { .fd = fd, .events = POLLIN, .revents = 0 },
48 { .fd = wakeupPipe[0], .events = POLLIN, .revents = 0 },
50 int pollResult =
::poll(fds, 2, 1000);
54 if (pollResult == -1) {
57 if (pollResult != 0) {
bool poll(int fd)
Waits for an event to occur on the given file descriptor.
void abort()
Aborts a poll in progress and any future poll attempts.
This file implemented 3 utility functions: