… | |
… | |
562 | ev_set_syserr_cb (cb); |
562 | ev_set_syserr_cb (cb); |
563 | } |
563 | } |
564 | |
564 | |
565 | #if EV_MULTIPLICITY |
565 | #if EV_MULTIPLICITY |
566 | #define EV_CONSTRUCT(cppstem,cstem) \ |
566 | #define EV_CONSTRUCT(cppstem,cstem) \ |
567 | (EV_PX = get_default_loop ()) EV_NOEXCEPT \ |
567 | (EV_PX = get_default_loop ()) EV_NOEXCEPT \ |
568 | : base<ev_ ## cstem, cppstem> (EV_A) \ |
568 | : base<ev_ ## cstem, cppstem> (EV_A) \ |
569 | { \ |
569 | { \ |
570 | } |
570 | } |
571 | #else |
571 | #else |
572 | #define EV_CONSTRUCT(cppstem,cstem) \ |
572 | #define EV_CONSTRUCT(cppstem,cstem) \ |
573 | () EV_NOEXCEPT \ |
573 | () EV_NOEXCEPT \ |
574 | { \ |
574 | { \ |
575 | } |
575 | } |
576 | #endif |
576 | #endif |
577 | |
577 | |
578 | /* using a template here would require quite a few more lines, |
578 | /* using a template here would require quite a few more lines, |
579 | * so a macro solution was chosen */ |
579 | * so a macro solution was chosen */ |
580 | #define EV_BEGIN_WATCHER(cppstem,cstem) \ |
580 | #define EV_BEGIN_WATCHER(cppstem,cstem) \ |
581 | \ |
581 | \ |
582 | struct cppstem : base<ev_ ## cstem, cppstem> \ |
582 | struct cppstem : base<ev_ ## cstem, cppstem> \ |
583 | { \ |
583 | { \ |
584 | void start () EV_NOEXCEPT \ |
584 | void start () EV_NOEXCEPT \ |
585 | { \ |
585 | { \ |
586 | ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
586 | ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
587 | } \ |
587 | } \ |
588 | \ |
588 | \ |
589 | void stop () EV_NOEXCEPT \ |
589 | void stop () EV_NOEXCEPT \ |
590 | { \ |
590 | { \ |
591 | ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
591 | ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
592 | } \ |
592 | } \ |
593 | \ |
593 | \ |
594 | cppstem EV_CONSTRUCT(cppstem,cstem) \ |
594 | cppstem EV_CONSTRUCT(cppstem,cstem) \ |
595 | \ |
595 | \ |
596 | ~cppstem () EV_NOEXCEPT \ |
596 | ~cppstem () EV_NOEXCEPT \ |
597 | { \ |
597 | { \ |
598 | stop (); \ |
598 | stop (); \ |
599 | } \ |
599 | } \ |
600 | \ |
600 | \ |
601 | using base<ev_ ## cstem, cppstem>::set; \ |
601 | using base<ev_ ## cstem, cppstem>::set; \ |
… | |
… | |
622 | |
622 | |
623 | void set (int events) EV_NOEXCEPT |
623 | void set (int events) EV_NOEXCEPT |
624 | { |
624 | { |
625 | int active = is_active (); |
625 | int active = is_active (); |
626 | if (active) stop (); |
626 | if (active) stop (); |
627 | ev_io_set (static_cast<ev_io *>(this), fd, events); |
627 | ev_io_modify (static_cast<ev_io *>(this), events); |
628 | if (active) start (); |
628 | if (active) start (); |
629 | } |
629 | } |
630 | |
630 | |
631 | void start (int fd, int events) EV_NOEXCEPT |
631 | void start (int fd, int events) EV_NOEXCEPT |
632 | { |
632 | { |