MCPcopy Create free account
hub / github.com/3rdparty/libprocess / poll

Function poll

src/posix/libev/libev_poll.cpp:99–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98
99Future<short> poll(int_fd fd, short events)
100{
101 Poll* poll = new Poll();
102
103 // Have the watchers data point back to the struct.
104 poll->watcher.async->data = poll;
105 poll->watcher.io->data = poll;
106
107 // Get a copy of the future to avoid any races with the event loop.
108 Future<short> future = poll->promise.future();
109
110 // Initialize and start the async watcher.
111 ev_async_init(poll->watcher.async.get(), discard_poll);
112 ev_async_start(loop, poll->watcher.async.get());
113
114 // Make sure we stop polling if a discard occurs on our future.
115 // Note that it's possible that we'll invoke '_poll' when someone
116 // does a discard even after the polling has already completed, but
117 // in this case while we will interrupt the event loop since the
118 // async watcher has already been stopped we won't cause
119 // 'discard_poll' to get invoked.
120 future.onDiscard(lambda::bind(&_poll, poll->watcher.async));
121
122 // Initialize and start the I/O watcher.
123 ev_io_init(poll->watcher.io.get(), polled, fd, events);
124 ev_io_start(loop, poll->watcher.io.get());
125
126 return future;
127}
128
129} // namespace internal {
130

Callers 7

readFunction · 0.50
writeFunction · 0.50
acceptMethod · 0.50
connectMethod · 0.50
sendMethod · 0.50
sendfileMethod · 0.50
TEST_FFunction · 0.50

Calls 4

bindFunction · 0.85
futureMethod · 0.80
initializeFunction · 0.50
getMethod · 0.45

Tested by 1

TEST_FFunction · 0.40