Event loop callback when future associated with polling file descriptor has been discarded.
| 65 | // Event loop callback when future associated with polling file |
| 66 | // descriptor has been discarded. |
| 67 | void discard_poll(struct ev_loop* loop, ev_async* watcher, int revents) |
| 68 | { |
| 69 | Poll* poll = (Poll*) watcher->data; |
| 70 | |
| 71 | // Check and see if we have a pending 'polled' callback and if so |
| 72 | // let it "win". |
| 73 | if (ev_is_pending(poll->watcher.io.get())) { |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | ev_async_stop(loop, poll->watcher.async.get()); |
| 78 | |
| 79 | // Stop the I/O watcher (but note we check if pending above) so it |
| 80 | // won't get invoked and we can delete 'poll' here. |
| 81 | ev_io_stop(loop, poll->watcher.io.get()); |
| 82 | |
| 83 | poll->promise.discard(); |
| 84 | |
| 85 | delete poll; |
| 86 | } |
| 87 | |
| 88 | |
| 89 | namespace io { |