| 221 | } |
| 222 | |
| 223 | inline void SetImpl(void* data, int fd, int what) { |
| 224 | TEvent e; |
| 225 | |
| 226 | Zero(e); |
| 227 | |
| 228 | if (what & CONT_POLL_EDGE_TRIGGERED) { |
| 229 | if (what & CONT_POLL_BACKLOG_EMPTY) { |
| 230 | // When backlog is empty, edge-triggered does not need restart. |
| 231 | return; |
| 232 | } |
| 233 | e.events |= EPOLLET; |
| 234 | } |
| 235 | |
| 236 | if (what & CONT_POLL_ONE_SHOT) { |
| 237 | e.events |= EPOLLONESHOT; |
| 238 | } |
| 239 | |
| 240 | if (what & CONT_POLL_READ) { |
| 241 | e.events |= EPOLLIN; |
| 242 | } |
| 243 | |
| 244 | if (what & CONT_POLL_WRITE) { |
| 245 | e.events |= EPOLLOUT; |
| 246 | } |
| 247 | |
| 248 | if (what & CONT_POLL_RDHUP) { |
| 249 | e.events |= EPOLLRDHUP; |
| 250 | } |
| 251 | |
| 252 | e.data.ptr = data; |
| 253 | |
| 254 | if (what & CONT_POLL_MODIFY) { |
| 255 | if (epoll_ctl(Fd_, EPOLL_CTL_MOD, fd, &e) == -1) { |
| 256 | ythrow TSystemError() << "epoll modify failed (fd=" << fd << ", what=" << what << ")"; |
| 257 | } |
| 258 | } else if (epoll_ctl(Fd_, EPOLL_CTL_ADD, fd, &e) == -1) { |
| 259 | if (LastSystemError() != EEXIST) { |
| 260 | ythrow TSystemError() << "epoll add failed (fd=" << fd << ", what=" << what << ")"; |
| 261 | } |
| 262 | |
| 263 | if (epoll_ctl(Fd_, EPOLL_CTL_MOD, fd, &e) == -1) { |
| 264 | ythrow TSystemError() << "epoll modify failed (fd=" << fd << ", what=" << what << ")"; |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | inline void Remove(int fd) noexcept { |
| 270 | TEvent e; |
no test coverage detected