… | |
… | |
2 | IO::AIO - Asynchronous Input/Output |
2 | IO::AIO - Asynchronous Input/Output |
3 | |
3 | |
4 | SYNOPSIS |
4 | SYNOPSIS |
5 | use IO::AIO; |
5 | use IO::AIO; |
6 | |
6 | |
7 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
7 | aio_open "/etc/passwd", IO::AIO::O_RDONLY, 0, sub { |
8 | my $fh = shift |
8 | my $fh = shift |
9 | or die "/etc/passwd: $!"; |
9 | or die "/etc/passwd: $!"; |
10 | ... |
10 | ... |
11 | }; |
11 | }; |
12 | |
12 | |
… | |
… | |
72 | |
72 | |
73 | # register the IO::AIO callback with EV |
73 | # register the IO::AIO callback with EV |
74 | my $aio_w = EV::io IO::AIO::poll_fileno, EV::READ, \&IO::AIO::poll_cb; |
74 | my $aio_w = EV::io IO::AIO::poll_fileno, EV::READ, \&IO::AIO::poll_cb; |
75 | |
75 | |
76 | # queue the request to open /etc/passwd |
76 | # queue the request to open /etc/passwd |
77 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
77 | aio_open "/etc/passwd", IO::AIO::O_RDONLY, 0, sub { |
78 | my $fh = shift |
78 | my $fh = shift |
79 | or die "error while opening: $!"; |
79 | or die "error while opening: $!"; |
80 | |
80 | |
81 | # stat'ing filehandles is generally non-blocking |
81 | # stat'ing filehandles is generally non-blocking |
82 | my $size = -s $fh; |
82 | my $size = -s $fh; |
… | |
… | |
187 | aio_fdatasync $fh, $callback->($status) |
187 | aio_fdatasync $fh, $callback->($status) |
188 | aio_sync_file_range $fh, $offset, $nbytes, $flags, $callback->($status) |
188 | aio_sync_file_range $fh, $offset, $nbytes, $flags, $callback->($status) |
189 | aio_pathsync $path, $callback->($status) |
189 | aio_pathsync $path, $callback->($status) |
190 | aio_msync $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
190 | aio_msync $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
191 | aio_mtouch $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
191 | aio_mtouch $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
|
|
192 | aio_mlock $scalar, $offset = 0, $length = undef, $callback->($status) |
|
|
193 | aio_mlockall $flags, $callback->($status) |
192 | aio_group $callback->(...) |
194 | aio_group $callback->(...) |
193 | aio_nop $callback->() |
195 | aio_nop $callback->() |
194 | |
196 | |
195 | $prev_pri = aioreq_pri [$pri] |
197 | $prev_pri = aioreq_pri [$pri] |
196 | aioreq_nice $pri_adjust |
198 | aioreq_nice $pri_adjust |
… | |
… | |
202 | IO::AIO::max_poll_reqs $nreqs |
204 | IO::AIO::max_poll_reqs $nreqs |
203 | IO::AIO::max_poll_time $seconds |
205 | IO::AIO::max_poll_time $seconds |
204 | IO::AIO::min_parallel $nthreads |
206 | IO::AIO::min_parallel $nthreads |
205 | IO::AIO::max_parallel $nthreads |
207 | IO::AIO::max_parallel $nthreads |
206 | IO::AIO::max_idle $nthreads |
208 | IO::AIO::max_idle $nthreads |
|
|
209 | IO::AIO::idle_timeout $seconds |
207 | IO::AIO::max_outstanding $maxreqs |
210 | IO::AIO::max_outstanding $maxreqs |
208 | IO::AIO::nreqs |
211 | IO::AIO::nreqs |
209 | IO::AIO::nready |
212 | IO::AIO::nready |
210 | IO::AIO::npending |
213 | IO::AIO::npending |
211 | |
214 | |
212 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
215 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
213 | IO::AIO::fadvise $fh, $offset, $len, $advice |
216 | IO::AIO::fadvise $fh, $offset, $len, $advice |
214 | IO::AIO::mlockall $flags |
217 | IO::AIO::madvise $scalar, $offset, $length, $advice |
|
|
218 | IO::AIO::mprotect $scalar, $offset, $length, $protect |
|
|
219 | IO::AIO::munlock $scalar, $offset = 0, $length = undef |
215 | IO::AIO::munlockall |
220 | IO::AIO::munlockall |
216 | |
221 | |
217 | AIO REQUEST FUNCTIONS |
222 | AIO REQUEST FUNCTIONS |
218 | All the "aio_*" calls are more or less thin wrappers around the syscall |
223 | All the "aio_*" calls are more or less thin wrappers around the syscall |
219 | with the same name (sans "aio_"). The arguments are similar or |
224 | with the same name (sans "aio_"). The arguments are similar or |
… | |
… | |
292 | will be modified by the umask in effect then the request is being |
297 | will be modified by the umask in effect then the request is being |
293 | executed, so better never change the umask. |
298 | executed, so better never change the umask. |
294 | |
299 | |
295 | Example: |
300 | Example: |
296 | |
301 | |
297 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
302 | aio_open "/etc/passwd", IO::AIO::O_RDONLY, 0, sub { |
298 | if ($_[0]) { |
303 | if ($_[0]) { |
299 | print "open successful, fh is $_[0]\n"; |
304 | print "open successful, fh is $_[0]\n"; |
300 | ... |
305 | ... |
301 | } else { |
306 | } else { |
302 | die "open failed: $!\n"; |
307 | die "open failed: $!\n"; |
303 | } |
308 | } |
304 | }; |
309 | }; |
305 | |
310 | |
|
|
311 | In addition to all the common open modes/flags ("O_RDONLY", |
|
|
312 | "O_WRONLY", "O_RDWR", "O_CREAT", "O_TRUNC", "O_EXCL" and |
|
|
313 | "O_APPEND"), the following POSIX and non-POSIX constants are |
|
|
314 | available (missing ones on your system are, as usual, 0): |
|
|
315 | |
|
|
316 | "O_ASYNC", "O_DIRECT", "O_NOATIME", "O_CLOEXEC", "O_NOCTTY", |
|
|
317 | "O_NOFOLLOW", "O_NONBLOCK", "O_EXEC", "O_SEARCH", "O_DIRECTORY", |
|
|
318 | "O_DSYNC", "O_RSYNC", "O_SYNC" and "O_TTY_INIT". |
|
|
319 | |
306 | aio_close $fh, $callback->($status) |
320 | aio_close $fh, $callback->($status) |
307 | Asynchronously close a file and call the callback with the result |
321 | Asynchronously close a file and call the callback with the result |
308 | code. |
322 | code. |
309 | |
323 | |
310 | Unfortunately, you can't do this to perl. Perl *insists* very |
324 | Unfortunately, you can't do this to perl. Perl *insists* very |
… | |
… | |
355 | reading at byte offset $in_offset, and starts writing at the current |
369 | reading at byte offset $in_offset, and starts writing at the current |
356 | file offset of $out_fh. Because of that, it is not safe to issue |
370 | file offset of $out_fh. Because of that, it is not safe to issue |
357 | more than one "aio_sendfile" per $out_fh, as they will interfere |
371 | more than one "aio_sendfile" per $out_fh, as they will interfere |
358 | with each other. |
372 | with each other. |
359 | |
373 | |
|
|
374 | Please note that "aio_sendfile" can read more bytes from $in_fh than |
|
|
375 | are written, and there is no way to find out how many bytes have |
|
|
376 | been read from "aio_sendfile" alone, as "aio_sendfile" only provides |
|
|
377 | the number of bytes written to $out_fh. Only if the result value |
|
|
378 | equals $length one can assume that $length bytes have been read. |
|
|
379 | |
|
|
380 | Unlike with other "aio_" functions, it makes a lot of sense to use |
|
|
381 | "aio_sendfile" on non-blocking sockets, as long as one end |
|
|
382 | (typically the $in_fh) is a file - the file I/O will then be |
|
|
383 | asynchronous, while the socket I/O will be non-blocking. Note, |
|
|
384 | however, that you can run into a trap where "aio_sendfile" reads |
|
|
385 | some data with readahead, then fails to write all data, and when the |
|
|
386 | socket is ready the next time, the data in the cache is already |
|
|
387 | lost, forcing "aio_sendfile" to again hit the disk. Explicit |
|
|
388 | "aio_read" + "aio_write" let's you control resource usage much |
|
|
389 | better. |
|
|
390 | |
360 | This call tries to make use of a native "sendfile" syscall to |
391 | This call tries to make use of a native "sendfile" syscall to |
361 | provide zero-copy operation. For this to work, $out_fh should refer |
392 | provide zero-copy operation. For this to work, $out_fh should refer |
362 | to a socket, and $in_fh should refer to an mmap'able file. |
393 | to a socket, and $in_fh should refer to an mmap'able file. |
363 | |
394 | |
364 | If a native sendfile cannot be found or it fails with "ENOSYS", |
395 | If a native sendfile cannot be found or it fails with "ENOSYS", |
365 | "ENOTSUP", "EOPNOTSUPP", "EAFNOSUPPORT", "EPROTOTYPE" or "ENOTSOCK", |
396 | "ENOTSUP", "EOPNOTSUPP", "EAFNOSUPPORT", "EPROTOTYPE" or "ENOTSOCK", |
366 | it will be emulated, so you can call "aio_sendfile" on any type of |
397 | it will be emulated, so you can call "aio_sendfile" on any type of |
367 | filehandle regardless of the limitations of the operating system. |
398 | filehandle regardless of the limitations of the operating system. |
368 | |
|
|
369 | Please note, however, that "aio_sendfile" can read more bytes from |
|
|
370 | $in_fh than are written, and there is no way to find out how many |
|
|
371 | bytes have been read from "aio_sendfile" alone, as "aio_sendfile" |
|
|
372 | only provides the number of bytes written to $out_fh. Only if the |
|
|
373 | result value equals $length one can assume that $length bytes have |
|
|
374 | been read. |
|
|
375 | |
399 | |
376 | aio_readahead $fh,$offset,$length, $callback->($retval) |
400 | aio_readahead $fh,$offset,$length, $callback->($retval) |
377 | "aio_readahead" populates the page cache with data from a file so |
401 | "aio_readahead" populates the page cache with data from a file so |
378 | that subsequent reads from that file will not block on disk I/O. The |
402 | that subsequent reads from that file will not block on disk I/O. The |
379 | $offset argument specifies the starting point from which data is to |
403 | $offset argument specifies the starting point from which data is to |
… | |
… | |
399 | |
423 | |
400 | Currently, the stats are always 64-bit-stats, i.e. instead of |
424 | Currently, the stats are always 64-bit-stats, i.e. instead of |
401 | returning an error when stat'ing a large file, the results will be |
425 | returning an error when stat'ing a large file, the results will be |
402 | silently truncated unless perl itself is compiled with large file |
426 | silently truncated unless perl itself is compiled with large file |
403 | support. |
427 | support. |
|
|
428 | |
|
|
429 | To help interpret the mode and dev/rdev stat values, IO::AIO offers |
|
|
430 | the following constants and functions (if not implemented, the |
|
|
431 | constants will be 0 and the functions will either "croak" or fall |
|
|
432 | back on traditional behaviour). |
|
|
433 | |
|
|
434 | "S_IFMT", "S_IFIFO", "S_IFCHR", "S_IFBLK", "S_IFLNK", "S_IFREG", |
|
|
435 | "S_IFDIR", "S_IFWHT", "S_IFSOCK", "IO::AIO::major $dev_t", |
|
|
436 | "IO::AIO::minor $dev_t", "IO::AIO::makedev $major, $minor". |
404 | |
437 | |
405 | Example: Print the length of /etc/passwd: |
438 | Example: Print the length of /etc/passwd: |
406 | |
439 | |
407 | aio_stat "/etc/passwd", sub { |
440 | aio_stat "/etc/passwd", sub { |
408 | $_[0] and die "stat failed: $!"; |
441 | $_[0] and die "stat failed: $!"; |
… | |
… | |
497 | |
530 | |
498 | The only (POSIX-) portable way of calling this function is: |
531 | The only (POSIX-) portable way of calling this function is: |
499 | |
532 | |
500 | aio_mknod $path, IO::AIO::S_IFIFO | $mode, 0, sub { ... |
533 | aio_mknod $path, IO::AIO::S_IFIFO | $mode, 0, sub { ... |
501 | |
534 | |
|
|
535 | See "aio_stat" for info about some potentially helpful extra |
|
|
536 | constants and functions. |
|
|
537 | |
502 | aio_link $srcpath, $dstpath, $callback->($status) |
538 | aio_link $srcpath, $dstpath, $callback->($status) |
503 | Asynchronously create a new link to the existing object at $srcpath |
539 | Asynchronously create a new link to the existing object at $srcpath |
504 | at the path $dstpath and call the callback with the result code. |
540 | at the path $dstpath and call the callback with the result code. |
505 | |
541 | |
506 | aio_symlink $srcpath, $dstpath, $callback->($status) |
542 | aio_symlink $srcpath, $dstpath, $callback->($status) |
… | |
… | |
542 | The flags are a combination of the following constants, ORed |
578 | The flags are a combination of the following constants, ORed |
543 | together (the flags will also be passed to the callback, possibly |
579 | together (the flags will also be passed to the callback, possibly |
544 | modified): |
580 | modified): |
545 | |
581 | |
546 | IO::AIO::READDIR_DENTS |
582 | IO::AIO::READDIR_DENTS |
547 | When this flag is off, then the callback gets an arrayref with |
583 | When this flag is off, then the callback gets an arrayref |
548 | of names only (as with "aio_readdir"), otherwise it gets an |
584 | consisting of names only (as with "aio_readdir"), otherwise it |
549 | arrayref with "[$name, $type, $inode]" arrayrefs, each |
585 | gets an arrayref with "[$name, $type, $inode]" arrayrefs, each |
550 | describing a single directory entry in more detail. |
586 | describing a single directory entry in more detail. |
551 | |
587 | |
552 | $name is the name of the entry. |
588 | $name is the name of the entry. |
553 | |
589 | |
554 | $type is one of the "IO::AIO::DT_xxx" constants: |
590 | $type is one of the "IO::AIO::DT_xxx" constants: |
… | |
… | |
567 | unspecified content on systems that do not deliver the inode |
603 | unspecified content on systems that do not deliver the inode |
568 | information. |
604 | information. |
569 | |
605 | |
570 | IO::AIO::READDIR_DIRS_FIRST |
606 | IO::AIO::READDIR_DIRS_FIRST |
571 | When this flag is set, then the names will be returned in an |
607 | When this flag is set, then the names will be returned in an |
572 | order where likely directories come first. This is useful when |
608 | order where likely directories come first, in optimal stat |
573 | you need to quickly find directories, or you want to find all |
609 | order. This is useful when you need to quickly find directories, |
574 | directories while avoiding to stat() each entry. |
610 | or you want to find all directories while avoiding to stat() |
|
|
611 | each entry. |
575 | |
612 | |
576 | If the system returns type information in readdir, then this is |
613 | If the system returns type information in readdir, then this is |
577 | used to find directories directly. Otherwise, likely directories |
614 | used to find directories directly. Otherwise, likely directories |
578 | are files beginning with ".", or otherwise files with no dots, |
615 | are names beginning with ".", or otherwise names with no dots, |
579 | of which files with short names are tried first. |
616 | of which names with short names are tried first. |
580 | |
617 | |
581 | IO::AIO::READDIR_STAT_ORDER |
618 | IO::AIO::READDIR_STAT_ORDER |
582 | When this flag is set, then the names will be returned in an |
619 | When this flag is set, then the names will be returned in an |
583 | order suitable for stat()'ing each one. That is, when you plan |
620 | order suitable for stat()'ing each one. That is, when you plan |
584 | to stat() all files in the given directory, then the returned |
621 | to stat() all files in the given directory, then the returned |
… | |
… | |
751 | "aio_msync", above, except for flags, which must be either 0 (which |
788 | "aio_msync", above, except for flags, which must be either 0 (which |
752 | reads all pages and ensures they are instantiated) or |
789 | reads all pages and ensures they are instantiated) or |
753 | "IO::AIO::MT_MODIFY", which modifies the memory page s(by reading |
790 | "IO::AIO::MT_MODIFY", which modifies the memory page s(by reading |
754 | and writing an octet from it, which dirties the page). |
791 | and writing an octet from it, which dirties the page). |
755 | |
792 | |
|
|
793 | aio_mlock $scalar, $offset = 0, $length = undef, $callback->($status) |
|
|
794 | This is a rather advanced IO::AIO call, which works best on |
|
|
795 | mmap(2)ed scalars. |
|
|
796 | |
|
|
797 | It reads in all the pages of the underlying storage into memory (if |
|
|
798 | any) and locks them, so they are not getting swapped/paged out or |
|
|
799 | removed. |
|
|
800 | |
|
|
801 | If $length is undefined, then the scalar will be locked till the |
|
|
802 | end. |
|
|
803 | |
|
|
804 | On systems that do not implement "mlock", this function returns -1 |
|
|
805 | and sets errno to "ENOSYS". |
|
|
806 | |
|
|
807 | Note that the corresponding "munlock" is synchronous and is |
|
|
808 | documented under "MISCELLANEOUS FUNCTIONS". |
|
|
809 | |
|
|
810 | Example: open a file, mmap and mlock it - both will be undone when |
|
|
811 | $data gets destroyed. |
|
|
812 | |
|
|
813 | open my $fh, "<", $path or die "$path: $!"; |
|
|
814 | my $data; |
|
|
815 | IO::AIO::mmap $data, -s $fh, IO::AIO::PROT_READ, IO::AIO::MAP_SHARED, $fh; |
|
|
816 | aio_mlock $data; # mlock in background |
|
|
817 | |
|
|
818 | aio_mlockall $flags, $callback->($status) |
|
|
819 | Calls the "mlockall" function with the given $flags (a combination |
|
|
820 | of "IO::AIO::MCL_CURRENT" and "IO::AIO::MCL_FUTURE"). |
|
|
821 | |
|
|
822 | On systems that do not implement "mlockall", this function returns |
|
|
823 | -1 and sets errno to "ENOSYS". |
|
|
824 | |
|
|
825 | Note that the corresponding "munlockall" is synchronous and is |
|
|
826 | documented under "MISCELLANEOUS FUNCTIONS". |
|
|
827 | |
|
|
828 | Example: asynchronously lock all current and future pages into |
|
|
829 | memory. |
|
|
830 | |
|
|
831 | aio_mlockall IO::AIO::MCL_FUTURE; |
|
|
832 | |
756 | aio_group $callback->(...) |
833 | aio_group $callback->(...) |
757 | This is a very special aio request: Instead of doing something, it |
834 | This is a very special aio request: Instead of doing something, it |
758 | is a container for other aio requests, which is useful if you want |
835 | is a container for other aio requests, which is useful if you want |
759 | to bundle many requests into a single, composite, request with a |
836 | to bundle many requests into a single, composite, request with a |
760 | definite callback and the ability to cancel the whole request with |
837 | definite callback and the ability to cancel the whole request with |
… | |
… | |
955 | |
1032 | |
956 | See "poll_cb" for an example. |
1033 | See "poll_cb" for an example. |
957 | |
1034 | |
958 | IO::AIO::poll_cb |
1035 | IO::AIO::poll_cb |
959 | Process some outstanding events on the result pipe. You have to call |
1036 | Process some outstanding events on the result pipe. You have to call |
960 | this regularly. Returns 0 if all events could be processed, or -1 if |
1037 | this regularly. Returns 0 if all events could be processed (or there |
961 | it returned earlier for whatever reason. Returns immediately when no |
1038 | were no events to process), or -1 if it returned earlier for |
962 | events are outstanding. The amount of events processed depends on |
1039 | whatever reason. Returns immediately when no events are outstanding. |
963 | the settings of "IO::AIO::max_poll_req" and |
1040 | The amount of events processed depends on the settings of |
964 | "IO::AIO::max_poll_time". |
1041 | "IO::AIO::max_poll_req" and "IO::AIO::max_poll_time". |
965 | |
1042 | |
966 | If not all requests were processed for whatever reason, the |
1043 | If not all requests were processed for whatever reason, the |
967 | filehandle will still be ready when "poll_cb" returns, so normally |
1044 | filehandle will still be ready when "poll_cb" returns, so normally |
968 | you don't have to do anything special to have it called later. |
1045 | you don't have to do anything special to have it called later. |
|
|
1046 | |
|
|
1047 | Apart from calling "IO::AIO::poll_cb" when the event filehandle |
|
|
1048 | becomes ready, it can be beneficial to call this function from loops |
|
|
1049 | which submit a lot of requests, to make sure the results get |
|
|
1050 | processed when they become available and not just when the loop is |
|
|
1051 | finished and the event loop takes over again. This function returns |
|
|
1052 | very fast when there are no outstanding requests. |
969 | |
1053 | |
970 | Example: Install an Event watcher that automatically calls |
1054 | Example: Install an Event watcher that automatically calls |
971 | IO::AIO::poll_cb with high priority (more examples can be found in |
1055 | IO::AIO::poll_cb with high priority (more examples can be found in |
972 | the SYNOPSIS section, at the top of this document): |
1056 | the SYNOPSIS section, at the top of this document): |
973 | |
1057 | |
… | |
… | |
1067 | |
1151 | |
1068 | Under normal circumstances you don't need to call this function. |
1152 | Under normal circumstances you don't need to call this function. |
1069 | |
1153 | |
1070 | IO::AIO::max_idle $nthreads |
1154 | IO::AIO::max_idle $nthreads |
1071 | Limit the number of threads (default: 4) that are allowed to idle |
1155 | Limit the number of threads (default: 4) that are allowed to idle |
1072 | (i.e., threads that did not get a request to process within 10 |
1156 | (i.e., threads that did not get a request to process within the idle |
1073 | seconds). That means if a thread becomes idle while $nthreads other |
1157 | timeout (default: 10 seconds). That means if a thread becomes idle |
1074 | threads are also idle, it will free its resources and exit. |
1158 | while $nthreads other threads are also idle, it will free its |
|
|
1159 | resources and exit. |
1075 | |
1160 | |
1076 | This is useful when you allow a large number of threads (e.g. 100 or |
1161 | This is useful when you allow a large number of threads (e.g. 100 or |
1077 | 1000) to allow for extremely high load situations, but want to free |
1162 | 1000) to allow for extremely high load situations, but want to free |
1078 | resources under normal circumstances (1000 threads can easily |
1163 | resources under normal circumstances (1000 threads can easily |
1079 | consume 30MB of RAM). |
1164 | consume 30MB of RAM). |
1080 | |
1165 | |
1081 | The default is probably ok in most situations, especially if thread |
1166 | The default is probably ok in most situations, especially if thread |
1082 | creation is fast. If thread creation is very slow on your system you |
1167 | creation is fast. If thread creation is very slow on your system you |
1083 | might want to use larger values. |
1168 | might want to use larger values. |
|
|
1169 | |
|
|
1170 | IO::AIO::idle_timeout $seconds |
|
|
1171 | Sets the minimum idle timeout (default 10) after which worker |
|
|
1172 | threads are allowed to exit. SEe "IO::AIO::max_idle". |
1084 | |
1173 | |
1085 | IO::AIO::max_outstanding $maxreqs |
1174 | IO::AIO::max_outstanding $maxreqs |
1086 | This is a very bad function to use in interactive programs because |
1175 | This is a very bad function to use in interactive programs because |
1087 | it blocks, and a bad way to reduce concurrency because it is |
1176 | it blocks, and a bad way to reduce concurrency because it is |
1088 | inexact: Better use an "aio_group" together with a feed callback. |
1177 | inexact: Better use an "aio_group" together with a feed callback. |
… | |
… | |
1130 | set to non-blocking operations). |
1219 | set to non-blocking operations). |
1131 | |
1220 | |
1132 | Returns the number of bytes copied, or -1 on error. |
1221 | Returns the number of bytes copied, or -1 on error. |
1133 | |
1222 | |
1134 | IO::AIO::fadvise $fh, $offset, $len, $advice |
1223 | IO::AIO::fadvise $fh, $offset, $len, $advice |
1135 | Simply calls the "posix_fadvise" function (see it's manpage for |
1224 | Simply calls the "posix_fadvise" function (see its manpage for |
1136 | details). The following advice constants are avaiable: |
1225 | details). The following advice constants are avaiable: |
1137 | "IO::AIO::FADV_NORMAL", "IO::AIO::FADV_SEQUENTIAL", |
1226 | "IO::AIO::FADV_NORMAL", "IO::AIO::FADV_SEQUENTIAL", |
1138 | "IO::AIO::FADV_RANDOM", "IO::AIO::FADV_NOREUSE", |
1227 | "IO::AIO::FADV_RANDOM", "IO::AIO::FADV_NOREUSE", |
1139 | "IO::AIO::FADV_WILLNEED", "IO::AIO::FADV_DONTNEED". |
1228 | "IO::AIO::FADV_WILLNEED", "IO::AIO::FADV_DONTNEED". |
1140 | |
1229 | |
1141 | On systems that do not implement "posix_fadvise", this function |
1230 | On systems that do not implement "posix_fadvise", this function |
1142 | returns ENOSYS, otherwise the return value of "posix_fadvise". |
1231 | returns ENOSYS, otherwise the return value of "posix_fadvise". |
|
|
1232 | |
|
|
1233 | IO::AIO::madvise $scalar, $offset, $len, $advice |
|
|
1234 | Simply calls the "posix_madvise" function (see its manpage for |
|
|
1235 | details). The following advice constants are avaiable: |
|
|
1236 | "IO::AIO::MADV_NORMAL", "IO::AIO::MADV_SEQUENTIAL", |
|
|
1237 | "IO::AIO::MADV_RANDOM", "IO::AIO::MADV_WILLNEED", |
|
|
1238 | "IO::AIO::MADV_DONTNEED". |
|
|
1239 | |
|
|
1240 | On systems that do not implement "posix_madvise", this function |
|
|
1241 | returns ENOSYS, otherwise the return value of "posix_madvise". |
|
|
1242 | |
|
|
1243 | IO::AIO::mprotect $scalar, $offset, $len, $protect |
|
|
1244 | Simply calls the "mprotect" function on the preferably AIO::mmap'ed |
|
|
1245 | $scalar (see its manpage for details). The following protect |
|
|
1246 | constants are avaiable: "IO::AIO::PROT_NONE", "IO::AIO::PROT_READ", |
|
|
1247 | "IO::AIO::PROT_WRITE", "IO::AIO::PROT_EXEC". |
|
|
1248 | |
|
|
1249 | On systems that do not implement "mprotect", this function returns |
|
|
1250 | ENOSYS, otherwise the return value of "mprotect". |
1143 | |
1251 | |
1144 | IO::AIO::mmap $scalar, $length, $prot, $flags, $fh[, $offset] |
1252 | IO::AIO::mmap $scalar, $length, $prot, $flags, $fh[, $offset] |
1145 | Memory-maps a file (or anonymous memory range) and attaches it to |
1253 | Memory-maps a file (or anonymous memory range) and attaches it to |
1146 | the given $scalar, which will act like a string scalar. |
1254 | the given $scalar, which will act like a string scalar. |
1147 | |
1255 | |
… | |
… | |
1192 | my $fast_md5 = md5 $data; |
1300 | my $fast_md5 = md5 $data; |
1193 | |
1301 | |
1194 | IO::AIO::munmap $scalar |
1302 | IO::AIO::munmap $scalar |
1195 | Removes a previous mmap and undefines the $scalar. |
1303 | Removes a previous mmap and undefines the $scalar. |
1196 | |
1304 | |
1197 | IO::AIO::mlockall $flags |
1305 | IO::AIO::munlock $scalar, $offset = 0, $length = undef |
1198 | Calls the "mlockall" function with the given $flags (a combination |
1306 | Calls the "munlock" function, undoing the effects of a previous |
1199 | of "IO::AIO::MCL_CURRENT" and "IO::AIO::MCL__FUTURE"). |
1307 | "aio_mlock" call (see its description for details). |
1200 | |
|
|
1201 | On systems that do not implement "mlockall", this function returns |
|
|
1202 | ENOSYS, otherwise the return value of "mlockall". |
|
|
1203 | |
1308 | |
1204 | IO::AIO::munlockall |
1309 | IO::AIO::munlockall |
1205 | Calls the "munlockall" function. |
1310 | Calls the "munlockall" function. |
1206 | |
1311 | |
1207 | On systems that do not implement "munlockall", this function returns |
1312 | On systems that do not implement "munlockall", this function returns |