… | |
… | |
70 | STAT = EV_STAT, |
70 | STAT = EV_STAT, |
71 | IDLE = EV_IDLE, |
71 | IDLE = EV_IDLE, |
72 | CHECK = EV_CHECK, |
72 | CHECK = EV_CHECK, |
73 | PREPARE = EV_PREPARE, |
73 | PREPARE = EV_PREPARE, |
74 | FORK = EV_FORK, |
74 | FORK = EV_FORK, |
|
|
75 | ASYNC = EV_ASYNC, |
75 | EMBED = EV_EMBED, |
76 | EMBED = EV_EMBED, |
76 | ERROR = EV_ERROR, |
77 | ERROR = EV_ERROR, |
77 | }; |
78 | }; |
78 | |
79 | |
79 | enum |
80 | enum |
… | |
… | |
561 | ev_set_syserr_cb (cb); |
562 | ev_set_syserr_cb (cb); |
562 | } |
563 | } |
563 | |
564 | |
564 | #if EV_MULTIPLICITY |
565 | #if EV_MULTIPLICITY |
565 | #define EV_CONSTRUCT(cppstem,cstem) \ |
566 | #define EV_CONSTRUCT(cppstem,cstem) \ |
566 | (EV_PX = get_default_loop ()) throw () \ |
567 | (EV_PX = get_default_loop ()) throw () \ |
567 | : base<ev_ ## cstem, cppstem> (EV_A) \ |
568 | : base<ev_ ## cstem, cppstem> (EV_A) \ |
568 | { \ |
569 | { \ |
569 | } |
570 | } |
570 | #else |
571 | #else |
571 | #define EV_CONSTRUCT(cppstem,cstem) \ |
572 | #define EV_CONSTRUCT(cppstem,cstem) \ |
572 | () throw () \ |
573 | () throw () \ |
573 | { \ |
574 | { \ |
574 | } |
575 | } |
575 | #endif |
576 | #endif |
576 | |
577 | |
577 | /* using a template here would require quite a bit more lines, |
578 | /* using a template here would require quite a bit more lines, |
578 | * so a macro solution was chosen */ |
579 | * so a macro solution was chosen */ |
579 | #define EV_BEGIN_WATCHER(cppstem,cstem) \ |
580 | #define EV_BEGIN_WATCHER(cppstem,cstem) \ |
580 | \ |
581 | \ |
581 | struct cppstem : base<ev_ ## cstem, cppstem> \ |
582 | struct cppstem : base<ev_ ## cstem, cppstem> \ |
582 | { \ |
583 | { \ |
583 | void start () throw () \ |
584 | void start () throw () \ |
584 | { \ |
585 | { \ |
585 | ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
586 | ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
586 | } \ |
587 | } \ |
587 | \ |
588 | \ |
588 | void stop () throw () \ |
589 | void stop () throw () \ |
589 | { \ |
590 | { \ |
590 | ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
591 | ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
591 | } \ |
592 | } \ |
592 | \ |
593 | \ |
593 | cppstem EV_CONSTRUCT(cppstem,cstem) \ |
594 | cppstem EV_CONSTRUCT(cppstem,cstem) \ |
594 | \ |
595 | \ |
595 | ~cppstem () throw () \ |
596 | ~cppstem () throw () \ |
596 | { \ |
597 | { \ |
597 | stop (); \ |
598 | stop (); \ |
598 | } \ |
599 | } \ |
599 | \ |
600 | \ |
600 | using base<ev_ ## cstem, cppstem>::set; \ |
601 | using base<ev_ ## cstem, cppstem>::set; \ |
601 | \ |
602 | \ |
602 | private: \ |
603 | private: \ |
603 | \ |
604 | \ |
604 | cppstem (const cppstem &o); \ |
605 | cppstem (const cppstem &o); \ |
605 | \ |
606 | \ |
606 | cppstem & operator =(const cppstem &o); \ |
607 | cppstem &operator =(const cppstem &o); \ |
607 | \ |
608 | \ |
608 | public: |
609 | public: |
609 | |
610 | |
610 | #define EV_END_WATCHER(cppstem,cstem) \ |
611 | #define EV_END_WATCHER(cppstem,cstem) \ |
611 | }; |
612 | }; |
… | |
… | |
746 | void set () throw () { } |
747 | void set () throw () { } |
747 | EV_END_WATCHER (check, check) |
748 | EV_END_WATCHER (check, check) |
748 | |
749 | |
749 | #if EV_EMBED_ENABLE |
750 | #if EV_EMBED_ENABLE |
750 | EV_BEGIN_WATCHER (embed, embed) |
751 | EV_BEGIN_WATCHER (embed, embed) |
|
|
752 | void set (struct ev_loop *embedded_loop) throw () |
|
|
753 | { |
|
|
754 | int active = is_active (); |
|
|
755 | if (active) stop (); |
|
|
756 | ev_embed_set (static_cast<ev_embed *>(this), embedded_loop); |
|
|
757 | if (active) start (); |
|
|
758 | } |
|
|
759 | |
751 | void start (struct ev_loop *embedded_loop) throw () |
760 | void start (struct ev_loop *embedded_loop) throw () |
752 | { |
761 | { |
753 | stop (); |
762 | set (embedded_loop); |
754 | ev_embed_set (static_cast<ev_embed *>(this), embedded_loop); |
|
|
755 | start (); |
763 | start (); |
756 | } |
764 | } |
757 | |
765 | |
758 | void sweep () |
766 | void sweep () |
759 | { |
767 | { |
… | |
… | |
764 | |
772 | |
765 | #if EV_FORK_ENABLE |
773 | #if EV_FORK_ENABLE |
766 | EV_BEGIN_WATCHER (fork, fork) |
774 | EV_BEGIN_WATCHER (fork, fork) |
767 | void set () throw () { } |
775 | void set () throw () { } |
768 | EV_END_WATCHER (fork, fork) |
776 | EV_END_WATCHER (fork, fork) |
|
|
777 | #endif |
|
|
778 | |
|
|
779 | #if EV_ASYNC_ENABLE |
|
|
780 | EV_BEGIN_WATCHER (async, async) |
|
|
781 | void set () throw () { } |
|
|
782 | |
|
|
783 | void send () throw () |
|
|
784 | { |
|
|
785 | ev_async_send (EV_A_ static_cast<ev_async *>(this)); |
|
|
786 | } |
|
|
787 | |
|
|
788 | bool async_pending () throw () |
|
|
789 | { |
|
|
790 | return ev_async_pending (static_cast<ev_async *>(this)); |
|
|
791 | } |
|
|
792 | EV_END_WATCHER (async, async) |
769 | #endif |
793 | #endif |
770 | |
794 | |
771 | #undef EV_PX |
795 | #undef EV_PX |
772 | #undef EV_PX_ |
796 | #undef EV_PX_ |
773 | #undef EV_CONSTRUCT |
797 | #undef EV_CONSTRUCT |