… | |
… | |
148 | |
148 | |
149 | PUSHMARK (SP); |
149 | PUSHMARK (SP); |
150 | XPUSHs (fh); |
150 | XPUSHs (fh); |
151 | } |
151 | } |
152 | |
152 | |
|
|
153 | if (SvOK (req->callback)) |
|
|
154 | { |
153 | PUTBACK; |
155 | PUTBACK; |
154 | call_sv (req->callback, G_VOID | G_EVAL); |
156 | call_sv (req->callback, G_VOID | G_EVAL); |
155 | SPAGAIN; |
157 | SPAGAIN; |
|
|
158 | } |
156 | |
159 | |
157 | if (req->callback) |
160 | if (req->callback) |
158 | SvREFCNT_dec (req->callback); |
161 | SvREFCNT_dec (req->callback); |
159 | |
162 | |
160 | errno = errorno; |
163 | errno = errorno; |
… | |
… | |
361 | return 0; |
364 | return 0; |
362 | } |
365 | } |
363 | |
366 | |
364 | MODULE = IO::AIO PACKAGE = IO::AIO |
367 | MODULE = IO::AIO PACKAGE = IO::AIO |
365 | |
368 | |
|
|
369 | PROTOTYPES: ENABLE |
|
|
370 | |
366 | BOOT: |
371 | BOOT: |
367 | { |
372 | { |
368 | if (pipe (respipe)) |
373 | if (pipe (respipe)) |
369 | croak ("unable to initialize result pipe"); |
374 | croak ("unable to initialize result pipe"); |
370 | |
375 | |
… | |
… | |
410 | CODE: |
415 | CODE: |
411 | RETVAL = max_outstanding; |
416 | RETVAL = max_outstanding; |
412 | max_outstanding = nreqs; |
417 | max_outstanding = nreqs; |
413 | |
418 | |
414 | void |
419 | void |
415 | aio_open(pathname,flags,mode,callback) |
420 | aio_open(pathname,flags,mode,callback=&PL_sv_undef) |
416 | SV * pathname |
421 | SV * pathname |
417 | int flags |
422 | int flags |
418 | int mode |
423 | int mode |
419 | SV * callback |
424 | SV * callback |
420 | PROTOTYPE: $$$$ |
425 | PROTOTYPE: $$$;$ |
421 | CODE: |
426 | CODE: |
422 | { |
427 | { |
423 | aio_req req; |
428 | aio_req req; |
424 | |
429 | |
425 | Newz (0, req, 1, aio_cb); |
430 | Newz (0, req, 1, aio_cb); |
… | |
… | |
436 | |
441 | |
437 | send_req (req); |
442 | send_req (req); |
438 | } |
443 | } |
439 | |
444 | |
440 | void |
445 | void |
441 | aio_close(fh,callback) |
446 | aio_close(fh,callback=&PL_sv_undef) |
442 | InputStream fh |
447 | InputStream fh |
443 | SV * callback |
448 | SV * callback |
444 | PROTOTYPE: $$ |
449 | PROTOTYPE: $;$ |
445 | ALIAS: |
450 | ALIAS: |
446 | aio_close = REQ_CLOSE |
451 | aio_close = REQ_CLOSE |
447 | aio_fsync = REQ_FSYNC |
452 | aio_fsync = REQ_FSYNC |
448 | aio_fdatasync = REQ_FDATASYNC |
453 | aio_fdatasync = REQ_FDATASYNC |
449 | CODE: |
454 | CODE: |
… | |
… | |
461 | |
466 | |
462 | send_req (req); |
467 | send_req (req); |
463 | } |
468 | } |
464 | |
469 | |
465 | void |
470 | void |
466 | aio_read(fh,offset,length,data,dataoffset,callback) |
471 | aio_read(fh,offset,length,data,dataoffset,callback=&PL_sv_undef) |
467 | InputStream fh |
472 | InputStream fh |
468 | UV offset |
473 | UV offset |
469 | IV length |
474 | IV length |
470 | SV * data |
475 | SV * data |
471 | IV dataoffset |
476 | IV dataoffset |
472 | SV * callback |
477 | SV * callback |
473 | PROTOTYPE: $$$$$$ |
478 | PROTOTYPE: $$$$$;$ |
474 | CODE: |
479 | CODE: |
475 | read_write (0, PerlIO_fileno (fh), offset, length, data, dataoffset, callback); |
480 | read_write (0, PerlIO_fileno (fh), offset, length, data, dataoffset, callback); |
476 | |
481 | |
477 | void |
482 | void |
478 | aio_write(fh,offset,length,data,dataoffset,callback) |
483 | aio_write(fh,offset,length,data,dataoffset,callback=&PL_sv_undef) |
479 | OutputStream fh |
484 | OutputStream fh |
480 | UV offset |
485 | UV offset |
481 | IV length |
486 | IV length |
482 | SV * data |
487 | SV * data |
483 | IV dataoffset |
488 | IV dataoffset |
484 | SV * callback |
489 | SV * callback |
485 | PROTOTYPE: $$$$$$ |
490 | PROTOTYPE: $$$$$;$ |
486 | CODE: |
491 | CODE: |
487 | read_write (1, PerlIO_fileno (fh), offset, length, data, dataoffset, callback); |
492 | read_write (1, PerlIO_fileno (fh), offset, length, data, dataoffset, callback); |
488 | |
493 | |
489 | void |
494 | void |
490 | aio_readahead(fh,offset,length,callback) |
495 | aio_readahead(fh,offset,length,callback=&PL_sv_undef) |
491 | InputStream fh |
496 | InputStream fh |
492 | UV offset |
497 | UV offset |
493 | IV length |
498 | IV length |
494 | SV * callback |
499 | SV * callback |
495 | PROTOTYPE: $$$$ |
500 | PROTOTYPE: $$$;$ |
496 | CODE: |
501 | CODE: |
497 | { |
502 | { |
498 | aio_req req; |
503 | aio_req req; |
499 | |
504 | |
500 | if (length < 0) |
505 | if (length < 0) |
… | |
… | |
513 | |
518 | |
514 | send_req (req); |
519 | send_req (req); |
515 | } |
520 | } |
516 | |
521 | |
517 | void |
522 | void |
518 | aio_stat(fh_or_path,callback) |
523 | aio_stat(fh_or_path,callback=&PL_sv_undef) |
519 | SV * fh_or_path |
524 | SV * fh_or_path |
520 | SV * callback |
525 | SV * callback |
521 | PROTOTYPE: $$ |
|
|
522 | ALIAS: |
526 | ALIAS: |
|
|
527 | aio_stat = REQ_STAT |
523 | aio_lstat = 1 |
528 | aio_lstat = REQ_LSTAT |
524 | CODE: |
529 | CODE: |
525 | { |
530 | { |
526 | aio_req req; |
531 | aio_req req; |
527 | |
532 | |
528 | Newz (0, req, 1, aio_cb); |
533 | Newz (0, req, 1, aio_cb); |
… | |
… | |
535 | if (!req->statdata) |
540 | if (!req->statdata) |
536 | croak ("out of memory during aio_req->statdata allocation"); |
541 | croak ("out of memory during aio_req->statdata allocation"); |
537 | |
542 | |
538 | if (SvPOK (fh_or_path)) |
543 | if (SvPOK (fh_or_path)) |
539 | { |
544 | { |
540 | req->type = ix ? REQ_LSTAT : REQ_STAT; |
545 | req->type = ix; |
541 | req->data = newSVsv (fh_or_path); |
546 | req->data = newSVsv (fh_or_path); |
542 | req->dataptr = SvPV_nolen (req->data); |
547 | req->dataptr = SvPV_nolen (req->data); |
543 | } |
548 | } |
544 | else |
549 | else |
545 | { |
550 | { |
… | |
… | |
551 | |
556 | |
552 | send_req (req); |
557 | send_req (req); |
553 | } |
558 | } |
554 | |
559 | |
555 | void |
560 | void |
556 | aio_unlink(pathname,callback) |
561 | aio_unlink(pathname,callback=&PL_sv_undef) |
557 | SV * pathname |
562 | SV * pathname |
558 | SV * callback |
563 | SV * callback |
559 | PROTOTYPE: $$ |
|
|
560 | CODE: |
564 | CODE: |
561 | { |
565 | { |
562 | aio_req req; |
566 | aio_req req; |
563 | |
567 | |
564 | Newz (0, req, 1, aio_cb); |
568 | Newz (0, req, 1, aio_cb); |
… | |
… | |
572 | req->callback = SvREFCNT_inc (callback); |
576 | req->callback = SvREFCNT_inc (callback); |
573 | |
577 | |
574 | send_req (req); |
578 | send_req (req); |
575 | } |
579 | } |
576 | |
580 | |
|
|
581 | void |
|
|
582 | flush() |
|
|
583 | PROTOTYPE: |
|
|
584 | CODE: |
|
|
585 | while (nreqs) |
|
|
586 | { |
|
|
587 | poll_wait (); |
|
|
588 | poll_cb (); |
|
|
589 | } |
|
|
590 | |
|
|
591 | void |
|
|
592 | poll() |
|
|
593 | PROTOTYPE: |
|
|
594 | CODE: |
|
|
595 | if (nreqs) |
|
|
596 | { |
|
|
597 | poll_wait (); |
|
|
598 | poll_cb (); |
|
|
599 | } |
|
|
600 | |
577 | int |
601 | int |
578 | poll_fileno() |
602 | poll_fileno() |
579 | PROTOTYPE: |
603 | PROTOTYPE: |
580 | CODE: |
604 | CODE: |
581 | RETVAL = respipe [0]; |
605 | RETVAL = respipe [0]; |