… | |
… | |
233 | |
233 | |
234 | The C<void *data> member simply stores the value of the C<data> argument. |
234 | The C<void *data> member simply stores the value of the C<data> argument. |
235 | |
235 | |
236 | =back |
236 | =back |
237 | |
237 | |
|
|
238 | Members not explicitly described as accessible must not be |
|
|
239 | accessed. Specifically, there is no guarantee that any members will still |
|
|
240 | have the value they had when the request was submitted. |
|
|
241 | |
238 | The return value of the callback is normally C<0>, which tells libeio to |
242 | The return value of the callback is normally C<0>, which tells libeio to |
239 | continue normally. If a callback returns a nonzero value, libeio will |
243 | continue normally. If a callback returns a nonzero value, libeio will |
240 | stop processing results (in C<eio_poll>) and will return the value to its |
244 | stop processing results (in C<eio_poll>) and will return the value to its |
241 | caller. |
245 | caller. |
242 | |
246 | |
243 | Memory areas passed to libeio must stay valid as long as a request |
247 | Memory areas passed to libeio wrappers must stay valid as long as a |
244 | executes, with the exception of paths, which are being copied |
248 | request executes, with the exception of paths, which are being copied |
245 | internally. Any memory libeio itself allocates will be freed after the |
249 | internally. Any memory libeio itself allocates will be freed after the |
246 | finish callback has been called. If you want to manage all memory passed |
250 | finish callback has been called. If you want to manage all memory passed |
247 | to libeio yourself you can use the low-level API. |
251 | to libeio yourself you can use the low-level API. |
248 | |
252 | |
249 | For example, to open a file, you could do this: |
253 | For example, to open a file, you could do this: |
… | |
… | |
626 | |
630 | |
627 | =over 4 |
631 | =over 4 |
628 | |
632 | |
629 | =item eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data) |
633 | =item eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data) |
630 | |
634 | |
631 | Reads (C<flags == 0>) or modifies (C<flags == EIO_MT_MODIFY) the given |
635 | Reads (C<flags == 0>) or modifies (C<flags == EIO_MT_MODIFY>) the given |
632 | memory area, page-wise, that is, it reads (or reads and writes back) the |
636 | memory area, page-wise, that is, it reads (or reads and writes back) the |
633 | first octet of every page that spans the memory area. |
637 | first octet of every page that spans the memory area. |
634 | |
638 | |
635 | This can be used to page in some mmapped file, or dirty some pages. Note |
639 | This can be used to page in some mmapped file, or dirty some pages. Note |
636 | that dirtying is an unlocked read-write access, so races can ensue when |
640 | that dirtying is an unlocked read-write access, so races can ensue when |
… | |
… | |
760 | request finish on its own. |
764 | request finish on its own. |
761 | |
765 | |
762 | =item 3) open callback adds more requests |
766 | =item 3) open callback adds more requests |
763 | |
767 | |
764 | In the open callback, if the open was not successful, copy C<< |
768 | In the open callback, if the open was not successful, copy C<< |
765 | req->errorno >> to C<< grp->errorno >> and set C<< grp->errorno >> to |
769 | req->errorno >> to C<< grp->errorno >> and set C<< grp->result >> to |
766 | C<-1> to signal an error. |
770 | C<-1> to signal an error. |
767 | |
771 | |
768 | Otherwise, malloc some memory or so and issue a read request, adding the |
772 | Otherwise, malloc some memory or so and issue a read request, adding the |
769 | read request to the group. |
773 | read request to the group. |
770 | |
774 | |
771 | =item 4) continue issuing requests till finished |
775 | =item 4) continue issuing requests till finished |
772 | |
776 | |
773 | In the real callback, check for errors and possibly continue with |
777 | In the read callback, check for errors and possibly continue with |
774 | C<eio_close> or any other eio request in the same way. |
778 | C<eio_close> or any other eio request in the same way. |
775 | |
779 | |
776 | As soon as no new requests are added the group request will finish. Make |
780 | As soon as no new requests are added, the group request will finish. Make |
777 | sure you I<always> set C<< grp->result >> to some sensible value. |
781 | sure you I<always> set C<< grp->result >> to some sensible value. |
778 | |
782 | |
779 | =back |
783 | =back |
780 | |
784 | |
781 | =head4 REQUEST LIMITING |
785 | =head4 REQUEST LIMITING |