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

Comparing EV/EV.xs (file contents):
Revision 1.32 by root, Thu Nov 1 11:11:39 2007 UTC vs.
Revision 1.35 by root, Thu Nov 1 13:33:12 2007 UTC

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 7#define TIMEOUT_NONE HUGE_VAL
8#define EV_USE_EPOLL 1
9 8
10#define EV_PROTOTYPES 1 9#define EV_PROTOTYPES 1
11#include "EV/EVAPI.h" 10#include "EV/EVAPI.h"
12 11
13#include "libev/ev.c" 12#include "libev/ev.c"
81 w->fh = 0; 80 w->fh = 0;
82 w->cb_sv = newSVsv (cb_sv); 81 w->cb_sv = newSVsv (cb_sv);
83 w->self = self; 82 w->self = self;
84 83
85 return (void *)w; 84 return (void *)w;
85}
86
87static void *
88e_destroy (void *w_)
89{
90 struct ev_watcher *w = w_;
91
92 SvREFCNT_dec (w->fh ); w->fh = 0;
93 SvREFCNT_dec (w->cb_sv); w->cb_sv = 0;
86} 94}
87 95
88static SV * 96static SV *
89e_bless (struct ev_watcher *w, HV *stash) 97e_bless (struct ev_watcher *w, HV *stash)
90{ 98{
291 evapi.child_stop = ev_child_stop; 299 evapi.child_stop = ev_child_stop;
292 300
293 sv_setiv (sv, (IV)&evapi); 301 sv_setiv (sv, (IV)&evapi);
294 SvREADONLY_on (sv); 302 SvREADONLY_on (sv);
295 } 303 }
304
305 pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child);
296} 306}
297 307
298NV ev_now () 308NV ev_now ()
299 CODE: 309 CODE:
300 RETVAL = ev_now; 310 RETVAL = ev_now;
436void ev_io_stop (struct ev_io *w) 446void ev_io_stop (struct ev_io *w)
437 447
438void DESTROY (struct ev_io *w) 448void DESTROY (struct ev_io *w)
439 CODE: 449 CODE:
440 ev_io_stop (w); 450 ev_io_stop (w);
451 e_destroy (w);
441 452
442void set (struct ev_io *w, SV *fh, int events) 453void set (struct ev_io *w, SV *fh, int events)
443 CODE: 454 CODE:
444{ 455{
445 int active = w->active; 456 int active = w->active;
498void ev_signal_stop (struct ev_signal *w) 509void ev_signal_stop (struct ev_signal *w)
499 510
500void DESTROY (struct ev_signal *w) 511void DESTROY (struct ev_signal *w)
501 CODE: 512 CODE:
502 ev_signal_stop (w); 513 ev_signal_stop (w);
514 e_destroy (w);
503 515
504void set (struct ev_signal *w, SV *signal = 0) 516void set (struct ev_signal *w, SV *signal = 0)
505 CODE: 517 CODE:
506{ 518{
507 Signal signum = sv_signum (signal); /* may croak here */ 519 Signal signum = sv_signum (signal); /* may croak here */
527 CHECK_REPEAT (w->repeat); 539 CHECK_REPEAT (w->repeat);
528 540
529void DESTROY (struct ev_timer *w) 541void DESTROY (struct ev_timer *w)
530 CODE: 542 CODE:
531 ev_timer_stop (w); 543 ev_timer_stop (w);
544 e_destroy (w);
532 545
533void set (struct ev_timer *w, NV after, NV repeat = 0.) 546void set (struct ev_timer *w, NV after, NV repeat = 0.)
534 INIT: 547 INIT:
535 CHECK_REPEAT (repeat); 548 CHECK_REPEAT (repeat);
536 CODE: 549 CODE:
550void ev_periodic_stop (struct ev_periodic *w) 563void ev_periodic_stop (struct ev_periodic *w)
551 564
552void DESTROY (struct ev_periodic *w) 565void DESTROY (struct ev_periodic *w)
553 CODE: 566 CODE:
554 ev_periodic_stop (w); 567 ev_periodic_stop (w);
568 e_destroy (w);
555 569
556void set (struct ev_periodic *w, NV at, NV interval = 0.) 570void set (struct ev_periodic *w, NV at, NV interval = 0.)
557 INIT: 571 INIT:
558 CHECK_REPEAT (interval); 572 CHECK_REPEAT (interval);
559 CODE: 573 CODE:
571void ev_idle_stop (struct ev_idle *w) 585void ev_idle_stop (struct ev_idle *w)
572 586
573void DESTROY (struct ev_idle *w) 587void DESTROY (struct ev_idle *w)
574 CODE: 588 CODE:
575 ev_idle_stop (w); 589 ev_idle_stop (w);
590 e_destroy (w);
576 591
577MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ 592MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_
578 593
579void ev_prepare_start (struct ev_prepare *w) 594void ev_prepare_start (struct ev_prepare *w)
580 595
581void ev_prepare_stop (struct ev_prepare *w) 596void ev_prepare_stop (struct ev_prepare *w)
582 597
583void DESTROY (struct ev_prepare *w) 598void DESTROY (struct ev_prepare *w)
584 CODE: 599 CODE:
585 ev_prepare_stop (w); 600 ev_prepare_stop (w);
601 e_destroy (w);
586 602
587MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ 603MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_
588 604
589void ev_check_start (struct ev_check *w) 605void ev_check_start (struct ev_check *w)
590 606
591void ev_check_stop (struct ev_check *w) 607void ev_check_stop (struct ev_check *w)
592 608
593void DESTROY (struct ev_check *w) 609void DESTROY (struct ev_check *w)
594 CODE: 610 CODE:
595 ev_check_stop (w); 611 ev_check_stop (w);
612 e_destroy (w);
596 613
597MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ 614MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
598 615
599void ev_child_start (struct ev_child *w) 616void ev_child_start (struct ev_child *w)
600 617
601void ev_child_stop (struct ev_child *w) 618void ev_child_stop (struct ev_child *w)
602 619
603void DESTROY (struct ev_child *w) 620void DESTROY (struct ev_child *w)
604 CODE: 621 CODE:
605 ev_child_stop (w); 622 ev_child_stop (w);
623 e_destroy (w);
606 624
607void set (struct ev_child *w, int pid) 625void set (struct ev_child *w, int pid)
608 CODE: 626 CODE:
609{ 627{
610 int active = w->active; 628 int active = w->active;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines