… | |
… | |
153 | |
153 | |
154 | You submit a request by calling the relevant C<eio_TYPE> function with the |
154 | You submit a request by calling the relevant C<eio_TYPE> function with the |
155 | required parameters, a callback of type C<int (*eio_cb)(eio_req *req)> |
155 | required parameters, a callback of type C<int (*eio_cb)(eio_req *req)> |
156 | (called C<eio_cb> below) and a freely usable C<void *data> argument. |
156 | (called C<eio_cb> below) and a freely usable C<void *data> argument. |
157 | |
157 | |
158 | The return value will either be 0 |
158 | The return value will either be 0, in case something went really wrong |
|
|
159 | (which can basically only happen on very fatal errors, such as C<malloc> |
|
|
160 | returning 0, which is rather unlikely), or a pointer to the newly-created |
|
|
161 | and submitted C<eio_req *>. |
159 | |
162 | |
160 | The callback will be called with an C<eio_req *> which contains the |
163 | The callback will be called with an C<eio_req *> which contains the |
161 | results of the request. The members you can access inside that structure |
164 | results of the request. The members you can access inside that structure |
162 | vary from request to request, except for: |
165 | vary from request to request, except for: |
163 | |
166 | |
… | |
… | |
226 | custom data value as C<data>. |
229 | custom data value as C<data>. |
227 | |
230 | |
228 | =head3 POSIX API WRAPPERS |
231 | =head3 POSIX API WRAPPERS |
229 | |
232 | |
230 | These requests simply wrap the POSIX call of the same name, with the same |
233 | These requests simply wrap the POSIX call of the same name, with the same |
231 | arguments. If a function is not implemented by the OS and cnanot be emulated |
234 | arguments. If a function is not implemented by the OS and cannot be emulated |
232 | in some way, then all of these return C<-1> and set C<errorno> to C<ENOSYS>. |
235 | in some way, then all of these return C<-1> and set C<errorno> to C<ENOSYS>. |
233 | |
236 | |
234 | =over 4 |
237 | =over 4 |
235 | |
238 | |
236 | =item eio_open (const char *path, int flags, mode_t mode, int pri, eio_cb cb, void *data) |
239 | =item eio_open (const char *path, int flags, mode_t mode, int pri, eio_cb cb, void *data) |
… | |
… | |
316 | { |
319 | { |
317 | char *target = strndup ((char *)req->ptr2, req->result); |
320 | char *target = strndup ((char *)req->ptr2, req->result); |
318 | |
321 | |
319 | free (target); |
322 | free (target); |
320 | } |
323 | } |
|
|
324 | |
|
|
325 | =item eio_realpath (const char *path, int pri, eio_cb cb, void *data) |
|
|
326 | |
|
|
327 | Similar to the realpath libc function, but unlike that one, result is |
|
|
328 | C<0> on failure and the length of the returned path in C<ptr2> - this is |
|
|
329 | similar to readlink. |
321 | |
330 | |
322 | =item eio_stat (const char *path, int pri, eio_cb cb, void *data) |
331 | =item eio_stat (const char *path, int pri, eio_cb cb, void *data) |
323 | |
332 | |
324 | =item eio_lstat (const char *path, int pri, eio_cb cb, void *data) |
333 | =item eio_lstat (const char *path, int pri, eio_cb cb, void *data) |
325 | |
334 | |
… | |
… | |
568 | |
577 | |
569 | =back |
578 | =back |
570 | |
579 | |
571 | =head3 GROUPING AND LIMITING REQUESTS |
580 | =head3 GROUPING AND LIMITING REQUESTS |
572 | |
581 | |
|
|
582 | There is one more rather special request, C<eio_grp>. It is a very special |
|
|
583 | aio request: Instead of doing something, it is a container for other eio |
|
|
584 | requests. |
|
|
585 | |
|
|
586 | There are two primary use cases for this: a) bundle many requests into a |
|
|
587 | single, composite, request with a definite callback and the ability to |
|
|
588 | cancel the whole request with its subrequests and b) limiting the number |
|
|
589 | of "active" requests. |
|
|
590 | |
|
|
591 | Further below you will find more dicussion of these topics - first follows |
|
|
592 | the reference section detailing the request generator and other methods. |
|
|
593 | |
|
|
594 | =over 4 |
|
|
595 | |
|
|
596 | =item eio_grp (eio_cb cb, void *data) |
|
|
597 | |
|
|
598 | Creates and submits a group request. |
|
|
599 | |
|
|
600 | =back |
|
|
601 | |
|
|
602 | |
|
|
603 | |
573 | #TODO |
604 | #TODO |
574 | |
605 | |
575 | /*****************************************************************************/ |
606 | /*****************************************************************************/ |
576 | /* groups */ |
607 | /* groups */ |
577 | |
608 | |