… | |
… | |
128 | |
128 | |
129 | static int next_pri = DEFAULT_PRI + PRI_BIAS; |
129 | static int next_pri = DEFAULT_PRI + PRI_BIAS; |
130 | |
130 | |
131 | static int started, wanted; |
131 | static int started, wanted; |
132 | static volatile int nreqs; |
132 | static volatile int nreqs; |
133 | static int max_outstanding = 1<<30; |
|
|
134 | static int respipe [2]; |
133 | static int respipe [2]; |
135 | |
134 | |
136 | #if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) |
135 | #if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) |
137 | # define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP |
136 | # define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP |
138 | #else |
137 | #else |
… | |
… | |
238 | } |
237 | } |
239 | |
238 | |
240 | abort (); |
239 | abort (); |
241 | } |
240 | } |
242 | |
241 | |
|
|
242 | static int poll_cb (); |
243 | static void req_invoke (aio_req req); |
243 | static void req_invoke (aio_req req); |
244 | static void req_free (aio_req req); |
244 | static void req_free (aio_req req); |
245 | static void req_cancel (aio_req req); |
245 | static void req_cancel (aio_req req); |
246 | |
246 | |
247 | /* must be called at most once */ |
247 | /* must be called at most once */ |
… | |
… | |
600 | |
600 | |
601 | LOCK (reqlock); |
601 | LOCK (reqlock); |
602 | reqq_push (&req_queue, req); |
602 | reqq_push (&req_queue, req); |
603 | pthread_cond_signal (&reqwait); |
603 | pthread_cond_signal (&reqwait); |
604 | UNLOCK (reqlock); |
604 | UNLOCK (reqlock); |
605 | |
|
|
606 | if (nreqs > max_outstanding) |
|
|
607 | for (;;) |
|
|
608 | { |
|
|
609 | poll_cb (); |
|
|
610 | |
|
|
611 | if (nreqs <= max_outstanding) |
|
|
612 | break; |
|
|
613 | |
|
|
614 | poll_wait (); |
|
|
615 | } |
|
|
616 | } |
605 | } |
617 | |
606 | |
618 | static void end_thread (void) |
607 | static void end_thread (void) |
619 | { |
608 | { |
620 | aio_req req; |
609 | aio_req req; |
… | |
… | |
1116 | void |
1105 | void |
1117 | max_parallel (nthreads) |
1106 | max_parallel (nthreads) |
1118 | int nthreads |
1107 | int nthreads |
1119 | PROTOTYPE: $ |
1108 | PROTOTYPE: $ |
1120 | |
1109 | |
1121 | int |
|
|
1122 | max_outstanding (nreqs) |
|
|
1123 | int nreqs |
|
|
1124 | PROTOTYPE: $ |
|
|
1125 | CODE: |
|
|
1126 | RETVAL = max_outstanding; |
|
|
1127 | max_outstanding = nreqs; |
|
|
1128 | |
|
|
1129 | void |
1110 | void |
1130 | aio_open (pathname,flags,mode,callback=&PL_sv_undef) |
1111 | aio_open (pathname,flags,mode,callback=&PL_sv_undef) |
1131 | SV * pathname |
1112 | SV * pathname |
1132 | int flags |
1113 | int flags |
1133 | int mode |
1114 | int mode |