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

Comparing EV/EV.xs (file contents):
Revision 1.35 by root, Thu Nov 1 13:33:12 2007 UTC vs.
Revision 1.40 by root, Fri Nov 2 11:09:50 2007 UTC

2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4 4
5/*#include <netinet/in.h>*/ 5/*#include <netinet/in.h>*/
6 6
7#define TIMEOUT_NONE HUGE_VAL
8
9#define EV_PROTOTYPES 1 7#define EV_PROTOTYPES 1
10#include "EV/EVAPI.h" 8#include "EV/EVAPI.h"
11 9
12#include "libev/ev.c" 10#include "libev/ev.c"
11#include "libev/event.h"
12#include "libev/event.c"
13#include "libev/evdns.c"
13 14
14typedef int Signal; 15typedef int Signal;
15 16
16static struct EVAPI evapi; 17static struct EVAPI evapi;
17 18
155 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); 156 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
156 SP = PL_stack_base + mark; PUTBACK; 157 SP = PL_stack_base + mark; PUTBACK;
157 } 158 }
158} 159}
159 160
160#if 0
161///////////////////////////////////////////////////////////////////////////// 161/////////////////////////////////////////////////////////////////////////////
162// DNS 162// DNS
163 163
164static void 164static void
165dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) 165dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg)
207 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); 207 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
208 } 208 }
209 209
210 LEAVE; 210 LEAVE;
211} 211}
212#endif
213 212
214#define CHECK_REPEAT(repeat) if (repeat < 0.) \ 213#define CHECK_REPEAT(repeat) if (repeat < 0.) \
215 croak (# repeat " value must be >= 0"); 214 croak (# repeat " value must be >= 0");
216 215
217#define CHECK_FD(fh,fd) if ((fd) < 0) \ 216#define CHECK_FD(fh,fd) if ((fd) < 0) \
482 } 481 }
483} 482}
484 OUTPUT: 483 OUTPUT:
485 RETVAL 484 RETVAL
486 485
487short events (struct ev_io *w, short new_events = EV_UNDEF) 486int events (struct ev_io *w, int new_events = EV_UNDEF)
488 CODE: 487 CODE:
489{ 488{
490 RETVAL = w->events; 489 RETVAL = w->events;
491 490
492 if (items > 1) 491 if (items > 1)
511void DESTROY (struct ev_signal *w) 510void DESTROY (struct ev_signal *w)
512 CODE: 511 CODE:
513 ev_signal_stop (w); 512 ev_signal_stop (w);
514 e_destroy (w); 513 e_destroy (w);
515 514
516void set (struct ev_signal *w, SV *signal = 0) 515void set (struct ev_signal *w, SV *signal)
517 CODE: 516 CODE:
518{ 517{
519 Signal signum = sv_signum (signal); /* may croak here */ 518 Signal signum = sv_signum (signal); /* may croak here */
520 int active = w->active; 519 int active = w->active;
521 520
522 if (active) ev_signal_stop (w); 521 if (active) ev_signal_stop (w);
522
523 ev_signal_set (w, signum); 523 ev_signal_set (w, signum);
524
524 if (active) ev_signal_start (w); 525 if (active) ev_signal_start (w);
525} 526}
527
528int signal (struct ev_signal *w, SV *new_signal = 0)
529 CODE:
530{
531 RETVAL = w->signum;
532
533 if (items > 1)
534 {
535 Signal signum = sv_signum (new_signal); /* may croak here */
536 int active = w->active;
537 if (active) ev_signal_stop (w);
538
539 ev_signal_set (w, signum);
540
541 if (active) ev_signal_start (w);
542 }
543}
544 OUTPUT:
545 RETVAL
526 546
527MODULE = EV PACKAGE = EV::Time 547MODULE = EV PACKAGE = EV::Time
528 548
529MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ 549MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_
530 550
572 CHECK_REPEAT (interval); 592 CHECK_REPEAT (interval);
573 CODE: 593 CODE:
574{ 594{
575 int active = w->active; 595 int active = w->active;
576 if (active) ev_periodic_stop (w); 596 if (active) ev_periodic_stop (w);
597
577 ev_periodic_set (w, at, interval); 598 ev_periodic_set (w, at, interval);
599
578 if (active) ev_periodic_start (w); 600 if (active) ev_periodic_start (w);
579} 601}
580 602
581MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 603MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
582 604
625void set (struct ev_child *w, int pid) 647void set (struct ev_child *w, int pid)
626 CODE: 648 CODE:
627{ 649{
628 int active = w->active; 650 int active = w->active;
629 if (active) ev_child_stop (w); 651 if (active) ev_child_stop (w);
652
630 ev_child_set (w, pid); 653 ev_child_set (w, pid);
654
631 if (active) ev_child_start (w); 655 if (active) ev_child_start (w);
632} 656}
633 657
658int pid (struct ev_child *w, int new_pid = 0)
659 CODE:
660{
661 RETVAL = w->pid;
662
663 if (items > 1)
664 {
665 int active = w->active;
666 if (active) ev_child_stop (w);
667
668 ev_child_set (w, new_pid);
669
670 if (active) ev_child_start (w);
671 }
672}
673 OUTPUT:
674 RETVAL
675
676
634int status (struct ev_child *w) 677int status (struct ev_child *w)
635 CODE: 678 CODE:
636 RETVAL = w->status; 679 RETVAL = w->status;
637 OUTPUT: 680 OUTPUT:
638 RETVAL 681 RETVAL
639
640#if 0
641 682
642MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ 683MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_
643 684
644BOOT: 685BOOT:
645{ 686{
728 769
729void evdns_search_add (char *domain) 770void evdns_search_add (char *domain)
730 771
731void evdns_search_ndots_set (int ndots) 772void evdns_search_ndots_set (int ndots)
732 773
774#if 0
733 775
734MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ 776MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_
735 777
736BOOT: 778BOOT:
737{ 779{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines