… | |
… | |
16 | Instead, in this module a number of (non-posix) threads are started that |
16 | Instead, in this module a number of (non-posix) threads are started that |
17 | execute your read/writes and signal their completion. You don't need |
17 | execute your read/writes and signal their completion. You don't need |
18 | thread support in your libc or perl, and the threads created by this |
18 | thread support in your libc or perl, and the threads created by this |
19 | module will not be visible to the pthreads library. |
19 | module will not be visible to the pthreads library. |
20 | |
20 | |
|
|
21 | NOTICE: the threads created by this module will automatically be killed |
|
|
22 | when the thread calling min_parallel exits. Make sure you only ever call |
|
|
23 | min_parallel from the same thread that loaded this module. |
|
|
24 | |
21 | Although the module will work with threads, it is not reentrant, so use |
25 | Although the module will work with threads, it is not reentrant, so use |
22 | appropriate locking yourself. |
26 | appropriate locking yourself. |
23 | |
27 | |
24 | =over 4 |
28 | =over 4 |
25 | |
29 | |
… | |
… | |
28 | package Linux::AIO; |
32 | package Linux::AIO; |
29 | |
33 | |
30 | use base 'Exporter'; |
34 | use base 'Exporter'; |
31 | |
35 | |
32 | BEGIN { |
36 | BEGIN { |
33 | $VERSION = 1.1; |
37 | $VERSION = 1.41; |
34 | |
38 | |
35 | @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat); |
39 | @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink); |
36 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); |
40 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); |
37 | |
41 | |
38 | require XSLoader; |
42 | require XSLoader; |
39 | XSLoader::load Linux::AIO, $VERSION; |
43 | XSLoader::load Linux::AIO, $VERSION; |
40 | } |
44 | } |
… | |
… | |
66 | |
70 | |
67 | Event->io (fd => Linux::AIO::poll_fileno, |
71 | Event->io (fd => Linux::AIO::poll_fileno, |
68 | poll => 'r', async => 1, |
72 | poll => 'r', async => 1, |
69 | cb => \&Linux::AIO::poll_cb ); |
73 | cb => \&Linux::AIO::poll_cb ); |
70 | |
74 | |
71 | |
|
|
72 | =item Linux::AIO::nreqs |
75 | =item Linux::AIO::nreqs |
73 | |
76 | |
74 | Returns the number of requests currently outstanding. |
77 | Returns the number of requests currently outstanding. |
75 | |
78 | |
76 | =item aio_open $pathname, $flags, $mode, $callback |
79 | =item aio_open $pathname, $flags, $mode, $callback |
… | |
… | |
101 | |
104 | |
102 | Currently, the stats are always 64-bit-stats, i.e. instead of returning an |
105 | Currently, the stats are always 64-bit-stats, i.e. instead of returning an |
103 | error when stat'ing a large file, the results will be silently truncated |
106 | error when stat'ing a large file, the results will be silently truncated |
104 | unless perl itself is compiled with large file support. |
107 | unless perl itself is compiled with large file support. |
105 | |
108 | |
|
|
109 | =item aio_unlink $pathname, $callback |
|
|
110 | |
|
|
111 | Asynchronously unlink a file. |
|
|
112 | |
106 | =cut |
113 | =cut |
107 | |
114 | |
108 | min_parallel 1; |
115 | min_parallel 1; |
109 | |
116 | |
110 | END { |
117 | END { |
… | |
… | |
126 | |
133 | |
127 | L<Coro>. |
134 | L<Coro>. |
128 | |
135 | |
129 | =head1 AUTHOR |
136 | =head1 AUTHOR |
130 | |
137 | |
131 | Marc Lehmann <pcg@goof.com> |
138 | Marc Lehmann <schmorp@schmorp.de> |
132 | http://www.goof.com/pcg/marc/ |
139 | http://home.schmorp.de/ |
133 | |
140 | |
134 | =cut |
141 | =cut |
135 | |
142 | |