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

Comparing EV/EV.xs (file contents):
Revision 1.34 by root, Thu Nov 1 12:11:07 2007 UTC vs.
Revision 1.39 by root, Fri Nov 2 11:02:22 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#define EV_USE_EPOLL 1
9
10#define EV_PROTOTYPES 1 7#define EV_PROTOTYPES 1
11#include "EV/EVAPI.h" 8#include "EV/EVAPI.h"
12 9
13#include "libev/ev.c" 10#include "libev/ev.c"
11#include "libev/event.h"
12#include "libev/event.c"
13#include "libev/evdns.c"
14 14
15typedef int Signal; 15typedef int Signal;
16 16
17static struct EVAPI evapi; 17static struct EVAPI evapi;
18 18
156 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);
157 SP = PL_stack_base + mark; PUTBACK; 157 SP = PL_stack_base + mark; PUTBACK;
158 } 158 }
159} 159}
160 160
161#if 0
162///////////////////////////////////////////////////////////////////////////// 161/////////////////////////////////////////////////////////////////////////////
163// DNS 162// DNS
164 163
165static void 164static void
166dns_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)
208 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);
209 } 208 }
210 209
211 LEAVE; 210 LEAVE;
212} 211}
213#endif
214 212
215#define CHECK_REPEAT(repeat) if (repeat < 0.) \ 213#define CHECK_REPEAT(repeat) if (repeat < 0.) \
216 croak (# repeat " value must be >= 0"); 214 croak (# repeat " value must be >= 0");
217 215
218#define CHECK_FD(fh,fd) if ((fd) < 0) \ 216#define CHECK_FD(fh,fd) if ((fd) < 0) \
483 } 481 }
484} 482}
485 OUTPUT: 483 OUTPUT:
486 RETVAL 484 RETVAL
487 485
488short events (struct ev_io *w, short new_events = EV_UNDEF) 486int events (struct ev_io *w, int new_events = EV_UNDEF)
489 CODE: 487 CODE:
490{ 488{
491 RETVAL = w->events; 489 RETVAL = w->events;
492 490
493 if (items > 1) 491 if (items > 1)
519{ 517{
520 Signal signum = sv_signum (signal); /* may croak here */ 518 Signal signum = sv_signum (signal); /* may croak here */
521 int active = w->active; 519 int active = w->active;
522 520
523 if (active) ev_signal_stop (w); 521 if (active) ev_signal_stop (w);
522
524 ev_signal_set (w, signum); 523 ev_signal_set (w, signum);
524
525 if (active) ev_signal_start (w); 525 if (active) ev_signal_start (w);
526} 526}
527
528int signal (struct ev_signal *w, SV *new_signal = 0)
529 CODE:
530{
531 Signal signum = new_signal ? sv_signum (signal) : 0; /* may croak here */
532 RETVAL = w->signum;
533
534 if (items > 1)
535 {
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
527 546
528MODULE = EV PACKAGE = EV::Time 547MODULE = EV PACKAGE = EV::Time
529 548
530MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ 549MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_
531 550
573 CHECK_REPEAT (interval); 592 CHECK_REPEAT (interval);
574 CODE: 593 CODE:
575{ 594{
576 int active = w->active; 595 int active = w->active;
577 if (active) ev_periodic_stop (w); 596 if (active) ev_periodic_stop (w);
597
578 ev_periodic_set (w, at, interval); 598 ev_periodic_set (w, at, interval);
599
579 if (active) ev_periodic_start (w); 600 if (active) ev_periodic_start (w);
580} 601}
581 602
582MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 603MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
583 604
626void set (struct ev_child *w, int pid) 647void set (struct ev_child *w, int pid)
627 CODE: 648 CODE:
628{ 649{
629 int active = w->active; 650 int active = w->active;
630 if (active) ev_child_stop (w); 651 if (active) ev_child_stop (w);
652
631 ev_child_set (w, pid); 653 ev_child_set (w, pid);
654
632 if (active) ev_child_start (w); 655 if (active) ev_child_start (w);
633} 656}
634 657
658int pid (struct ev_child *w, int new_pid = 0)
659 CODE:
660{
661 RETVAL = newSVsv (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
635int status (struct ev_child *w) 677int status (struct ev_child *w)
636 CODE: 678 CODE:
637 RETVAL = w->status; 679 RETVAL = w->status;
638 OUTPUT: 680 OUTPUT:
639 RETVAL 681 RETVAL
640
641#if 0
642 682
643MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ 683MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_
644 684
645BOOT: 685BOOT:
646{ 686{
729 769
730void evdns_search_add (char *domain) 770void evdns_search_add (char *domain)
731 771
732void evdns_search_ndots_set (int ndots) 772void evdns_search_ndots_set (int ndots)
733 773
774#if 0
734 775
735MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ 776MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_
736 777
737BOOT: 778BOOT:
738{ 779{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines