… | |
… | |
130 | |
130 | |
131 | If C<eio_poll ()> is configured to not handle all results in one go |
131 | If C<eio_poll ()> is configured to not handle all results in one go |
132 | (i.e. it returns C<-1>) then you should start an idle watcher that calls |
132 | (i.e. it returns C<-1>) then you should start an idle watcher that calls |
133 | C<eio_poll> until it returns something C<!= -1>. |
133 | C<eio_poll> until it returns something C<!= -1>. |
134 | |
134 | |
135 | A full-featured wrapper would look as follows (if C<eio_poll> is handling |
135 | A full-featured conenctor between libeio and libev would look as follows |
136 | all requests, it can of course be simplified a lot by removing the idle |
136 | (if C<eio_poll> is handling all requests, it can of course be simplified a |
137 | watcher logic): |
137 | lot by removing the idle watcher logic): |
138 | |
138 | |
139 | static struct ev_loop *loop; |
139 | static struct ev_loop *loop; |
140 | static ev_idle repeat_watcher; |
140 | static ev_idle repeat_watcher; |
141 | static ev_async ready_watcher; |
141 | static ev_async ready_watcher; |
142 | |
142 | |
… | |
… | |
178 | |
178 | |
179 | For most other event loops, you would typically use a pipe - the event |
179 | For most other event loops, you would typically use a pipe - the event |
180 | loop should be told to wait for read readiness on the read end. In |
180 | loop should be told to wait for read readiness on the read end. In |
181 | C<want_poll> you would write a single byte, in C<done_poll> you would try |
181 | C<want_poll> you would write a single byte, in C<done_poll> you would try |
182 | to read that byte, and in the callback for the read end, you would call |
182 | to read that byte, and in the callback for the read end, you would call |
183 | C<eio_poll>. The race is avoided here because the event loop should invoke |
183 | C<eio_poll>. |
184 | your callback again and again until the byte has been read (as the pipe |
184 | |
185 | read callback does not read it, only C<done_poll>). |
185 | You don't have to take special care in the case C<eio_poll> doesn't handle |
|
|
186 | all requests, as the done callback will not be invoked, so the event loop |
|
|
187 | will still signal readyness for the pipe until I<all> results have been |
|
|
188 | processed. |
186 | |
189 | |
187 | |
190 | |
188 | =head1 HIGH LEVEL REQUEST API |
191 | =head1 HIGH LEVEL REQUEST API |
189 | |
192 | |
190 | Libeio has both a high-level API, which consists of calling a request |
193 | Libeio has both a high-level API, which consists of calling a request |