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.120 by root, Sun May 11 19:17:09 2008 UTC vs.
Revision 1.123 by root, Sat May 17 12:17:25 2008 UTC

80typedef SV SV8; /* byte-sv, used for argument-checking */ 80typedef 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
91#define EIO_NO_WRAPPERS 1
90 92
91#include "libeio/eio.h" 93#include "libeio/eio.h"
92 94
93static int req_invoke (eio_req *req); 95static int req_invoke (eio_req *req);
94#define EIO_FINISH(req) req_invoke (req) 96#define EIO_FINISH(req) req_invoke (req)
105 107
106typedef eio_req *aio_req; 108typedef eio_req *aio_req;
107typedef eio_req *aio_req_ornot; 109typedef eio_req *aio_req_ornot;
108 110
109static SV *on_next_submit; 111static SV *on_next_submit;
110static int next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; 112static int next_pri = EIO_PRI_DEFAULT;
111static int max_outstanding; 113static int max_outstanding;
112 114
113static int respipe_osf [2], respipe [2] = { -1, -1 }; 115static int respipe_osf [2], respipe [2] = { -1, -1 };
114 116
115static void req_destroy (aio_req req); 117static void req_destroy (aio_req req);
410 X_UNLOCK (reslock); 412 X_UNLOCK (reslock);
411 413
412 if (size) 414 if (size)
413 return; 415 return;
414 416
415 maybe_start_thread (); 417 etp_maybe_start_thread ();
416 418
417 FD_ZERO (&rfd); 419 FD_ZERO (&rfd);
418 FD_SET (respipe [0], &rfd); 420 FD_SET (respipe [0], &rfd);
419 421
420 PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); 422 PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0);
443} 445}
444 446
445#define dREQ \ 447#define dREQ \
446 aio_req req; \ 448 aio_req req; \
447 int req_pri = next_pri; \ 449 int req_pri = next_pri; \
448 next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; \ 450 next_pri = EIO_PRI_DEFAULT; \
449 \ 451 \
450 if (SvOK (callback) && !SvROK (callback)) \ 452 if (SvOK (callback) && !SvROK (callback)) \
451 croak ("callback must be undef or of reference type"); \ 453 croak ("callback must be undef or of reference type"); \
452 \ 454 \
453 Newz (0, req, 1, eio_req); \ 455 Newz (0, req, 1, eio_req); \
474 newCONSTSUB (stash, "EXDEV", newSViv (EXDEV)); 476 newCONSTSUB (stash, "EXDEV", newSViv (EXDEV));
475 newCONSTSUB (stash, "O_RDONLY", newSViv (O_RDONLY)); 477 newCONSTSUB (stash, "O_RDONLY", newSViv (O_RDONLY));
476 newCONSTSUB (stash, "O_WRONLY", newSViv (O_WRONLY)); 478 newCONSTSUB (stash, "O_WRONLY", newSViv (O_WRONLY));
477 newCONSTSUB (stash, "O_CREAT", newSViv (O_CREAT)); 479 newCONSTSUB (stash, "O_CREAT", newSViv (O_CREAT));
478 newCONSTSUB (stash, "O_TRUNC", newSViv (O_TRUNC)); 480 newCONSTSUB (stash, "O_TRUNC", newSViv (O_TRUNC));
479#ifdef _WIN32 481#ifndef _WIN32
480 X_MUTEX_CHECK (wrklock);
481 X_MUTEX_CHECK (reslock);
482 X_MUTEX_CHECK (reqlock);
483 X_MUTEX_CHECK (reqwait);
484 X_MUTEX_CHECK (preadwritelock);
485 X_MUTEX_CHECK (readdirlock);
486
487 X_COND_CHECK (reqwait);
488#else
489 newCONSTSUB (stash, "S_IFIFO", newSViv (S_IFIFO)); 482 newCONSTSUB (stash, "S_IFIFO", newSViv (S_IFIFO));
490#endif 483#endif
491 484
492 create_respipe (); 485 create_respipe ();
493 486
917 910
918int 911int
919aioreq_pri (int pri = 0) 912aioreq_pri (int pri = 0)
920 PROTOTYPE: ;$ 913 PROTOTYPE: ;$
921 CODE: 914 CODE:
922 RETVAL = next_pri - EIO_PRI_BIAS; 915 RETVAL = next_pri;
923 if (items > 0) 916 if (items > 0)
924 { 917 {
925 if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; 918 if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN;
926 if (pri > EIO_PRI_MAX) pri = EIO_PRI_MAX; 919 if (pri > EIO_PRI_MAX) pri = EIO_PRI_MAX;
927 next_pri = pri + EIO_PRI_BIAS; 920 next_pri = pri;
928 } 921 }
929 OUTPUT: 922 OUTPUT:
930 RETVAL 923 RETVAL
931 924
932void 925void
933aioreq_nice (int nice = 0) 926aioreq_nice (int nice = 0)
934 CODE: 927 CODE:
935 nice = next_pri - nice; 928 nice = next_pri - nice;
936 if (nice < EIO_PRI_MIN) nice = EIO_PRI_MIN; 929 if (nice < EIO_PRI_MIN) nice = EIO_PRI_MIN;
937 if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; 930 if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX;
938 next_pri = nice + EIO_PRI_BIAS; 931 next_pri = nice;
939 932
940void 933void
941flush () 934flush ()
942 PROTOTYPE: 935 PROTOTYPE:
943 CODE: 936 CODE:
1004 997
1005int 998int
1006nthreads() 999nthreads()
1007 PROTOTYPE: 1000 PROTOTYPE:
1008 CODE: 1001 CODE:
1009 if (WORDACCESS_UNSAFE) X_LOCK (wrklock); 1002 RETVAL = eio_nthreads ();
1010 RETVAL = started;
1011 if (WORDACCESS_UNSAFE) X_UNLOCK (wrklock);
1012 OUTPUT: 1003 OUTPUT:
1013 RETVAL 1004 RETVAL
1014 1005
1015void _on_next_submit (SV *cb) 1006void _on_next_submit (SV *cb)
1016 CODE: 1007 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines