… | |
… | |
137 | C<want_poll> you would write a single byte, in C<done_poll> you would try |
137 | C<want_poll> you would write a single byte, in C<done_poll> you would try |
138 | to read that byte, and in the callback for the read end, you would call |
138 | to read that byte, and in the callback for the read end, you would call |
139 | C<eio_poll>. The race is avoided here because the event loop should invoke |
139 | C<eio_poll>. The race is avoided here because the event loop should invoke |
140 | your callback again and again until the byte has been read (as the pipe |
140 | your callback again and again until the byte has been read (as the pipe |
141 | read callback does not read it, only C<done_poll>). |
141 | read callback does not read it, only C<done_poll>). |
142 | |
|
|
143 | =head2 CONFIGURATION |
|
|
144 | |
|
|
145 | The functions in this section can sometimes be useful, but the default |
|
|
146 | configuration will do in most case, so you should skip this section on |
|
|
147 | first reading. |
|
|
148 | |
|
|
149 | =over 4 |
|
|
150 | |
|
|
151 | =item eio_set_max_poll_time (eio_tstamp nseconds) |
|
|
152 | |
|
|
153 | This causes C<eio_poll ()> to return after it has detected that it was |
|
|
154 | running for C<nsecond> seconds or longer (this number can be fractional). |
|
|
155 | |
|
|
156 | This can be used to limit the amount of time spent handling eio requests, |
|
|
157 | for example, in interactive programs, you might want to limit this time to |
|
|
158 | C<0.01> seconds or so. |
|
|
159 | |
|
|
160 | Note that: |
|
|
161 | |
|
|
162 | a) libeio doesn't know how long your request callbacks take, so the time |
|
|
163 | spent in C<eio_poll> is up to one callback invocation longer then this |
|
|
164 | interval. |
|
|
165 | |
|
|
166 | b) this is implemented by calling C<gettimeofday> after each request, |
|
|
167 | which can be costly. |
|
|
168 | |
|
|
169 | c) at least one request will be handled. |
|
|
170 | |
|
|
171 | =item eio_set_max_poll_reqs (unsigned int nreqs) |
|
|
172 | |
|
|
173 | When C<nreqs> is non-zero, then C<eio_poll> will not handle more than |
|
|
174 | C<nreqs> requests per invocation. This is a less costly way to limit the |
|
|
175 | amount of work done by C<eio_poll> then setting a time limit. |
|
|
176 | |
|
|
177 | If you know your callbacks are generally fast, you could use this to |
|
|
178 | encourage interactiveness in your programs by setting it to C<10>, C<100> |
|
|
179 | or even C<1000>. |
|
|
180 | |
|
|
181 | =item eio_set_min_parallel (unsigned int nthreads) |
|
|
182 | |
|
|
183 | Make sure libeio can handle at least this many requests in parallel. It |
|
|
184 | might be able handle more. |
|
|
185 | |
|
|
186 | =item eio_set_max_parallel (unsigned int nthreads) |
|
|
187 | |
|
|
188 | Set the maximum number of threads that libeio will spawn. |
|
|
189 | |
|
|
190 | =item eio_set_max_idle (unsigned int nthreads) |
|
|
191 | |
|
|
192 | Libeio uses threads internally to handle most requests, and will start and stop threads on demand. |
|
|
193 | |
|
|
194 | This call can be used to limit the number of idle threads (threads without |
|
|
195 | work to do): libeio will keep some threads idle in preparation for more |
|
|
196 | requests, but never longer than C<nthreads> threads. |
|
|
197 | |
|
|
198 | In addition to this, libeio will also stop threads when they are idle for |
|
|
199 | a few seconds, regardless of this setting. |
|
|
200 | |
|
|
201 | =item unsigned int eio_nthreads () |
|
|
202 | |
|
|
203 | Return the number of worker threads currently running. |
|
|
204 | |
|
|
205 | =item unsigned int eio_nreqs () |
|
|
206 | |
|
|
207 | Return the number of requests currently handled by libeio. This is the |
|
|
208 | total number of requests that have been submitted to libeio, but not yet |
|
|
209 | destroyed. |
|
|
210 | |
|
|
211 | =item unsigned int eio_nready () |
|
|
212 | |
|
|
213 | Returns the number of ready requests, i.e. requests that have been |
|
|
214 | submitted but have not yet entered the execution phase. |
|
|
215 | |
|
|
216 | =item unsigned int eio_npending () |
|
|
217 | |
|
|
218 | Returns the number of pending requests, i.e. requests that have been |
|
|
219 | executed and have results, but have not been finished yet by a call to |
|
|
220 | C<eio_poll>). |
|
|
221 | |
|
|
222 | =back |
|
|
223 | |
142 | |
224 | |
143 | |
225 | =head1 HIGH LEVEL REQUEST API |
144 | =head1 HIGH LEVEL REQUEST API |
226 | |
145 | |
227 | Libeio has both a high-level API, which consists of calling a request |
146 | Libeio has both a high-level API, which consists of calling a request |
… | |
… | |
660 | |
579 | |
661 | zero |
580 | zero |
662 | |
581 | |
663 | #TODO |
582 | #TODO |
664 | |
583 | |
|
|
584 | =head2 CONFIGURATION |
|
|
585 | |
|
|
586 | The functions in this section can sometimes be useful, but the default |
|
|
587 | configuration will do in most case, so you should skip this section on |
|
|
588 | first reading. |
|
|
589 | |
|
|
590 | =over 4 |
|
|
591 | |
|
|
592 | =item eio_set_max_poll_time (eio_tstamp nseconds) |
|
|
593 | |
|
|
594 | This causes C<eio_poll ()> to return after it has detected that it was |
|
|
595 | running for C<nsecond> seconds or longer (this number can be fractional). |
|
|
596 | |
|
|
597 | This can be used to limit the amount of time spent handling eio requests, |
|
|
598 | for example, in interactive programs, you might want to limit this time to |
|
|
599 | C<0.01> seconds or so. |
|
|
600 | |
|
|
601 | Note that: |
|
|
602 | |
|
|
603 | a) libeio doesn't know how long your request callbacks take, so the time |
|
|
604 | spent in C<eio_poll> is up to one callback invocation longer then this |
|
|
605 | interval. |
|
|
606 | |
|
|
607 | b) this is implemented by calling C<gettimeofday> after each request, |
|
|
608 | which can be costly. |
|
|
609 | |
|
|
610 | c) at least one request will be handled. |
|
|
611 | |
|
|
612 | =item eio_set_max_poll_reqs (unsigned int nreqs) |
|
|
613 | |
|
|
614 | When C<nreqs> is non-zero, then C<eio_poll> will not handle more than |
|
|
615 | C<nreqs> requests per invocation. This is a less costly way to limit the |
|
|
616 | amount of work done by C<eio_poll> then setting a time limit. |
|
|
617 | |
|
|
618 | If you know your callbacks are generally fast, you could use this to |
|
|
619 | encourage interactiveness in your programs by setting it to C<10>, C<100> |
|
|
620 | or even C<1000>. |
|
|
621 | |
|
|
622 | =item eio_set_min_parallel (unsigned int nthreads) |
|
|
623 | |
|
|
624 | Make sure libeio can handle at least this many requests in parallel. It |
|
|
625 | might be able handle more. |
|
|
626 | |
|
|
627 | =item eio_set_max_parallel (unsigned int nthreads) |
|
|
628 | |
|
|
629 | Set the maximum number of threads that libeio will spawn. |
|
|
630 | |
|
|
631 | =item eio_set_max_idle (unsigned int nthreads) |
|
|
632 | |
|
|
633 | Libeio uses threads internally to handle most requests, and will start and stop threads on demand. |
|
|
634 | |
|
|
635 | This call can be used to limit the number of idle threads (threads without |
|
|
636 | work to do): libeio will keep some threads idle in preparation for more |
|
|
637 | requests, but never longer than C<nthreads> threads. |
|
|
638 | |
|
|
639 | In addition to this, libeio will also stop threads when they are idle for |
|
|
640 | a few seconds, regardless of this setting. |
|
|
641 | |
|
|
642 | =item unsigned int eio_nthreads () |
|
|
643 | |
|
|
644 | Return the number of worker threads currently running. |
|
|
645 | |
|
|
646 | =item unsigned int eio_nreqs () |
|
|
647 | |
|
|
648 | Return the number of requests currently handled by libeio. This is the |
|
|
649 | total number of requests that have been submitted to libeio, but not yet |
|
|
650 | destroyed. |
|
|
651 | |
|
|
652 | =item unsigned int eio_nready () |
|
|
653 | |
|
|
654 | Returns the number of ready requests, i.e. requests that have been |
|
|
655 | submitted but have not yet entered the execution phase. |
|
|
656 | |
|
|
657 | =item unsigned int eio_npending () |
|
|
658 | |
|
|
659 | Returns the number of pending requests, i.e. requests that have been |
|
|
660 | executed and have results, but have not been finished yet by a call to |
|
|
661 | C<eio_poll>). |
|
|
662 | |
|
|
663 | =back |
|
|
664 | |
665 | =head1 EMBEDDING |
665 | =head1 EMBEDDING |
666 | |
666 | |
667 | Libeio can be embedded directly into programs. This functionality is not |
667 | Libeio can be embedded directly into programs. This functionality is not |
668 | documented and not (yet) officially supported. |
668 | documented and not (yet) officially supported. |
669 | |
669 | |