… | |
… | |
5 | #include <sys/types.h> |
5 | #include <sys/types.h> |
6 | #include <unistd.h> |
6 | #include <unistd.h> |
7 | #include <fcntl.h> |
7 | #include <fcntl.h> |
8 | #include <signal.h> |
8 | #include <signal.h> |
9 | #include <sched.h> |
9 | #include <sched.h> |
|
|
10 | |
|
|
11 | typedef void *InOutStream; /* hack, but 5.6.1 is simply toooo old ;) */ |
10 | |
12 | |
11 | #define STACKSIZE 1024 /* yeah */ |
13 | #define STACKSIZE 1024 /* yeah */ |
12 | |
14 | |
13 | enum { REQ_QUIT, REQ_READ, REQ_WRITE, REQ_OPEN, REQ_CLOSE }; |
15 | enum { REQ_QUIT, REQ_READ, REQ_WRITE, REQ_OPEN, REQ_CLOSE }; |
14 | |
16 | |
… | |
… | |
257 | |
259 | |
258 | poll_cb (); |
260 | poll_cb (); |
259 | while (started > nthreads) |
261 | while (started > nthreads) |
260 | { |
262 | { |
261 | sched_yield (); |
263 | sched_yield (); |
|
|
264 | fcntl (respipe[0], F_SETFL, 0); |
262 | poll_cb (); |
265 | poll_cb (); |
|
|
266 | fcntl (respipe[0], F_SETFL, O_NONBLOCK); |
263 | } |
267 | } |
264 | |
268 | |
265 | void |
269 | void |
266 | aio_read(fh,offset,length,data,dataoffset,callback) |
270 | aio_read(fh,offset,length,data,dataoffset,callback) |
267 | PerlIO * fh |
271 | InOutStream fh |
268 | UV offset |
272 | UV offset |
269 | STRLEN length |
273 | IV length |
270 | SV * data |
274 | SV * data |
271 | STRLEN dataoffset |
275 | IV dataoffset |
272 | SV * callback |
276 | SV * callback |
273 | PROTOTYPE: $$$$$$ |
277 | PROTOTYPE: $$$$$$ |
274 | ALIAS: |
278 | ALIAS: |
275 | aio_write = 1 |
279 | aio_write = 1 |
276 | CODE: |
280 | CODE: |
… | |
… | |
301 | |
305 | |
302 | send_req (req); |
306 | send_req (req); |
303 | |
307 | |
304 | void |
308 | void |
305 | aio_close(fh,callback) |
309 | aio_close(fh,callback) |
306 | PerlIO * fh |
310 | InOutStream fh |
307 | SV * callback |
311 | SV * callback |
308 | PROTOTYPE: $ |
312 | PROTOTYPE: $ |
309 | CODE: |
313 | CODE: |
310 | aio_req req; |
314 | aio_req req; |
311 | |
315 | |