ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.pm
(Generate patch)

Comparing IO-AIO/AIO.pm (file contents):
Revision 1.82 by root, Fri Oct 27 20:10:06 2006 UTC vs.
Revision 1.85 by root, Sat Oct 28 01:40:30 2006 UTC

50 50
51=head1 DESCRIPTION 51=head1 DESCRIPTION
52 52
53This module implements asynchronous I/O using whatever means your 53This module implements asynchronous I/O using whatever means your
54operating system supports. 54operating system supports.
55
56Asynchronous means that operations that can normally block your program
57(e.g. reading from disk) will be done asynchronously: the operation
58will still block, but you can do something else in the meantime. This
59is extremely useful for programs that need to stay interactive even
60when doing heavy I/O (GUI programs, high performance network servers
61etc.), but can also be used to easily do operations in parallel that are
62normally done sequentially, e.g. stat'ing many files, which is much faster
63on a RAID volume or over NFS when you do a number of stat operations
64concurrently.
65
66While this works on all types of file descriptors (for example sockets),
67using these functions on file descriptors that support nonblocking
68operation (again, sockets, pipes etc.) is very inefficient. Use an event
69loop for that (such as the L<Event|Event> module): IO::AIO will naturally
70fit into such an event loop itself.
55 71
56In this version, a number of threads are started that execute your 72In this version, a number of threads are started that execute your
57requests and signal their completion. You don't need thread support 73requests and signal their completion. You don't need thread support
58in perl, and the threads created by this module will not be visible 74in perl, and the threads created by this module will not be visible
59to perl. In the future, this module might make use of the native aio 75to perl. In the future, this module might make use of the native aio
60functions available on many operating systems. However, they are often 76functions available on many operating systems. However, they are often
61not well-supported or restricted (Linux doesn't allow them on normal 77not well-supported or restricted (GNU/Linux doesn't allow them on normal
62files currently, for example), and they would only support aio_read and 78files currently, for example), and they would only support aio_read and
63aio_write, so the remaining functionality would have to be implemented 79aio_write, so the remaining functionality would have to be implemented
64using threads anyway. 80using threads anyway.
65 81
66Although the module will work with in the presence of other (Perl-) 82Although the module will work with in the presence of other (Perl-)
331Asynchronously unlink (delete) a file and call the callback with the 347Asynchronously unlink (delete) a file and call the callback with the
332result code. 348result code.
333 349
334=item aio_mknod $path, $mode, $dev, $callback->($status) 350=item aio_mknod $path, $mode, $dev, $callback->($status)
335 351
336Asynchronously create a device node (or fifo). See mknod(2): the only 352Asynchronously create a device node (or fifo). See mknod(2).
337portable value for C<$mode> is C<S_IFIFO> ored with permissions, and C<0> 353
338for C<$dev>. 354The only portable (POSIX) way of calling this function is:
355
356 aio_mknod $path, IO::AIO::S_IFIFO | $mode, 0, sub { ...
339 357
340=item aio_link $srcpath, $dstpath, $callback->($status) 358=item aio_link $srcpath, $dstpath, $callback->($status)
341 359
342Asynchronously create a new link to the existing object at C<$srcpath> at 360Asynchronously create a new link to the existing object at C<$srcpath> at
343the path C<$dstpath> and call the callback with the result code. 361the path C<$dstpath> and call the callback with the result code.
989} 1007}
990 1008
991min_parallel 8; 1009min_parallel 8;
992 1010
993END { 1011END {
1012 min_parallel 1;
994 flush; 1013 flush;
995}; 1014};
996 1015
9971; 10161;
998 1017

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines