ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.xs
(Generate patch)

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.73 by root, Tue Oct 24 21:26:30 2006 UTC vs.
Revision 1.75 by root, Thu Oct 26 06:44:48 2006 UTC

47/* used for struct dirent, AIX doesn't provide it */ 47/* used for struct dirent, AIX doesn't provide it */
48#ifndef NAME_MAX 48#ifndef NAME_MAX
49# define NAME_MAX 4096 49# define NAME_MAX 4096
50#endif 50#endif
51 51
52#ifndef PTHREAD_STACK_MIN
53/* care for broken platforms, e.g. windows */
54# define PTHREAD_STACK_MIN 16384
55#endif
56
52#if __ia64 57#if __ia64
53# define STACKSIZE 65536 58# define STACKSIZE 65536
54#elif __i386 || __x86_64 /* 16k is unreasonably high :( */ 59#elif __i386 || __x86_64 /* 16k is unreasonably high :( */
55# define STACKSIZE PTHREAD_STACK_MIN 60# define STACKSIZE PTHREAD_STACK_MIN
56#else 61#else
128 133
129static int next_pri = DEFAULT_PRI + PRI_BIAS; 134static int next_pri = DEFAULT_PRI + PRI_BIAS;
130 135
131static int started, wanted; 136static int started, wanted;
132static volatile int nreqs; 137static volatile int nreqs;
133static int max_outstanding = 1<<30;
134static int respipe [2]; 138static int respipe [2];
135 139
136#if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) 140#if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP)
137# define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 141# define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
138#else 142#else
238 } 242 }
239 243
240 abort (); 244 abort ();
241} 245}
242 246
247static int poll_cb ();
243static void req_invoke (aio_req req); 248static void req_invoke (aio_req req);
244static void req_free (aio_req req); 249static void req_free (aio_req req);
245static void req_cancel (aio_req req); 250static void req_cancel (aio_req req);
246 251
247/* must be called at most once */ 252/* must be called at most once */
600 605
601 LOCK (reqlock); 606 LOCK (reqlock);
602 reqq_push (&req_queue, req); 607 reqq_push (&req_queue, req);
603 pthread_cond_signal (&reqwait); 608 pthread_cond_signal (&reqwait);
604 UNLOCK (reqlock); 609 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} 610}
617 611
618static void end_thread (void) 612static void end_thread (void)
619{ 613{
620 aio_req req; 614 aio_req req;
713#if !HAVE_FDATASYNC 707#if !HAVE_FDATASYNC
714# define fdatasync fsync 708# define fdatasync fsync
715#endif 709#endif
716 710
717#if !HAVE_READAHEAD 711#if !HAVE_READAHEAD
718# define readahead aio_readahead 712# define readahead(fd,offset,count) aio_readahead (fd, offset, count, self)
719 713
720static ssize_t readahead (int fd, off_t offset, size_t count) 714static ssize_t aio_readahead (int fd, off_t offset, size_t count, worker *self)
721{ 715{
722 dBUF; 716 dBUF;
723 717
724 while (count > 0) 718 while (count > 0)
725 { 719 {
730 count -= len; 724 count -= len;
731 } 725 }
732 726
733 errno = 0; 727 errno = 0;
734} 728}
729
735#endif 730#endif
736 731
737#if !HAVE_READDIR_R 732#if !HAVE_READDIR_R
738# define readdir_r aio_readdir_r 733# define readdir_r aio_readdir_r
739 734
1116void 1111void
1117max_parallel (nthreads) 1112max_parallel (nthreads)
1118 int nthreads 1113 int nthreads
1119 PROTOTYPE: $ 1114 PROTOTYPE: $
1120 1115
1121int
1122max_outstanding (nreqs)
1123 int nreqs
1124 PROTOTYPE: $
1125 CODE:
1126 RETVAL = max_outstanding;
1127 max_outstanding = nreqs;
1128
1129void 1116void
1130aio_open (pathname,flags,mode,callback=&PL_sv_undef) 1117aio_open (pathname,flags,mode,callback=&PL_sv_undef)
1131 SV * pathname 1118 SV * pathname
1132 int flags 1119 int flags
1133 int mode 1120 int mode

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines