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