… | |
… | |
62 | } |
62 | } |
63 | |
63 | |
64 | #define newSVtimer(timer) iom_new_ref ((timer)->self, IOM_CLASS "::timer") |
64 | #define newSVtimer(timer) iom_new_ref ((timer)->self, IOM_CLASS "::timer") |
65 | #define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::timer") |
65 | #define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::timer") |
66 | |
66 | |
67 | struct timer : perl_watcher, time_watcher |
67 | struct timer : perl_watcher, ev::timer |
68 | { |
68 | { |
69 | tstamp interval; |
|
|
70 | |
|
|
71 | timer () |
69 | timer () |
72 | : time_watcher (this, &timer::execute) |
70 | : ev::timer (this, &timer::execute) |
73 | { |
71 | { |
74 | } |
72 | } |
75 | |
73 | |
76 | void execute (time_watcher &w) |
74 | void execute (ev::timer &w, int revents) |
77 | { |
75 | { |
78 | if (interval) |
|
|
79 | start (at + interval); |
|
|
80 | |
|
|
81 | invoke (IOM_CLASS "::timer", newSVtimer (this)); |
76 | invoke (IOM_CLASS "::timer", newSVtimer (this)); |
82 | } |
77 | } |
83 | }; |
78 | }; |
84 | |
79 | |
85 | #define newSViow(iow) iom_new_ref ((iow)->self, IOM_CLASS "::iow") |
80 | #define newSViow(iow) iom_new_ref ((iow)->self, IOM_CLASS "::iow") |
86 | #define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iow") |
81 | #define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iow") |
87 | |
82 | |
88 | struct iow : perl_watcher, io_watcher |
83 | struct iow : perl_watcher, ev::io |
89 | { |
84 | { |
90 | iow () |
85 | iow () |
91 | : io_watcher (this, &iow::execute) |
86 | : ev::io (this, &iow::execute) |
92 | { |
87 | { |
93 | } |
88 | } |
94 | |
89 | |
95 | void execute (io_watcher &w, short revents) |
90 | void execute (ev::io &w, int revents) |
96 | { |
91 | { |
97 | invoke (IOM_CLASS "::iow", newSViow (this), revents); |
92 | invoke (IOM_CLASS "::iow", newSViow (this), revents); |
98 | } |
93 | } |
99 | }; |
94 | }; |
100 | |
95 | |
101 | #define newSViw(iw) iom_new_ref ((iw)->self, IOM_CLASS "::iw") |
96 | #define newSViw(iw) iom_new_ref ((iw)->self, IOM_CLASS "::iw") |
102 | #define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iw") |
97 | #define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iw") |
103 | |
98 | |
104 | struct iw : perl_watcher, idle_watcher |
99 | struct iw : perl_watcher, ev::idle |
105 | { |
100 | { |
106 | iw () |
101 | iw () |
107 | : idle_watcher (this, &iw::execute) |
102 | : ev::idle (this, &iw::execute) |
108 | { |
103 | { |
109 | } |
104 | } |
110 | |
105 | |
111 | void execute (idle_watcher &w) |
106 | void execute (ev::idle &w, int revents) |
112 | { |
107 | { |
113 | invoke (IOM_CLASS "::iw", newSViw (this)); |
108 | invoke (IOM_CLASS "::iw", newSViw (this)); |
114 | } |
109 | } |
115 | }; |
110 | }; |
116 | |
111 | |
117 | #define newSVpw(pw) iom_new_ref ((pw)->self, IOM_CLASS "::pw") |
112 | #define newSVpw(pw) iom_new_ref ((pw)->self, IOM_CLASS "::pw") |
118 | #define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::pw") |
113 | #define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::pw") |
119 | |
114 | |
120 | struct pw : perl_watcher, child_watcher |
115 | struct pw : perl_watcher, ev::child |
121 | { |
116 | { |
122 | pw () |
117 | pw () |
123 | : child_watcher (this, &pw::execute) |
118 | : ev::child (this, &pw::execute) |
124 | { |
119 | { |
125 | } |
120 | } |
126 | |
121 | |
127 | void execute (child_watcher &w, int status) |
122 | void execute (ev::child &w, int revents) |
128 | { |
123 | { |
129 | invoke (IOM_CLASS "::pw", newSVpw (this), status); |
124 | invoke (IOM_CLASS "::pw", newSVpw (this), w.rstatus); |
130 | } |
125 | } |
131 | }; |
126 | }; |
132 | |
127 | |