… | |
… | |
12 | #include <sys/types.h> |
12 | #include <sys/types.h> |
13 | #include <sys/stat.h> |
13 | #include <sys/stat.h> |
14 | #include <limits.h> |
14 | #include <limits.h> |
15 | #include <fcntl.h> |
15 | #include <fcntl.h> |
16 | #include <sched.h> |
16 | #include <sched.h> |
|
|
17 | |
|
|
18 | /* perl namespace pollution */ |
|
|
19 | #undef VERSION |
17 | |
20 | |
18 | #ifdef _WIN32 |
21 | #ifdef _WIN32 |
19 | |
22 | |
20 | # define EIO_STRUCT_DIRENT Direntry_t |
23 | # define EIO_STRUCT_DIRENT Direntry_t |
21 | # undef malloc |
24 | # undef malloc |
… | |
… | |
101 | #include "libeio/eio.c" |
104 | #include "libeio/eio.c" |
102 | |
105 | |
103 | typedef eio_req *aio_req; |
106 | typedef eio_req *aio_req; |
104 | typedef eio_req *aio_req_ornot; |
107 | typedef eio_req *aio_req_ornot; |
105 | |
108 | |
106 | static int max_outstanding = 0; |
109 | static SV *on_next_submit; |
107 | |
|
|
108 | static int next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; |
110 | static int next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; |
|
|
111 | static int max_outstanding; |
109 | |
112 | |
110 | static int respipe_osf [2], respipe [2] = { -1, -1 }; |
113 | static int respipe_osf [2], respipe [2] = { -1, -1 }; |
111 | |
114 | |
112 | static void req_destroy (aio_req req); |
115 | static void req_destroy (aio_req req); |
113 | static void req_cancel (aio_req req); |
116 | static void req_cancel (aio_req req); |
… | |
… | |
163 | PUTBACK; |
166 | PUTBACK; |
164 | call_sv (grp->sv2, G_VOID | G_EVAL | G_KEEPERR); |
167 | call_sv (grp->sv2, G_VOID | G_EVAL | G_KEEPERR); |
165 | SPAGAIN; |
168 | SPAGAIN; |
166 | FREETMPS; |
169 | FREETMPS; |
167 | LEAVE; |
170 | LEAVE; |
|
|
171 | } |
|
|
172 | } |
|
|
173 | |
|
|
174 | static void req_submit (eio_req *req) |
|
|
175 | { |
|
|
176 | eio_submit (req); |
|
|
177 | |
|
|
178 | if (on_next_submit) |
|
|
179 | { |
|
|
180 | dSP; |
|
|
181 | SV *cb = sv_2mortal (on_next_submit); |
|
|
182 | |
|
|
183 | on_next_submit = 0; |
|
|
184 | |
|
|
185 | PUSHMARK (SP); |
|
|
186 | PUTBACK; |
|
|
187 | call_sv (cb, G_DISCARD | G_EVAL); |
168 | } |
188 | } |
169 | } |
189 | } |
170 | |
190 | |
171 | static int req_invoke (eio_req *req) |
191 | static int req_invoke (eio_req *req) |
172 | { |
192 | { |
… | |
… | |
440 | \ |
460 | \ |
441 | req->callback = newSVsv (callback); \ |
461 | req->callback = newSVsv (callback); \ |
442 | req->pri = req_pri |
462 | req->pri = req_pri |
443 | |
463 | |
444 | #define REQ_SEND \ |
464 | #define REQ_SEND \ |
445 | eio_submit (req); \ |
465 | req_submit (req); \ |
446 | \ |
466 | \ |
447 | if (GIMME_V != G_VOID) \ |
467 | if (GIMME_V != G_VOID) \ |
448 | XPUSHs (req_sv (req, AIO_REQ_KLASS)); |
468 | XPUSHs (req_sv (req, AIO_REQ_KLASS)); |
449 | |
469 | |
450 | MODULE = IO::AIO PACKAGE = IO::AIO |
470 | MODULE = IO::AIO PACKAGE = IO::AIO |
… | |
… | |
1003 | RETVAL = started; |
1023 | RETVAL = started; |
1004 | if (WORDACCESS_UNSAFE) X_UNLOCK (wrklock); |
1024 | if (WORDACCESS_UNSAFE) X_UNLOCK (wrklock); |
1005 | OUTPUT: |
1025 | OUTPUT: |
1006 | RETVAL |
1026 | RETVAL |
1007 | |
1027 | |
|
|
1028 | void _on_next_submit (SV *cb) |
|
|
1029 | CODE: |
|
|
1030 | SvREFCNT_dec (on_next_submit); |
|
|
1031 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
|
|
1032 | |
1008 | PROTOTYPES: DISABLE |
1033 | PROTOTYPES: DISABLE |
1009 | |
1034 | |
1010 | MODULE = IO::AIO PACKAGE = IO::AIO::REQ |
1035 | MODULE = IO::AIO PACKAGE = IO::AIO::REQ |
1011 | |
1036 | |
1012 | void |
1037 | void |