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

Comparing libeio/eio.pod (file contents):
Revision 1.22 by root, Fri Jul 8 01:12:39 2011 UTC vs.
Revision 1.23 by root, Wed Jul 13 21:31:40 2011 UTC

687 687
688=over 4 688=over 4
689 689
690=item eio_req *grp = eio_grp (eio_cb cb, void *data) 690=item eio_req *grp = eio_grp (eio_cb cb, void *data)
691 691
692Creates, submits and returns a group request. 692Creates, submits and returns a group request. Note that it doesn't have a
693priority, unlike all other requests.
693 694
694=item eio_grp_add (eio_req *grp, eio_req *req) 695=item eio_grp_add (eio_req *grp, eio_req *req)
695 696
696Adds a request to the request group. 697Adds a request to the request group.
697 698
698=item eio_grp_cancel (eio_req *grp) 699=item eio_grp_cancel (eio_req *grp)
699 700
700Cancels all requests I<in> the group, but I<not> the group request 701Cancels all requests I<in> the group, but I<not> the group request
701itself. You can cancel the group request via a normal C<eio_cancel> call. 702itself. You can cancel the group request I<and> all subrequests via a
703normal C<eio_cancel> call.
702 704
703
704
705=back 705=back
706 706
707=head4 GROUP REQUEST LIFETIME
708
709Left alone, a group request will instantly move to the pending state and
710will be finished at the next call of C<eio_poll>.
711
712There usefulness stems from the fact that, if a subrequest is added to a
713group I<before> a call to C<eio_poll>, via C<eio_grp_add>, then the group
714will not finish until all the subrequests have finished.
715
716So the usage cycle of a group request is like this: after it is created,
717you normally instantly add a subrequest. If none is added, the group
718request will finish on it's own. As long as subrequests are added before
719the group request is finished it will be kept from finishing, that is the
720callbacks of any subrequests can, in turn, add more requests to the group,
721and as long as any requests are active, the group request itself will not
722finish.
723
724=head4 CREATING COMPOSITE REQUESTS
725
726Imagine you wanted to create an C<eio_load> request that opens a file,
727reads it and closes it. This means it has to execute at least three eio
728requests, but for various reasons it might be nice if that request looked
729like any other eio request.
730
731This can be done with groups:
732
733=over 4
734
735=item 1) create the request object
736
737Create a group that contains all further requests. This is the request you
738can return as "the load request".
739
740=item 2) open the file, maybe
741
742Next, open the file with C<eio_open> and add the request to the group
743request and you are finished steting up the request.
744
745If, for some reason, you cannot C<eio_open> (path is a null ptr?) you
746cna set C<< grp->result >> to C<-1> to signal an error and let the gorup
747request finish on its own.
748
749=item 3) open callback adds more requests
750
751In the open callback, if the open was not successful, copy C<<
752req->errorno >> to C<< grp->errorno >> and set C<< grp->errorno >> to
753C<-1> to signal an error.
754
755Otherwise, malloc some memory or so and issue a read request, adding the
756read request to the group.
757
758=item 4) continue issuign requests till finished
759
760In the real callback, check for errors and possibly continue with
761C<eio_close> or any other eio request in the same way.
762
763As soon as no new requests are added the group request will finish. Make
764sure you I<always> set C<< grp->result >> to some sensible value.
765
766=back
767
768=head4 REQUEST LIMITING
707 769
708 770
709#TODO 771#TODO
710 772
711/*****************************************************************************/
712/* groups */
713
714eio_req *eio_grp (eio_cb cb, void *data);
715void eio_grp_feed (eio_req *grp, void (*feed)(eio_req *req), int limit);
716void eio_grp_limit (eio_req *grp, int limit); 773void eio_grp_limit (eio_req *grp, int limit);
717void eio_grp_cancel (eio_req *grp); /* cancels all sub requests but not the group */
718 774
719 775
720=back 776=back
721 777
722 778

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines