… | |
… | |
80 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
80 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
81 | |
81 | |
82 | #define AIO_REQ_KLASS "IO::AIO::REQ" |
82 | #define AIO_REQ_KLASS "IO::AIO::REQ" |
83 | #define AIO_GRP_KLASS "IO::AIO::GRP" |
83 | #define AIO_GRP_KLASS "IO::AIO::GRP" |
84 | |
84 | |
85 | #define EIO_COMMON \ |
85 | #define EIO_REQ_MEMBERS \ |
86 | SV *callback; \ |
86 | SV *callback; \ |
87 | SV *sv1, *sv2; \ |
87 | SV *sv1, *sv2; \ |
88 | STRLEN stroffset; \ |
88 | STRLEN stroffset; \ |
89 | SV *self |
89 | SV *self; |
90 | |
90 | |
91 | #include "libeio/eio.h" |
91 | #include "libeio/eio.h" |
92 | |
92 | |
93 | static int req_invoke (eio_req *req); |
93 | static int req_invoke (eio_req *req); |
94 | #define EIO_FINISH(req) req_invoke (req) |
94 | #define EIO_FINISH(req) req_invoke (req) |
… | |
… | |
105 | |
105 | |
106 | typedef eio_req *aio_req; |
106 | typedef eio_req *aio_req; |
107 | typedef eio_req *aio_req_ornot; |
107 | typedef eio_req *aio_req_ornot; |
108 | |
108 | |
109 | static SV *on_next_submit; |
109 | static SV *on_next_submit; |
110 | static int next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; |
110 | static int next_pri = EIO_PRI_DEFAULT; |
111 | static int max_outstanding; |
111 | static int max_outstanding; |
112 | |
112 | |
113 | static int respipe_osf [2], respipe [2] = { -1, -1 }; |
113 | static int respipe_osf [2], respipe [2] = { -1, -1 }; |
114 | |
114 | |
115 | static void req_destroy (aio_req req); |
115 | static void req_destroy (aio_req req); |
… | |
… | |
443 | } |
443 | } |
444 | |
444 | |
445 | #define dREQ \ |
445 | #define dREQ \ |
446 | aio_req req; \ |
446 | aio_req req; \ |
447 | int req_pri = next_pri; \ |
447 | int req_pri = next_pri; \ |
448 | next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; \ |
448 | next_pri = EIO_PRI_DEFAULT; \ |
449 | \ |
449 | \ |
450 | if (SvOK (callback) && !SvROK (callback)) \ |
450 | if (SvOK (callback) && !SvROK (callback)) \ |
451 | croak ("callback must be undef or of reference type"); \ |
451 | croak ("callback must be undef or of reference type"); \ |
452 | \ |
452 | \ |
453 | Newz (0, req, 1, eio_req); \ |
453 | Newz (0, req, 1, eio_req); \ |
… | |
… | |
917 | |
917 | |
918 | int |
918 | int |
919 | aioreq_pri (int pri = 0) |
919 | aioreq_pri (int pri = 0) |
920 | PROTOTYPE: ;$ |
920 | PROTOTYPE: ;$ |
921 | CODE: |
921 | CODE: |
922 | RETVAL = next_pri - EIO_PRI_BIAS; |
922 | RETVAL = next_pri; |
923 | if (items > 0) |
923 | if (items > 0) |
924 | { |
924 | { |
925 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
925 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
926 | if (pri > EIO_PRI_MAX) pri = EIO_PRI_MAX; |
926 | if (pri > EIO_PRI_MAX) pri = EIO_PRI_MAX; |
927 | next_pri = pri + EIO_PRI_BIAS; |
927 | next_pri = pri; |
928 | } |
928 | } |
929 | OUTPUT: |
929 | OUTPUT: |
930 | RETVAL |
930 | RETVAL |
931 | |
931 | |
932 | void |
932 | void |
933 | aioreq_nice (int nice = 0) |
933 | aioreq_nice (int nice = 0) |
934 | CODE: |
934 | CODE: |
935 | nice = next_pri - nice; |
935 | nice = next_pri - nice; |
936 | if (nice < EIO_PRI_MIN) nice = EIO_PRI_MIN; |
936 | if (nice < EIO_PRI_MIN) nice = EIO_PRI_MIN; |
937 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
937 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
938 | next_pri = nice + EIO_PRI_BIAS; |
938 | next_pri = nice; |
939 | |
939 | |
940 | void |
940 | void |
941 | flush () |
941 | flush () |
942 | PROTOTYPE: |
942 | PROTOTYPE: |
943 | CODE: |
943 | CODE: |