ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libeio/eio.pod
(Generate patch)

Comparing libeio/eio.pod (file contents):
Revision 1.29 by sf-exg, Mon Sep 26 17:10:10 2011 UTC vs.
Revision 1.34 by root, Mon Mar 11 07:59:41 2013 UTC

25similar functions, as well as less rarely ones such as C<mknod>, C<futime> 25similar functions, as well as less rarely ones such as C<mknod>, C<futime>
26or C<readlink>. 26or C<readlink>.
27 27
28It also offers wrappers around C<sendfile> (Solaris, Linux, HP-UX and 28It also offers wrappers around C<sendfile> (Solaris, Linux, HP-UX and
29FreeBSD, with emulation on other platforms) and C<readahead> (Linux, with 29FreeBSD, with emulation on other platforms) and C<readahead> (Linux, with
30emulation elsewhere>). 30emulation elsewhere).
31 31
32The goal is to enable you to write fully non-blocking programs. For 32The goal is to enable you to write fully non-blocking programs. For
33example, in a game server, you would not want to freeze for a few seconds 33example, in a game server, you would not want to freeze for a few seconds
34just because the server is running a backup and you happen to call 34just because the server is running a backup and you happen to call
35C<readdir>. 35C<readdir>.
176 { 176 {
177 loop = EV_DEFAULT; 177 loop = EV_DEFAULT;
178 178
179 ev_idle_init (&repeat_watcher, repeat); 179 ev_idle_init (&repeat_watcher, repeat);
180 ev_async_init (&ready_watcher, ready); 180 ev_async_init (&ready_watcher, ready);
181 ev_async_start (loop &watcher); 181 ev_async_start (loop, &watcher);
182 182
183 eio_init (want_poll, 0); 183 eio_init (want_poll, 0);
184 } 184 }
185 185
186For most other event loops, you would typically use a pipe - the event 186For most other event loops, you would typically use a pipe - the event
630 630
631=over 4 631=over 4
632 632
633=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)
634 634
635Reads (C<flags == 0>) or modifies (C<flags == EIO_MT_MODIFY) the given 635Reads (C<flags == 0>) or modifies (C<flags == EIO_MT_MODIFY>) the given
636memory area, page-wise, that is, it reads (or reads and writes back) the 636memory area, page-wise, that is, it reads (or reads and writes back) the
637first octet of every page that spans the memory area. 637first octet of every page that spans the memory area.
638 638
639This can be used to page in some mmapped file, or dirty some pages. Note 639This can be used to page in some mmapped file, or dirty some pages. Note
640that dirtying is an unlocked read-write access, so races can ensue when 640that dirtying is an unlocked read-write access, so races can ensue when
764request finish on its own. 764request finish on its own.
765 765
766=item 3) open callback adds more requests 766=item 3) open callback adds more requests
767 767
768In the open callback, if the open was not successful, copy C<< 768In the open callback, if the open was not successful, copy C<<
769req->errorno >> to C<< grp->errorno >> and set C<< grp->errorno >> to 769req->errorno >> to C<< grp->errorno >> and set C<< grp->result >> to
770C<-1> to signal an error. 770C<-1> to signal an error.
771 771
772Otherwise, malloc some memory or so and issue a read request, adding the 772Otherwise, malloc some memory or so and issue a read request, adding the
773read request to the group. 773read request to the group.
774 774
775=item 4) continue issuing requests till finished 775=item 4) continue issuing requests till finished
776 776
777In the real callback, check for errors and possibly continue with 777In the read callback, check for errors and possibly continue with
778C<eio_close> or any other eio request in the same way. 778C<eio_close> or any other eio request in the same way.
779 779
780As soon as no new requests are added the group request will finish. Make 780As soon as no new requests are added, the group request will finish. Make
781sure you I<always> set C<< grp->result >> to some sensible value. 781sure you I<always> set C<< grp->result >> to some sensible value.
782 782
783=back 783=back
784 784
785=head4 REQUEST LIMITING 785=head4 REQUEST LIMITING
787 787
788#TODO 788#TODO
789 789
790void eio_grp_limit (eio_req *grp, int limit); 790void eio_grp_limit (eio_req *grp, int limit);
791 791
792
793=back
794 792
795 793
796=head1 LOW LEVEL REQUEST API 794=head1 LOW LEVEL REQUEST API
797 795
798#TODO 796#TODO
926This symbol governs the stack size for each eio thread. Libeio itself 924This symbol governs the stack size for each eio thread. Libeio itself
927was written to use very little stackspace, but when using C<EIO_CUSTOM> 925was written to use very little stackspace, but when using C<EIO_CUSTOM>
928requests, you might want to increase this. 926requests, you might want to increase this.
929 927
930If this symbol is undefined (the default) then libeio will use its default 928If this symbol is undefined (the default) then libeio will use its default
931stack size (C<sizeof (void *) * 4096> currently). If it is defined, but 929stack size (C<sizeof (void *) * 4096> currently). In all other cases, the
932C<0>, then the default operating system stack size will be used. In all
933other cases, the value must be an expression that evaluates to the desired 930value must be an expression that evaluates to the desired stack size.
934stack size.
935 931
936=back 932=back
937 933
938 934
939=head1 PORTABILITY REQUIREMENTS 935=head1 PORTABILITY REQUIREMENTS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines