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.110 by root, Sun Dec 2 20:54:33 2007 UTC vs.
Revision 1.111 by root, Sun Mar 30 06:31:49 2008 UTC

189 189
190static thread_t main_tid; 190static thread_t main_tid;
191static int main_sig; 191static int main_sig;
192static int block_sig_level; 192static int block_sig_level;
193 193
194void block_sig () 194void block_sig (void)
195{ 195{
196 sigset_t ss; 196 sigset_t ss;
197 197
198 if (block_sig_level++) 198 if (block_sig_level++)
199 return; 199 return;
204 sigemptyset (&ss); 204 sigemptyset (&ss);
205 sigaddset (&ss, main_sig); 205 sigaddset (&ss, main_sig);
206 pthread_sigmask (SIG_BLOCK, &ss, 0); 206 pthread_sigmask (SIG_BLOCK, &ss, 0);
207} 207}
208 208
209void unblock_sig () 209void unblock_sig (void)
210{ 210{
211 sigset_t ss; 211 sigset_t ss;
212 212
213 if (--block_sig_level) 213 if (--block_sig_level)
214 return; 214 return;
274static mutex_t reqlock = X_MUTEX_INIT; 274static mutex_t reqlock = X_MUTEX_INIT;
275static cond_t reqwait = X_COND_INIT; 275static cond_t reqwait = X_COND_INIT;
276 276
277#if WORDACCESS_UNSAFE 277#if WORDACCESS_UNSAFE
278 278
279static unsigned int get_nready () 279static unsigned int get_nready (void)
280{ 280{
281 unsigned int retval; 281 unsigned int retval;
282 282
283 X_LOCK (reqlock); 283 X_LOCK (reqlock);
284 retval = nready; 284 retval = nready;
285 X_UNLOCK (reqlock); 285 X_UNLOCK (reqlock);
286 286
287 return retval; 287 return retval;
288} 288}
289 289
290static unsigned int get_npending () 290static unsigned int get_npending (void)
291{ 291{
292 unsigned int retval; 292 unsigned int retval;
293 293
294 X_LOCK (reslock); 294 X_LOCK (reslock);
295 retval = npending; 295 retval = npending;
296 X_UNLOCK (reslock); 296 X_UNLOCK (reslock);
297 297
298 return retval; 298 return retval;
299} 299}
300 300
301static unsigned int get_nthreads () 301static unsigned int get_nthreads (void)
302{ 302{
303 unsigned int retval; 303 unsigned int retval;
304 304
305 X_LOCK (wrklock); 305 X_LOCK (wrklock);
306 retval = started; 306 retval = started;
369 } 369 }
370 370
371 abort (); 371 abort ();
372} 372}
373 373
374static int poll_cb (); 374static int poll_cb (void);
375static int req_invoke (aio_req req); 375static int req_invoke (aio_req req);
376static void req_destroy (aio_req req); 376static void req_destroy (aio_req req);
377static void req_cancel (aio_req req); 377static void req_cancel (aio_req req);
378 378
379/* must be called at most once */ 379/* must be called at most once */
653#else 653#else
654# define TO_SOCKET(x) (x) 654# define TO_SOCKET(x) (x)
655#endif 655#endif
656 656
657static void 657static void
658create_respipe () 658create_respipe (void)
659{ 659{
660 int old_readfd = respipe [0]; 660 int old_readfd = respipe [0];
661 661
662 if (respipe [1] >= 0) 662 if (respipe [1] >= 0)
663 respipe_close (TO_SOCKET (respipe [1])); 663 respipe_close (TO_SOCKET (respipe [1]));
715 free (wrk); 715 free (wrk);
716 716
717 X_UNLOCK (wrklock); 717 X_UNLOCK (wrklock);
718} 718}
719 719
720static void maybe_start_thread () 720static void maybe_start_thread (void)
721{ 721{
722 if (get_nthreads () >= wanted) 722 if (get_nthreads () >= wanted)
723 return; 723 return;
724 724
725 /* todo: maybe use idle here, but might be less exact */ 725 /* todo: maybe use idle here, but might be less exact */
785 785
786 while (started > wanted) 786 while (started > wanted)
787 end_thread (); 787 end_thread ();
788} 788}
789 789
790static void poll_wait () 790static void poll_wait (void)
791{ 791{
792 fd_set rfd; 792 fd_set rfd;
793 793
794 while (nreqs) 794 while (nreqs)
795 { 795 {
808 808
809 PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); 809 PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0);
810 } 810 }
811} 811}
812 812
813static int poll_cb () 813static int poll_cb (void)
814{ 814{
815 dSP; 815 dSP;
816 int count = 0; 816 int count = 0;
817 int maxreqs = max_poll_reqs; 817 int maxreqs = max_poll_reqs;
818 int do_croak = 0; 818 int do_croak = 0;
1992 1992
1993 block_sig (); 1993 block_sig ();
1994 PUSHMARK (SP); 1994 PUSHMARK (SP);
1995 PUTBACK; 1995 PUTBACK;
1996 count = call_sv (cb, GIMME_V | G_NOARGS | G_EVAL); 1996 count = call_sv (cb, GIMME_V | G_NOARGS | G_EVAL);
1997 SPAGAIN;
1998 unblock_sig (); 1997 unblock_sig ();
1999 1998
2000 if (SvTRUE (ERRSV)) 1999 if (SvTRUE (ERRSV))
2001 croak (0); 2000 croak (0);
2002 2001

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines