1 | #include "EXTERN.h" |
1 | #include "EXTERN.h" |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | /*#include <netinet/in.h>*/ |
5 | /* fix perl api breakage */ |
|
|
6 | #undef signal |
|
|
7 | #undef sigaction |
6 | |
8 | |
7 | #define TIMEOUT_NONE HUGE_VAL |
9 | #include "schmorp.h" |
8 | |
10 | |
|
|
11 | /* old API compatibility */ |
|
|
12 | static int |
|
|
13 | sv_fileno (SV *fh) |
|
|
14 | { |
|
|
15 | return s_fileno (fh, 0); |
|
|
16 | } |
|
|
17 | |
|
|
18 | #define EV_STANDALONE 1 |
9 | #define EV_PROTOTYPES 1 |
19 | #define EV_PROTOTYPES 1 |
|
|
20 | #define EV_USE_CLOCK_SYSCALL 0 /* as long as we need pthreads anyways... */ |
|
|
21 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
|
|
22 | #define EV_USE_FLOOR 1 |
|
|
23 | #define EV_H <ev.h> |
|
|
24 | #define EV_CONFIG_H error |
10 | #include "EV/EVAPI.h" |
25 | #include "EV/EVAPI.h" |
11 | |
26 | |
|
|
27 | #define EV_SELECT_IS_WINSOCKET 0 |
|
|
28 | #ifdef _WIN32 |
|
|
29 | # define EV_SELECT_USE_FD_SET 0 |
|
|
30 | # define NFDBITS PERL_NFDBITS |
|
|
31 | # define fd_mask Perl_fd_mask |
|
|
32 | #endif |
|
|
33 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
12 | #include "libev/ev.c" |
34 | #include "libev/ev.c" |
13 | #include "libev/event.h" |
|
|
14 | #include "libev/event.c" |
|
|
15 | |
35 | |
16 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
36 | #if !defined(_WIN32) && !defined(_MINIX) |
17 | #define HAVE_STRUCT_IN6_ADDR 1 |
37 | # include <pthread.h> |
18 | #define HAVE_STRTOK_R 1 |
38 | #endif |
19 | #include "libev/evdns.c" |
39 | |
|
|
40 | #define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop)) |
|
|
41 | #define e_flags(w) ((ev_watcher *)(w))->e_flags |
|
|
42 | #define e_self(w) ((ev_watcher *)(w))->self |
|
|
43 | #define e_fh(w) ((ev_watcher *)(w))->fh |
|
|
44 | #define e_data(w) ((ev_watcher *)(w))->data |
|
|
45 | |
|
|
46 | #define WFLAG_KEEPALIVE 1 |
|
|
47 | #define WFLAG_UNREFED 2 /* has been unref'ed */ |
|
|
48 | |
|
|
49 | #define UNREF(w) \ |
|
|
50 | if (!(e_flags (w) & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \ |
|
|
51 | && ev_is_active (w)) \ |
|
|
52 | { \ |
|
|
53 | ev_unref (e_loop (w)); \ |
|
|
54 | e_flags (w) |= WFLAG_UNREFED; \ |
|
|
55 | } |
|
|
56 | |
|
|
57 | #define REF(w) \ |
|
|
58 | if (e_flags (w) & WFLAG_UNREFED) \ |
|
|
59 | { \ |
|
|
60 | e_flags (w) &= ~WFLAG_UNREFED; \ |
|
|
61 | ev_ref (e_loop (w)); \ |
|
|
62 | } |
|
|
63 | |
|
|
64 | #define START(type,w) \ |
|
|
65 | do { \ |
|
|
66 | ev_ ## type ## _start (e_loop (w), w); \ |
|
|
67 | UNREF (w); \ |
|
|
68 | } while (0) |
|
|
69 | |
|
|
70 | #define STOP(type,w) \ |
|
|
71 | do { \ |
|
|
72 | REF (w); \ |
|
|
73 | ev_ ## type ## _stop (e_loop (w), w); \ |
|
|
74 | } while (0) |
|
|
75 | |
|
|
76 | #define RESET(type,w,seta) \ |
|
|
77 | do { \ |
|
|
78 | int active = ev_is_active (w); \ |
|
|
79 | if (active) STOP (type, w); \ |
|
|
80 | ev_ ## type ## _set seta; \ |
|
|
81 | if (active) START (type, w); \ |
|
|
82 | } while (0) |
20 | |
83 | |
21 | typedef int Signal; |
84 | typedef int Signal; |
22 | |
85 | |
|
|
86 | /* horrible... */ |
|
|
87 | #define CHECK_SIGNAL_CAN_START(w) \ |
|
|
88 | do { \ |
|
|
89 | /* dive into the internals of libev to avoid aborting in libev */ \ |
|
|
90 | if (signals [(w)->signum - 1].loop \ |
|
|
91 | && signals [(w)->signum - 1].loop != e_loop (w)) \ |
|
|
92 | croak ("unable to start signal watcher, signal %d already registered in another loop", w->signum); \ |
|
|
93 | } while (0) |
|
|
94 | |
|
|
95 | #define START_SIGNAL(w) \ |
|
|
96 | do { \ |
|
|
97 | CHECK_SIGNAL_CAN_START (w); \ |
|
|
98 | START (signal, w); \ |
|
|
99 | } while (0) \ |
|
|
100 | |
|
|
101 | #define RESET_SIGNAL(w,seta) \ |
|
|
102 | do { \ |
|
|
103 | int active = ev_is_active (w); \ |
|
|
104 | if (active) STOP (signal, w); \ |
|
|
105 | ev_ ## signal ## _set seta; \ |
|
|
106 | if (active) START_SIGNAL (w); \ |
|
|
107 | } while (0) |
|
|
108 | |
|
|
109 | static SV *default_loop_sv; |
|
|
110 | |
23 | static struct EVAPI evapi; |
111 | static struct EVAPI evapi; |
24 | |
112 | |
25 | static HV |
113 | static HV |
|
|
114 | *stash_loop, |
26 | *stash_watcher, |
115 | *stash_watcher, |
27 | *stash_io, |
116 | *stash_io, |
28 | *stash_timer, |
117 | *stash_timer, |
29 | *stash_periodic, |
118 | *stash_periodic, |
30 | *stash_signal, |
119 | *stash_signal, |
|
|
120 | *stash_child, |
|
|
121 | *stash_stat, |
31 | *stash_idle, |
122 | *stash_idle, |
32 | *stash_prepare, |
123 | *stash_prepare, |
33 | *stash_check, |
124 | *stash_check, |
34 | *stash_child; |
125 | *stash_embed, |
35 | |
126 | *stash_fork, |
36 | static int |
127 | *stash_cleanup, |
37 | sv_signum (SV *sig) |
128 | *stash_async; |
38 | { |
|
|
39 | int signum; |
|
|
40 | |
|
|
41 | SvGETMAGIC (sig); |
|
|
42 | |
|
|
43 | for (signum = 1; signum < SIG_SIZE; ++signum) |
|
|
44 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
|
|
45 | return signum; |
|
|
46 | |
|
|
47 | if (SvIV (sig) > 0) |
|
|
48 | return SvIV (sig); |
|
|
49 | |
|
|
50 | return -1; |
|
|
51 | } |
|
|
52 | |
129 | |
53 | ///////////////////////////////////////////////////////////////////////////// |
130 | ///////////////////////////////////////////////////////////////////////////// |
54 | // Event |
131 | // Event |
55 | |
132 | |
56 | static void e_cb (struct ev_watcher *w, int revents); |
133 | static void e_cb (EV_P_ ev_watcher *w, int revents); |
57 | |
|
|
58 | static int |
|
|
59 | sv_fileno (SV *fh) |
|
|
60 | { |
|
|
61 | SvGETMAGIC (fh); |
|
|
62 | |
|
|
63 | if (SvROK (fh)) |
|
|
64 | fh = SvRV (fh); |
|
|
65 | |
|
|
66 | if (SvTYPE (fh) == SVt_PVGV) |
|
|
67 | return PerlIO_fileno (IoIFP (sv_2io (fh))); |
|
|
68 | |
|
|
69 | if ((SvIV (fh) >= 0) && (SvIV (fh) < 0x7ffffff)) |
|
|
70 | return SvIV (fh); |
|
|
71 | |
|
|
72 | return -1; |
|
|
73 | } |
|
|
74 | |
134 | |
75 | static void * |
135 | static void * |
76 | e_new (int size, SV *cb_sv) |
136 | e_new (int size, SV *cb_sv, SV *loop) |
77 | { |
137 | { |
|
|
138 | SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0; |
78 | struct ev_watcher *w; |
139 | ev_watcher *w; |
79 | SV *self = NEWSV (0, size); |
140 | SV *self = NEWSV (0, size); |
80 | SvPOK_only (self); |
141 | SvPOK_only (self); |
81 | SvCUR_set (self, size); |
142 | SvCUR_set (self, size); |
82 | |
143 | |
83 | w = (struct ev_watcher *)SvPVX (self); |
144 | w = (ev_watcher *)SvPVX (self); |
84 | |
145 | |
85 | ev_watcher_init (w, e_cb); |
146 | ev_init (w, cv ? e_cb : 0); |
86 | |
147 | |
|
|
148 | w->loop = SvREFCNT_inc (SvRV (loop)); |
|
|
149 | w->e_flags = WFLAG_KEEPALIVE; |
|
|
150 | w->data = 0; |
87 | w->fh = 0; |
151 | w->fh = 0; |
88 | w->cb_sv = newSVsv (cb_sv); |
152 | w->cb_sv = SvREFCNT_inc (cv); |
89 | w->self = self; |
153 | w->self = self; |
90 | |
154 | |
91 | return (void *)w; |
155 | return (void *)w; |
92 | } |
156 | } |
93 | |
157 | |
94 | static void * |
158 | static void |
95 | e_destroy (void *w_) |
159 | e_destroy (void *w_) |
96 | { |
160 | { |
97 | struct ev_watcher *w = w_; |
161 | ev_watcher *w = (ev_watcher *)w_; |
98 | |
162 | |
|
|
163 | SvREFCNT_dec (w->loop ); w->loop = 0; |
99 | SvREFCNT_dec (w->fh ); w->fh = 0; |
164 | SvREFCNT_dec (w->fh ); w->fh = 0; |
100 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
165 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
|
|
166 | SvREFCNT_dec (w->data ); w->data = 0; |
101 | } |
167 | } |
102 | |
168 | |
103 | static SV * |
169 | static SV * |
104 | e_bless (struct ev_watcher *w, HV *stash) |
170 | e_bless (ev_watcher *w, HV *stash) |
105 | { |
171 | { |
106 | SV *rv; |
172 | SV *rv; |
107 | |
173 | |
108 | if (SvOBJECT (w->self)) |
174 | if (SvOBJECT (w->self)) |
109 | rv = newRV_inc (w->self); |
175 | rv = newRV_inc (w->self); |
… | |
… | |
115 | } |
181 | } |
116 | |
182 | |
117 | return rv; |
183 | return rv; |
118 | } |
184 | } |
119 | |
185 | |
|
|
186 | static SV *sv_self_cache, *sv_events_cache; |
|
|
187 | |
120 | static void |
188 | static void |
121 | e_cb (struct ev_watcher *w, int revents) |
189 | e_cb (EV_P_ ev_watcher *w, int revents) |
122 | { |
190 | { |
123 | dSP; |
191 | dSP; |
124 | I32 mark = SP - PL_stack_base; |
192 | I32 mark = SP - PL_stack_base; |
125 | SV *sv_self, *sv_events, *sv_status = 0; |
193 | SV *sv_self, *sv_events; |
126 | static SV *sv_events_cache; |
|
|
127 | |
194 | |
|
|
195 | /* libev might have stopped the watcher */ |
|
|
196 | if (expect_false (w->e_flags & WFLAG_UNREFED) |
|
|
197 | && !ev_is_active (w)) |
|
|
198 | REF (w); |
|
|
199 | |
|
|
200 | if (expect_true (sv_self_cache)) |
|
|
201 | { |
|
|
202 | sv_self = sv_self_cache; sv_self_cache = 0; |
|
|
203 | SvRV_set (sv_self, SvREFCNT_inc_NN (w->self)); |
|
|
204 | } |
|
|
205 | else |
|
|
206 | { |
128 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
207 | sv_self = newRV_inc (w->self); /* e_self (w) MUST be blessed by now */ |
|
|
208 | SvREADONLY_on (sv_self); |
|
|
209 | } |
|
|
210 | |
|
|
211 | if (expect_true (sv_events_cache)) |
|
|
212 | { |
|
|
213 | sv_events = sv_events_cache; sv_events_cache = 0; |
|
|
214 | SvIV_set (sv_events, revents); |
|
|
215 | SvIOK_only (sv_events); |
|
|
216 | } |
|
|
217 | else |
|
|
218 | { |
|
|
219 | sv_events = newSViv (revents); |
|
|
220 | SvREADONLY_on (sv_events); |
|
|
221 | } |
|
|
222 | |
|
|
223 | PUSHMARK (SP); |
|
|
224 | EXTEND (SP, 2); |
|
|
225 | PUSHs (sv_self); |
|
|
226 | PUSHs (sv_events); |
|
|
227 | |
|
|
228 | PUTBACK; |
|
|
229 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
|
|
230 | |
|
|
231 | if (expect_false (SvREFCNT (sv_self) != 1 || sv_self_cache)) |
|
|
232 | SvREFCNT_dec (sv_self); |
|
|
233 | else |
|
|
234 | { |
|
|
235 | SvREFCNT_dec (SvRV (sv_self)); |
|
|
236 | SvRV_set (sv_self, &PL_sv_undef); |
|
|
237 | sv_self_cache = sv_self; |
|
|
238 | } |
|
|
239 | |
|
|
240 | if (expect_false (SvREFCNT (sv_events) != 1 || sv_events_cache)) |
|
|
241 | SvREFCNT_dec (sv_events); |
|
|
242 | else |
|
|
243 | sv_events_cache = sv_events; |
|
|
244 | |
|
|
245 | if (expect_false (SvTRUE (ERRSV))) |
|
|
246 | { |
|
|
247 | SPAGAIN; |
|
|
248 | PUSHMARK (SP); |
|
|
249 | PUTBACK; |
|
|
250 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
|
|
251 | } |
|
|
252 | |
|
|
253 | SP = PL_stack_base + mark; |
|
|
254 | PUTBACK; |
|
|
255 | } |
|
|
256 | |
|
|
257 | static void |
|
|
258 | e_once_cb (int revents, void *arg) |
|
|
259 | { |
|
|
260 | dSP; |
|
|
261 | I32 mark = SP - PL_stack_base; |
|
|
262 | SV *sv_events; |
129 | |
263 | |
130 | if (sv_events_cache) |
264 | if (sv_events_cache) |
131 | { |
265 | { |
132 | sv_events = sv_events_cache; sv_events_cache = 0; |
266 | sv_events = sv_events_cache; sv_events_cache = 0; |
133 | SvIV_set (sv_events, revents); |
267 | SvIV_set (sv_events, revents); |
134 | } |
268 | } |
135 | else |
269 | else |
136 | sv_events = newSViv (revents); |
270 | sv_events = newSViv (revents); |
137 | |
271 | |
138 | PUSHMARK (SP); |
272 | PUSHMARK (SP); |
139 | EXTEND (SP, 2); |
|
|
140 | PUSHs (sv_self); |
|
|
141 | PUSHs (sv_events); |
273 | XPUSHs (sv_events); |
142 | |
|
|
143 | if (revents & EV_CHILD) |
|
|
144 | XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status)); |
|
|
145 | |
274 | |
146 | PUTBACK; |
275 | PUTBACK; |
147 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
276 | call_sv ((SV *)arg, G_DISCARD | G_VOID | G_EVAL); |
148 | SP = PL_stack_base + mark; PUTBACK; |
|
|
149 | |
277 | |
150 | SvREFCNT_dec (sv_self); |
278 | SvREFCNT_dec ((SV *)arg); |
151 | SvREFCNT_dec (sv_status); |
|
|
152 | |
279 | |
153 | if (sv_events_cache) |
280 | if (sv_events_cache) |
154 | SvREFCNT_dec (sv_events); |
281 | SvREFCNT_dec (sv_events); |
155 | else |
282 | else |
156 | sv_events_cache = sv_events; |
283 | sv_events_cache = sv_events; |
|
|
284 | |
|
|
285 | if (SvTRUE (ERRSV)) |
|
|
286 | { |
|
|
287 | SPAGAIN; |
|
|
288 | PUSHMARK (SP); |
|
|
289 | PUTBACK; |
|
|
290 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
|
|
291 | } |
|
|
292 | |
|
|
293 | SP = PL_stack_base + mark; |
|
|
294 | PUTBACK; |
|
|
295 | } |
|
|
296 | |
|
|
297 | static ev_tstamp |
|
|
298 | e_periodic_cb (ev_periodic *w, ev_tstamp now) |
|
|
299 | { |
|
|
300 | ev_tstamp retval; |
|
|
301 | int count; |
|
|
302 | dSP; |
|
|
303 | |
|
|
304 | ENTER; |
|
|
305 | SAVETMPS; |
|
|
306 | |
|
|
307 | PUSHMARK (SP); |
|
|
308 | EXTEND (SP, 2); |
|
|
309 | PUSHs (newRV_inc (e_self (w))); /* e_self (w) MUST be blessed by now */ |
|
|
310 | PUSHs (newSVnv (now)); |
|
|
311 | |
|
|
312 | PUTBACK; |
|
|
313 | count = call_sv (w->fh, G_SCALAR | G_EVAL); |
|
|
314 | SPAGAIN; |
157 | |
315 | |
158 | if (SvTRUE (ERRSV)) |
316 | if (SvTRUE (ERRSV)) |
159 | { |
317 | { |
160 | PUSHMARK (SP); |
318 | PUSHMARK (SP); |
161 | PUTBACK; |
319 | PUTBACK; |
162 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
320 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
163 | SP = PL_stack_base + mark; PUTBACK; |
321 | SPAGAIN; |
164 | } |
322 | } |
165 | } |
|
|
166 | |
323 | |
167 | ///////////////////////////////////////////////////////////////////////////// |
324 | if (count > 0) |
168 | // DNS |
|
|
169 | |
|
|
170 | static void |
|
|
171 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
|
|
172 | { |
|
|
173 | dSP; |
|
|
174 | SV *cb = (SV *)arg; |
|
|
175 | |
|
|
176 | ENTER; |
|
|
177 | SAVETMPS; |
|
|
178 | PUSHMARK (SP); |
|
|
179 | EXTEND (SP, count + 3); |
|
|
180 | PUSHs (sv_2mortal (newSViv (result))); |
|
|
181 | |
|
|
182 | if (result == DNS_ERR_NONE && ttl >= 0) |
|
|
183 | { |
325 | { |
184 | int i; |
326 | retval = SvNV (TOPs); |
185 | |
327 | |
186 | PUSHs (sv_2mortal (newSViv (type))); |
328 | if (retval < now) |
187 | PUSHs (sv_2mortal (newSViv (ttl))); |
329 | retval = now; |
188 | |
|
|
189 | for (i = 0; i < count; ++i) |
|
|
190 | switch (type) |
|
|
191 | { |
|
|
192 | case DNS_IPv6_AAAA: |
|
|
193 | PUSHs (sv_2mortal (newSVpvn (i * 16 + (char *)addresses, 16))); |
|
|
194 | break; |
|
|
195 | case DNS_IPv4_A: |
|
|
196 | PUSHs (sv_2mortal (newSVpvn (i * 4 + (char *)addresses, 4))); |
|
|
197 | break; |
|
|
198 | case DNS_PTR: |
|
|
199 | PUSHs (sv_2mortal (newSVpv (*(char **)addresses, 0))); |
|
|
200 | break; |
|
|
201 | } |
|
|
202 | } |
330 | } |
203 | |
331 | else |
204 | PUTBACK; |
332 | retval = now; |
205 | call_sv (sv_2mortal (cb), G_DISCARD | G_VOID | G_EVAL); |
|
|
206 | |
333 | |
207 | FREETMPS; |
334 | FREETMPS; |
208 | |
|
|
209 | if (SvTRUE (ERRSV)) |
|
|
210 | { |
|
|
211 | PUSHMARK (SP); |
|
|
212 | PUTBACK; |
|
|
213 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
|
|
214 | } |
|
|
215 | |
|
|
216 | LEAVE; |
335 | LEAVE; |
|
|
336 | |
|
|
337 | return retval; |
217 | } |
338 | } |
218 | |
339 | |
219 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
340 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
220 | croak (# repeat " value must be >= 0"); |
341 | croak (# repeat " value must be >= 0"); |
221 | |
342 | |
222 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
343 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
223 | croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); |
344 | croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); |
224 | |
345 | |
|
|
346 | #define CHECK_SIG(sv,num) if ((num) < 0) \ |
|
|
347 | croak ("illegal signal number or name: %s", SvPV_nolen (sv)); |
|
|
348 | |
|
|
349 | static void |
|
|
350 | default_fork (void) |
|
|
351 | { |
|
|
352 | ev_loop_fork (EV_DEFAULT_UC); |
|
|
353 | } |
|
|
354 | |
225 | ///////////////////////////////////////////////////////////////////////////// |
355 | ///////////////////////////////////////////////////////////////////////////// |
226 | // XS interface functions |
356 | // XS interface functions |
227 | |
357 | |
228 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
358 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
229 | |
359 | |
230 | PROTOTYPES: ENABLE |
360 | PROTOTYPES: ENABLE |
231 | |
361 | |
232 | BOOT: |
362 | BOOT: |
233 | { |
363 | { |
234 | int i; |
|
|
235 | HV *stash = gv_stashpv ("EV", 1); |
364 | HV *stash = gv_stashpv ("EV", 1); |
236 | |
365 | |
237 | static const struct { |
366 | static const struct { |
238 | const char *name; |
367 | const char *name; |
239 | IV iv; |
368 | IV iv; |
240 | } *civ, const_iv[] = { |
369 | } *civ, const_iv[] = { |
241 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
370 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
371 | const_iv (EV_, MINPRI) |
|
|
372 | const_iv (EV_, MAXPRI) |
|
|
373 | |
242 | const_iv (EV_, UNDEF) |
374 | const_iv (EV_, UNDEF) |
243 | const_iv (EV_, NONE) |
375 | const_iv (EV_, NONE) |
244 | const_iv (EV_, TIMEOUT) |
|
|
245 | const_iv (EV_, READ) |
376 | const_iv (EV_, READ) |
246 | const_iv (EV_, WRITE) |
377 | const_iv (EV_, WRITE) |
|
|
378 | const_iv (EV_, IO) |
|
|
379 | const_iv (EV_, TIMER) |
|
|
380 | const_iv (EV_, PERIODIC) |
247 | const_iv (EV_, SIGNAL) |
381 | const_iv (EV_, SIGNAL) |
|
|
382 | const_iv (EV_, CHILD) |
|
|
383 | const_iv (EV_, STAT) |
248 | const_iv (EV_, IDLE) |
384 | const_iv (EV_, IDLE) |
|
|
385 | const_iv (EV_, PREPARE) |
249 | const_iv (EV_, CHECK) |
386 | const_iv (EV_, CHECK) |
|
|
387 | const_iv (EV_, EMBED) |
|
|
388 | const_iv (EV_, FORK) |
|
|
389 | const_iv (EV_, CLEANUP) |
|
|
390 | const_iv (EV_, ASYNC) |
|
|
391 | const_iv (EV_, CUSTOM) |
250 | const_iv (EV_, ERROR) |
392 | const_iv (EV_, ERROR) |
251 | |
393 | |
|
|
394 | const_iv (EV, RUN_NOWAIT) |
|
|
395 | const_iv (EV, RUN_ONCE) |
|
|
396 | |
|
|
397 | const_iv (EV, BREAK_CANCEL) |
|
|
398 | const_iv (EV, BREAK_ONE) |
|
|
399 | const_iv (EV, BREAK_ALL) |
|
|
400 | const_iv (EV, BACKEND_SELECT) |
|
|
401 | const_iv (EV, BACKEND_POLL) |
|
|
402 | const_iv (EV, BACKEND_EPOLL) |
|
|
403 | const_iv (EV, BACKEND_KQUEUE) |
|
|
404 | const_iv (EV, BACKEND_DEVPOLL) |
|
|
405 | const_iv (EV, BACKEND_PORT) |
|
|
406 | const_iv (EV, BACKEND_ALL) |
|
|
407 | const_iv (EV, BACKEND_MASK) |
|
|
408 | const_iv (EV, FLAG_AUTO) |
|
|
409 | const_iv (EV, FLAG_FORKCHECK) |
|
|
410 | const_iv (EV, FLAG_SIGNALFD) |
|
|
411 | const_iv (EV, FLAG_NOSIGMASK) |
|
|
412 | const_iv (EV, FLAG_NOENV) |
|
|
413 | const_iv (EV, FLAG_NOINOTIFY) |
|
|
414 | |
|
|
415 | const_iv (EV_, VERSION_MAJOR) |
|
|
416 | const_iv (EV_, VERSION_MINOR) |
|
|
417 | #if EV_COMPAT3 |
|
|
418 | const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */ |
|
|
419 | const_iv (EV_, TIMEOUT) |
|
|
420 | const_iv (EV, LOOP_NONBLOCK) |
252 | const_iv (EV, LOOP_ONESHOT) |
421 | const_iv (EV, LOOP_ONESHOT) |
|
|
422 | const_iv (EV, UNLOOP_CANCEL) |
253 | const_iv (EV, LOOP_NONBLOCK) |
423 | const_iv (EV, UNLOOP_ONE) |
254 | |
|
|
255 | const_iv (EV, METHOD_NONE) |
|
|
256 | const_iv (EV, METHOD_SELECT) |
|
|
257 | const_iv (EV, METHOD_EPOLL) |
424 | const_iv (EV, UNLOOP_ALL) |
|
|
425 | #endif |
258 | }; |
426 | }; |
259 | |
427 | |
260 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
428 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
261 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
429 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
262 | |
430 | |
|
|
431 | stash_loop = gv_stashpv ("EV::Loop" , 1); |
263 | stash_watcher = gv_stashpv ("EV::Watcher" , 1); |
432 | stash_watcher = gv_stashpv ("EV::Watcher" , 1); |
264 | stash_io = gv_stashpv ("EV::Io" , 1); |
433 | stash_io = gv_stashpv ("EV::IO" , 1); |
265 | stash_timer = gv_stashpv ("EV::Timer" , 1); |
434 | stash_timer = gv_stashpv ("EV::Timer" , 1); |
266 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
435 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
267 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
436 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
268 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
437 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
269 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
438 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
270 | stash_check = gv_stashpv ("EV::Check" , 1); |
439 | stash_check = gv_stashpv ("EV::Check" , 1); |
271 | stash_child = gv_stashpv ("EV::Child" , 1); |
440 | stash_child = gv_stashpv ("EV::Child" , 1); |
|
|
441 | stash_embed = gv_stashpv ("EV::Embed" , 1); |
|
|
442 | stash_stat = gv_stashpv ("EV::Stat" , 1); |
|
|
443 | stash_fork = gv_stashpv ("EV::Fork" , 1); |
|
|
444 | stash_cleanup = gv_stashpv ("EV::Cleanup" , 1); |
|
|
445 | stash_async = gv_stashpv ("EV::Async" , 1); |
272 | |
446 | |
273 | { |
447 | { |
274 | SV *sv = perl_get_sv ("EV::API", TRUE); |
448 | SV *sv = perl_get_sv ("EV::API", TRUE); |
275 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
449 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
276 | |
450 | |
277 | /* the poor man's shared library emulator */ |
451 | /* the poor man's shared library emulator */ |
278 | evapi.ver = EV_API_VERSION; |
452 | evapi.ver = EV_API_VERSION; |
279 | evapi.rev = EV_API_REVISION; |
453 | evapi.rev = EV_API_REVISION; |
280 | evapi.sv_fileno = sv_fileno; |
454 | evapi.sv_fileno = sv_fileno; |
281 | evapi.sv_signum = sv_signum; |
455 | evapi.sv_signum = s_signum; |
282 | evapi.now = &ev_now; |
456 | evapi.supported_backends = ev_supported_backends (); |
283 | evapi.method = &ev_method; |
457 | evapi.recommended_backends = ev_recommended_backends (); |
284 | evapi.loop_done = &ev_loop_done; |
458 | evapi.embeddable_backends = ev_embeddable_backends (); |
285 | evapi.time = ev_time; |
459 | evapi.time_ = ev_time; |
|
|
460 | evapi.sleep_ = ev_sleep; |
286 | evapi.loop = ev_loop; |
461 | evapi.loop_new = ev_loop_new; |
|
|
462 | evapi.loop_destroy = ev_loop_destroy; |
|
|
463 | evapi.loop_fork = ev_loop_fork; |
|
|
464 | evapi.iteration = ev_iteration; |
|
|
465 | evapi.depth = ev_depth; |
|
|
466 | evapi.set_userdata = ev_set_userdata; |
|
|
467 | evapi.userdata = ev_userdata; |
|
|
468 | evapi.now = ev_now; |
|
|
469 | evapi.now_update = ev_now_update; |
|
|
470 | evapi.suspend = ev_suspend; |
|
|
471 | evapi.resume = ev_resume; |
|
|
472 | evapi.backend = ev_backend; |
|
|
473 | evapi.break_ = ev_break; |
|
|
474 | evapi.invoke_pending = ev_invoke_pending; |
|
|
475 | evapi.pending_count = ev_pending_count; |
|
|
476 | evapi.verify = ev_verify; |
|
|
477 | evapi.set_loop_release_cb = ev_set_loop_release_cb; |
|
|
478 | evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb; |
|
|
479 | evapi.ref = ev_ref; |
|
|
480 | evapi.unref = ev_unref; |
|
|
481 | evapi.run = ev_run; |
287 | evapi.once = ev_once; |
482 | evapi.once = ev_once; |
288 | evapi.io_start = ev_io_start; |
483 | evapi.io_start = ev_io_start; |
289 | evapi.io_stop = ev_io_stop; |
484 | evapi.io_stop = ev_io_stop; |
290 | evapi.timer_start = ev_timer_start; |
485 | evapi.timer_start = ev_timer_start; |
291 | evapi.timer_stop = ev_timer_stop; |
486 | evapi.timer_stop = ev_timer_stop; |
292 | evapi.timer_again = ev_timer_again; |
487 | evapi.timer_again = ev_timer_again; |
|
|
488 | evapi.timer_remaining = ev_timer_remaining; |
293 | evapi.periodic_start = ev_periodic_start; |
489 | evapi.periodic_start = ev_periodic_start; |
294 | evapi.periodic_stop = ev_periodic_stop; |
490 | evapi.periodic_stop = ev_periodic_stop; |
295 | evapi.signal_start = ev_signal_start; |
491 | evapi.signal_start = ev_signal_start; |
296 | evapi.signal_stop = ev_signal_stop; |
492 | evapi.signal_stop = ev_signal_stop; |
297 | evapi.idle_start = ev_idle_start; |
493 | evapi.idle_start = ev_idle_start; |
298 | evapi.idle_stop = ev_idle_stop; |
494 | evapi.idle_stop = ev_idle_stop; |
299 | evapi.prepare_start = ev_prepare_start; |
495 | evapi.prepare_start = ev_prepare_start; |
300 | evapi.prepare_stop = ev_prepare_stop; |
496 | evapi.prepare_stop = ev_prepare_stop; |
301 | evapi.check_start = ev_check_start; |
497 | evapi.check_start = ev_check_start; |
302 | evapi.check_stop = ev_check_stop; |
498 | evapi.check_stop = ev_check_stop; |
|
|
499 | #if EV_CHILD_ENABLE |
303 | evapi.child_start = ev_child_start; |
500 | evapi.child_start = ev_child_start; |
304 | evapi.child_stop = ev_child_stop; |
501 | evapi.child_stop = ev_child_stop; |
|
|
502 | #endif |
|
|
503 | evapi.stat_start = ev_stat_start; |
|
|
504 | evapi.stat_stop = ev_stat_stop; |
|
|
505 | evapi.stat_stat = ev_stat_stat; |
|
|
506 | evapi.embed_start = ev_embed_start; |
|
|
507 | evapi.embed_stop = ev_embed_stop; |
|
|
508 | evapi.embed_sweep = ev_embed_sweep; |
|
|
509 | evapi.fork_start = ev_fork_start; |
|
|
510 | evapi.fork_stop = ev_fork_stop; |
|
|
511 | evapi.cleanup_start = ev_cleanup_start; |
|
|
512 | evapi.cleanup_stop = ev_cleanup_stop; |
|
|
513 | evapi.async_start = ev_async_start; |
|
|
514 | evapi.async_stop = ev_async_stop; |
|
|
515 | evapi.async_send = ev_async_send; |
|
|
516 | evapi.clear_pending = ev_clear_pending; |
|
|
517 | evapi.invoke = ev_invoke; |
305 | |
518 | |
306 | sv_setiv (sv, (IV)&evapi); |
519 | sv_setiv (sv, (IV)&evapi); |
307 | SvREADONLY_on (sv); |
520 | SvREADONLY_on (sv); |
308 | } |
521 | } |
|
|
522 | #if !defined(_WIN32) && !defined(_MINIX) |
|
|
523 | pthread_atfork (0, 0, default_fork); |
|
|
524 | #endif |
|
|
525 | } |
309 | |
526 | |
310 | pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); |
527 | SV *ev_default_loop (unsigned int flags = 0) |
|
|
528 | CODE: |
|
|
529 | { |
|
|
530 | if (!default_loop_sv) |
|
|
531 | { |
|
|
532 | evapi.default_loop = ev_default_loop (flags); |
|
|
533 | |
|
|
534 | if (!evapi.default_loop) |
|
|
535 | XSRETURN_UNDEF; |
|
|
536 | |
|
|
537 | default_loop_sv = sv_bless (newRV_noinc (newSViv (PTR2IV (evapi.default_loop))), stash_loop); |
|
|
538 | } |
|
|
539 | |
|
|
540 | RETVAL = newSVsv (default_loop_sv); |
|
|
541 | } |
|
|
542 | OUTPUT: |
|
|
543 | RETVAL |
|
|
544 | |
|
|
545 | void ev_default_destroy () |
|
|
546 | CODE: |
|
|
547 | ev_loop_destroy (EV_DEFAULT_UC); |
|
|
548 | SvREFCNT_dec (default_loop_sv); |
|
|
549 | default_loop_sv = 0; |
|
|
550 | |
|
|
551 | unsigned int ev_supported_backends () |
|
|
552 | |
|
|
553 | unsigned int ev_recommended_backends () |
|
|
554 | |
|
|
555 | unsigned int ev_embeddable_backends () |
|
|
556 | |
|
|
557 | void ev_sleep (NV interval) |
|
|
558 | |
|
|
559 | NV ev_time () |
|
|
560 | |
|
|
561 | void ev_feed_signal (SV *signal) |
|
|
562 | CODE: |
|
|
563 | { |
|
|
564 | Signal signum = s_signum (signal); |
|
|
565 | CHECK_SIG (signal, signum); |
|
|
566 | |
|
|
567 | ev_feed_signal (signum); |
311 | } |
568 | } |
312 | |
569 | |
313 | NV ev_now () |
570 | NV ev_now () |
314 | CODE: |
571 | C_ARGS: evapi.default_loop |
315 | RETVAL = ev_now; |
|
|
316 | OUTPUT: |
|
|
317 | RETVAL |
|
|
318 | |
572 | |
319 | int ev_method () |
573 | void ev_now_update () |
320 | CODE: |
574 | C_ARGS: evapi.default_loop |
321 | RETVAL = ev_method; |
|
|
322 | OUTPUT: |
|
|
323 | RETVAL |
|
|
324 | |
575 | |
325 | NV ev_time () |
576 | void ev_suspend () |
|
|
577 | C_ARGS: evapi.default_loop |
326 | |
578 | |
|
|
579 | void ev_resume () |
|
|
580 | C_ARGS: evapi.default_loop |
|
|
581 | |
|
|
582 | unsigned int ev_backend () |
|
|
583 | C_ARGS: evapi.default_loop |
|
|
584 | |
|
|
585 | void ev_verify () |
|
|
586 | ALIAS: |
|
|
587 | loop_verify = 1 |
|
|
588 | C_ARGS: evapi.default_loop |
|
|
589 | |
|
|
590 | unsigned int ev_iteration () |
|
|
591 | ALIAS: |
|
|
592 | loop_count = 1 |
|
|
593 | C_ARGS: evapi.default_loop |
|
|
594 | |
|
|
595 | unsigned int ev_depth () |
|
|
596 | ALIAS: |
|
|
597 | loop_depth = 1 |
|
|
598 | C_ARGS: evapi.default_loop |
|
|
599 | |
|
|
600 | void ev_set_io_collect_interval (NV interval) |
|
|
601 | C_ARGS: evapi.default_loop, interval |
|
|
602 | |
|
|
603 | void ev_set_timeout_collect_interval (NV interval) |
|
|
604 | C_ARGS: evapi.default_loop, interval |
|
|
605 | |
327 | void ev_init (int flags = 0) |
606 | void ev_run (int flags = 0) |
|
|
607 | ALIAS: |
|
|
608 | loop = 1 |
|
|
609 | C_ARGS: evapi.default_loop, flags |
328 | |
610 | |
329 | void ev_loop (int flags = 0) |
611 | void ev_break (int how = EVBREAK_ONE) |
|
|
612 | ALIAS: |
|
|
613 | unloop = 1 |
|
|
614 | C_ARGS: evapi.default_loop, how |
330 | |
615 | |
331 | void ev_loop_done (int value = 1) |
616 | void ev_feed_fd_event (int fd, int revents = EV_NONE) |
332 | CODE: |
617 | C_ARGS: evapi.default_loop, fd, revents |
333 | ev_loop_done = value; |
|
|
334 | |
618 | |
|
|
619 | void ev_feed_signal_event (SV *signal) |
|
|
620 | CODE: |
|
|
621 | { |
|
|
622 | Signal signum = s_signum (signal); |
|
|
623 | CHECK_SIG (signal, signum); |
|
|
624 | |
|
|
625 | ev_feed_signal_event (evapi.default_loop, signum); |
|
|
626 | } |
|
|
627 | |
|
|
628 | unsigned int ev_pending_count () |
|
|
629 | C_ARGS: evapi.default_loop |
|
|
630 | |
|
|
631 | void ev_invoke_pending () |
|
|
632 | C_ARGS: evapi.default_loop |
|
|
633 | |
335 | struct ev_io *io (SV *fh, int events, SV *cb) |
634 | ev_io *io (SV *fh, int events, SV *cb) |
336 | ALIAS: |
635 | ALIAS: |
337 | io_ns = 1 |
636 | io_ns = 1 |
|
|
637 | _ae_io = 2 |
338 | CODE: |
638 | CODE: |
339 | { |
639 | { |
340 | int fd = sv_fileno (fh); |
640 | int fd = s_fileno (fh, events & EV_WRITE); |
341 | CHECK_FD (fh, fd); |
641 | CHECK_FD (fh, fd); |
342 | |
642 | |
|
|
643 | if (ix == 2) |
|
|
644 | { |
|
|
645 | ix = 0; |
|
|
646 | events = events ? EV_WRITE : EV_READ; |
|
|
647 | } |
|
|
648 | |
343 | RETVAL = e_new (sizeof (struct ev_io), cb); |
649 | RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv); |
344 | RETVAL->fh = newSVsv (fh); |
650 | e_fh (RETVAL) = newSVsv (fh); |
345 | ev_io_set (RETVAL, fd, events); |
651 | ev_io_set (RETVAL, fd, events); |
346 | if (!ix) ev_io_start (RETVAL); |
652 | if (!ix) START (io, RETVAL); |
347 | } |
653 | } |
348 | OUTPUT: |
654 | OUTPUT: |
349 | RETVAL |
655 | RETVAL |
350 | |
656 | |
351 | struct ev_timer *timer (NV after, NV repeat, SV *cb) |
657 | ev_timer *timer (NV after, NV repeat, SV *cb) |
352 | ALIAS: |
658 | ALIAS: |
353 | timer_ns = 1 |
659 | timer_ns = 1 |
354 | INIT: |
660 | INIT: |
355 | CHECK_REPEAT (repeat); |
661 | CHECK_REPEAT (repeat); |
356 | CODE: |
662 | CODE: |
357 | RETVAL = e_new (sizeof (struct ev_timer), cb); |
663 | RETVAL = e_new (sizeof (ev_timer), cb, default_loop_sv); |
358 | ev_timer_set (RETVAL, after, repeat); |
664 | ev_timer_set (RETVAL, after, repeat); |
359 | if (!ix) ev_timer_start (RETVAL); |
665 | if (!ix) START (timer, RETVAL); |
360 | OUTPUT: |
666 | OUTPUT: |
361 | RETVAL |
667 | RETVAL |
362 | |
668 | |
363 | struct ev_periodic *periodic (NV at, NV interval, SV *cb) |
669 | SV *periodic (NV at, NV interval, SV *reschedule_cb, SV *cb) |
364 | ALIAS: |
670 | ALIAS: |
365 | periodic_ns = 1 |
671 | periodic_ns = 1 |
366 | INIT: |
672 | INIT: |
367 | CHECK_REPEAT (interval); |
673 | CHECK_REPEAT (interval); |
368 | CODE: |
674 | CODE: |
369 | RETVAL = e_new (sizeof (struct ev_periodic), cb); |
675 | { |
370 | ev_periodic_set (RETVAL, at, interval); |
676 | ev_periodic *w; |
371 | if (!ix) ev_periodic_start (RETVAL); |
677 | w = e_new (sizeof (ev_periodic), cb, default_loop_sv); |
|
|
678 | e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
|
|
679 | ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0); |
|
|
680 | RETVAL = e_bless ((ev_watcher *)w, stash_periodic); |
|
|
681 | if (!ix) START (periodic, w); |
|
|
682 | } |
372 | OUTPUT: |
683 | OUTPUT: |
373 | RETVAL |
684 | RETVAL |
374 | |
685 | |
375 | struct ev_signal *signal (Signal signum, SV *cb) |
686 | ev_signal *signal (SV *signal, SV *cb) |
376 | ALIAS: |
687 | ALIAS: |
377 | signal_ns = 1 |
688 | signal_ns = 1 |
378 | CODE: |
689 | CODE: |
|
|
690 | { |
|
|
691 | Signal signum = s_signum (signal); |
|
|
692 | CHECK_SIG (signal, signum); |
|
|
693 | |
379 | RETVAL = e_new (sizeof (struct ev_signal), cb); |
694 | RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv); |
380 | ev_signal_set (RETVAL, signum); |
695 | ev_signal_set (RETVAL, signum); |
381 | if (!ix) ev_signal_start (RETVAL); |
696 | if (!ix) START_SIGNAL (RETVAL); |
|
|
697 | } |
382 | OUTPUT: |
698 | OUTPUT: |
383 | RETVAL |
699 | RETVAL |
384 | |
700 | |
385 | struct ev_idle *idle (SV *cb) |
701 | ev_idle *idle (SV *cb) |
386 | ALIAS: |
702 | ALIAS: |
387 | idle_ns = 1 |
703 | idle_ns = 1 |
388 | CODE: |
704 | CODE: |
389 | RETVAL = e_new (sizeof (struct ev_idle), cb); |
705 | RETVAL = e_new (sizeof (ev_idle), cb, default_loop_sv); |
390 | ev_idle_set (RETVAL); |
706 | ev_idle_set (RETVAL); |
391 | if (!ix) ev_idle_start (RETVAL); |
707 | if (!ix) START (idle, RETVAL); |
392 | OUTPUT: |
708 | OUTPUT: |
393 | RETVAL |
709 | RETVAL |
394 | |
710 | |
395 | struct ev_prepare *prepare (SV *cb) |
711 | ev_prepare *prepare (SV *cb) |
396 | ALIAS: |
712 | ALIAS: |
397 | prepare_ns = 1 |
713 | prepare_ns = 1 |
398 | CODE: |
714 | CODE: |
399 | RETVAL = e_new (sizeof (struct ev_prepare), cb); |
715 | RETVAL = e_new (sizeof (ev_prepare), cb, default_loop_sv); |
400 | ev_prepare_set (RETVAL); |
716 | ev_prepare_set (RETVAL); |
401 | if (!ix) ev_prepare_start (RETVAL); |
717 | if (!ix) START (prepare, RETVAL); |
402 | OUTPUT: |
718 | OUTPUT: |
403 | RETVAL |
719 | RETVAL |
404 | |
720 | |
405 | struct ev_check *check (SV *cb) |
721 | ev_check *check (SV *cb) |
406 | ALIAS: |
722 | ALIAS: |
407 | check_ns = 1 |
723 | check_ns = 1 |
408 | CODE: |
724 | CODE: |
409 | RETVAL = e_new (sizeof (struct ev_check), cb); |
725 | RETVAL = e_new (sizeof (ev_check), cb, default_loop_sv); |
410 | ev_check_set (RETVAL); |
726 | ev_check_set (RETVAL); |
411 | if (!ix) ev_check_start (RETVAL); |
727 | if (!ix) START (check, RETVAL); |
412 | OUTPUT: |
728 | OUTPUT: |
413 | RETVAL |
729 | RETVAL |
414 | |
730 | |
|
|
731 | ev_fork *fork (SV *cb) |
|
|
732 | ALIAS: |
|
|
733 | fork_ns = 1 |
|
|
734 | CODE: |
|
|
735 | RETVAL = e_new (sizeof (ev_fork), cb, default_loop_sv); |
|
|
736 | ev_fork_set (RETVAL); |
|
|
737 | if (!ix) START (fork, RETVAL); |
|
|
738 | OUTPUT: |
|
|
739 | RETVAL |
|
|
740 | |
|
|
741 | ev_cleanup *cleanup (SV *cb) |
|
|
742 | ALIAS: |
|
|
743 | cleanup_ns = 1 |
|
|
744 | CODE: |
|
|
745 | RETVAL = e_new (sizeof (ev_cleanup), cb, default_loop_sv); |
|
|
746 | ev_cleanup_set (RETVAL); |
|
|
747 | if (!ix) START (cleanup, RETVAL); |
|
|
748 | OUTPUT: |
|
|
749 | RETVAL |
|
|
750 | |
415 | struct ev_child *child (int pid, SV *cb) |
751 | ev_child *child (int pid, int trace, SV *cb) |
416 | ALIAS: |
752 | ALIAS: |
417 | check_ns = 1 |
753 | child_ns = 1 |
418 | CODE: |
754 | CODE: |
419 | RETVAL = e_new (sizeof (struct ev_check), cb); |
755 | #if EV_CHILD_ENABLE |
|
|
756 | RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); |
420 | ev_child_set (RETVAL, pid); |
757 | ev_child_set (RETVAL, pid, trace); |
421 | if (!ix) ev_child_start (RETVAL); |
758 | if (!ix) START (child, RETVAL); |
|
|
759 | #else |
|
|
760 | croak ("EV::child watchers not supported on this platform"); |
|
|
761 | #endif |
422 | OUTPUT: |
762 | OUTPUT: |
423 | RETVAL |
763 | RETVAL |
424 | |
764 | |
|
|
765 | |
|
|
766 | ev_stat *stat (SV *path, NV interval, SV *cb) |
|
|
767 | ALIAS: |
|
|
768 | stat_ns = 1 |
|
|
769 | CODE: |
|
|
770 | RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv); |
|
|
771 | e_fh (RETVAL) = newSVsv (path); |
|
|
772 | ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval); |
|
|
773 | if (!ix) START (stat, RETVAL); |
|
|
774 | OUTPUT: |
|
|
775 | RETVAL |
|
|
776 | |
|
|
777 | #ifndef EV_NO_LOOPS |
|
|
778 | |
|
|
779 | ev_embed *embed (struct ev_loop *loop, SV *cb = 0) |
|
|
780 | ALIAS: |
|
|
781 | embed_ns = 1 |
|
|
782 | CODE: |
|
|
783 | { |
|
|
784 | if (!(ev_backend (loop) & ev_embeddable_backends ())) |
|
|
785 | croak ("passed loop is not embeddable via EV::embed,"); |
|
|
786 | |
|
|
787 | RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv); |
|
|
788 | e_fh (RETVAL) = newSVsv (ST (0)); |
|
|
789 | ev_embed_set (RETVAL, loop); |
|
|
790 | if (!ix) START (embed, RETVAL); |
|
|
791 | } |
|
|
792 | OUTPUT: |
|
|
793 | RETVAL |
|
|
794 | |
|
|
795 | #endif |
|
|
796 | |
|
|
797 | ev_async *async (SV *cb) |
|
|
798 | ALIAS: |
|
|
799 | async_ns = 1 |
|
|
800 | CODE: |
|
|
801 | RETVAL = e_new (sizeof (ev_async), cb, default_loop_sv); |
|
|
802 | ev_async_set (RETVAL); |
|
|
803 | if (!ix) START (async, RETVAL); |
|
|
804 | OUTPUT: |
|
|
805 | RETVAL |
|
|
806 | |
|
|
807 | void once (SV *fh, int events, SV *timeout, SV *cb) |
|
|
808 | CODE: |
|
|
809 | ev_once ( |
|
|
810 | evapi.default_loop, |
|
|
811 | s_fileno (fh, events & EV_WRITE), events, |
|
|
812 | SvOK (timeout) ? SvNV (timeout) : -1., |
|
|
813 | e_once_cb, |
|
|
814 | newSVsv (cb) |
|
|
815 | ); |
425 | |
816 | |
426 | PROTOTYPES: DISABLE |
817 | PROTOTYPES: DISABLE |
427 | |
818 | |
428 | MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ |
819 | MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ |
429 | |
820 | |
430 | int ev_is_active (struct ev_watcher *w) |
821 | int ev_is_active (ev_watcher *w) |
431 | |
822 | |
|
|
823 | int ev_is_pending (ev_watcher *w) |
|
|
824 | |
|
|
825 | void ev_invoke (ev_watcher *w, int revents = EV_NONE) |
|
|
826 | C_ARGS: e_loop (w), w, revents |
|
|
827 | |
|
|
828 | int ev_clear_pending (ev_watcher *w) |
|
|
829 | C_ARGS: e_loop (w), w |
|
|
830 | |
|
|
831 | void ev_feed_event (ev_watcher *w, int revents = EV_NONE) |
|
|
832 | C_ARGS: e_loop (w), w, revents |
|
|
833 | |
|
|
834 | int keepalive (ev_watcher *w, int new_value = 0) |
|
|
835 | CODE: |
|
|
836 | { |
|
|
837 | RETVAL = w->e_flags & WFLAG_KEEPALIVE; |
|
|
838 | new_value = new_value ? WFLAG_KEEPALIVE : 0; |
|
|
839 | |
|
|
840 | if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE)) |
|
|
841 | { |
|
|
842 | w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value; |
|
|
843 | REF (w); |
|
|
844 | UNREF (w); |
|
|
845 | } |
|
|
846 | } |
|
|
847 | OUTPUT: |
|
|
848 | RETVAL |
|
|
849 | |
432 | SV *cb (struct ev_watcher *w, SV *new_cb = 0) |
850 | SV *cb (ev_watcher *w, SV *new_cb = 0) |
433 | CODE: |
851 | CODE: |
434 | { |
852 | { |
435 | RETVAL = newSVsv (w->cb_sv); |
|
|
436 | |
|
|
437 | if (items > 1) |
|
|
438 | sv_setsv (w->cb_sv, new_cb); |
|
|
439 | } |
|
|
440 | OUTPUT: |
|
|
441 | RETVAL |
|
|
442 | |
|
|
443 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
|
|
444 | CODE: |
|
|
445 | w->cb (w, revents); |
|
|
446 | |
|
|
447 | MODULE = EV PACKAGE = EV::Io PREFIX = ev_io_ |
|
|
448 | |
|
|
449 | void ev_io_start (struct ev_io *w) |
|
|
450 | |
|
|
451 | void ev_io_stop (struct ev_io *w) |
|
|
452 | |
|
|
453 | void DESTROY (struct ev_io *w) |
|
|
454 | CODE: |
|
|
455 | ev_io_stop (w); |
|
|
456 | e_destroy (w); |
|
|
457 | |
|
|
458 | void set (struct ev_io *w, SV *fh, int events) |
|
|
459 | CODE: |
|
|
460 | { |
|
|
461 | int active = w->active; |
|
|
462 | int fd = sv_fileno (fh); |
|
|
463 | CHECK_FD (fh, fd); |
|
|
464 | |
|
|
465 | if (active) ev_io_stop (w); |
|
|
466 | |
|
|
467 | sv_setsv (w->fh, fh); |
|
|
468 | ev_io_set (w, fd, events); |
|
|
469 | |
|
|
470 | if (active) ev_io_start (w); |
|
|
471 | } |
|
|
472 | |
|
|
473 | SV *fh (struct ev_io *w, SV *new_fh = 0) |
|
|
474 | CODE: |
|
|
475 | { |
|
|
476 | RETVAL = newSVsv (w->fh); |
|
|
477 | |
|
|
478 | if (items > 1) |
853 | if (items > 1) |
479 | { |
854 | { |
480 | int active = w->active; |
855 | new_cb = s_get_cv_croak (new_cb); |
481 | if (active) ev_io_stop (w); |
856 | RETVAL = newRV_noinc (w->cb_sv); |
482 | |
857 | w->cb_sv = SvREFCNT_inc (new_cb); |
483 | sv_setsv (w->fh, new_fh); |
|
|
484 | ev_io_set (w, sv_fileno (w->fh), w->events); |
|
|
485 | |
|
|
486 | if (active) ev_io_start (w); |
|
|
487 | } |
858 | } |
|
|
859 | else |
|
|
860 | RETVAL = newRV_inc (w->cb_sv); |
488 | } |
861 | } |
489 | OUTPUT: |
862 | OUTPUT: |
490 | RETVAL |
863 | RETVAL |
491 | |
864 | |
492 | short events (struct ev_io *w, short new_events = EV_UNDEF) |
865 | SV *data (ev_watcher *w, SV *new_data = 0) |
493 | CODE: |
866 | CODE: |
494 | { |
867 | { |
495 | RETVAL = w->events; |
868 | RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; |
496 | |
869 | |
497 | if (items > 1) |
870 | if (items > 1) |
498 | { |
871 | { |
499 | int active = w->active; |
872 | SvREFCNT_dec (w->data); |
500 | if (active) ev_io_stop (w); |
873 | w->data = newSVsv (new_data); |
501 | |
|
|
502 | ev_io_set (w, w->fd, new_events); |
|
|
503 | |
|
|
504 | if (active) ev_io_start (w); |
|
|
505 | } |
874 | } |
506 | } |
875 | } |
507 | OUTPUT: |
876 | OUTPUT: |
508 | RETVAL |
877 | RETVAL |
509 | |
878 | |
|
|
879 | SV *loop (ev_watcher *w) |
|
|
880 | CODE: |
|
|
881 | RETVAL = newRV_inc (w->loop); |
|
|
882 | OUTPUT: |
|
|
883 | RETVAL |
|
|
884 | |
|
|
885 | int priority (ev_watcher *w, int new_priority = 0) |
|
|
886 | CODE: |
|
|
887 | { |
|
|
888 | RETVAL = w->priority; |
|
|
889 | |
|
|
890 | if (items > 1) |
|
|
891 | { |
|
|
892 | int active = ev_is_active (w); |
|
|
893 | |
|
|
894 | if (active) |
|
|
895 | { |
|
|
896 | /* grrr. */ |
|
|
897 | PUSHMARK (SP); |
|
|
898 | XPUSHs (ST (0)); |
|
|
899 | PUTBACK; |
|
|
900 | call_method ("stop", G_DISCARD | G_VOID); |
|
|
901 | } |
|
|
902 | |
|
|
903 | ev_set_priority (w, new_priority); |
|
|
904 | |
|
|
905 | if (active) |
|
|
906 | { |
|
|
907 | PUSHMARK (SP); |
|
|
908 | XPUSHs (ST (0)); |
|
|
909 | PUTBACK; |
|
|
910 | call_method ("start", G_DISCARD | G_VOID); |
|
|
911 | } |
|
|
912 | } |
|
|
913 | } |
|
|
914 | OUTPUT: |
|
|
915 | RETVAL |
|
|
916 | |
|
|
917 | MODULE = EV PACKAGE = EV::IO PREFIX = ev_io_ |
|
|
918 | |
|
|
919 | void ev_io_start (ev_io *w) |
|
|
920 | CODE: |
|
|
921 | START (io, w); |
|
|
922 | |
|
|
923 | void ev_io_stop (ev_io *w) |
|
|
924 | CODE: |
|
|
925 | STOP (io, w); |
|
|
926 | |
|
|
927 | void DESTROY (ev_io *w) |
|
|
928 | CODE: |
|
|
929 | STOP (io, w); |
|
|
930 | e_destroy (w); |
|
|
931 | |
|
|
932 | void set (ev_io *w, SV *fh, int events) |
|
|
933 | CODE: |
|
|
934 | { |
|
|
935 | int fd = s_fileno (fh, events & EV_WRITE); |
|
|
936 | CHECK_FD (fh, fd); |
|
|
937 | |
|
|
938 | sv_setsv (e_fh (w), fh); |
|
|
939 | RESET (io, w, (w, fd, events)); |
|
|
940 | } |
|
|
941 | |
|
|
942 | SV *fh (ev_io *w, SV *new_fh = 0) |
|
|
943 | CODE: |
|
|
944 | { |
|
|
945 | if (items > 1) |
|
|
946 | { |
|
|
947 | int fd = s_fileno (new_fh, w->events & EV_WRITE); |
|
|
948 | CHECK_FD (new_fh, fd); |
|
|
949 | |
|
|
950 | RETVAL = e_fh (w); |
|
|
951 | e_fh (w) = newSVsv (new_fh); |
|
|
952 | |
|
|
953 | RESET (io, w, (w, fd, w->events)); |
|
|
954 | } |
|
|
955 | else |
|
|
956 | RETVAL = newSVsv (e_fh (w)); |
|
|
957 | } |
|
|
958 | OUTPUT: |
|
|
959 | RETVAL |
|
|
960 | |
|
|
961 | int events (ev_io *w, int new_events = EV_UNDEF) |
|
|
962 | CODE: |
|
|
963 | { |
|
|
964 | RETVAL = w->events; |
|
|
965 | |
|
|
966 | if (items > 1) |
|
|
967 | RESET (io, w, (w, w->fd, new_events)); |
|
|
968 | } |
|
|
969 | OUTPUT: |
|
|
970 | RETVAL |
|
|
971 | |
510 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
972 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
511 | |
973 | |
512 | void ev_signal_start (struct ev_signal *w) |
974 | void ev_signal_start (ev_signal *w) |
|
|
975 | CODE: |
|
|
976 | START_SIGNAL (w); |
513 | |
977 | |
514 | void ev_signal_stop (struct ev_signal *w) |
978 | void ev_signal_stop (ev_signal *w) |
|
|
979 | CODE: |
|
|
980 | STOP (signal, w); |
515 | |
981 | |
516 | void DESTROY (struct ev_signal *w) |
982 | void DESTROY (ev_signal *w) |
517 | CODE: |
983 | CODE: |
518 | ev_signal_stop (w); |
984 | STOP (signal, w); |
519 | e_destroy (w); |
985 | e_destroy (w); |
520 | |
986 | |
521 | void set (struct ev_signal *w, SV *signal = 0) |
987 | void set (ev_signal *w, SV *signal) |
522 | CODE: |
988 | CODE: |
523 | { |
989 | { |
524 | Signal signum = sv_signum (signal); /* may croak here */ |
990 | Signal signum = s_signum (signal); |
525 | int active = w->active; |
991 | CHECK_SIG (signal, signum); |
526 | |
992 | |
527 | if (active) ev_signal_stop (w); |
993 | RESET_SIGNAL (w, (w, signum)); |
528 | ev_signal_set (w, signum); |
|
|
529 | if (active) ev_signal_start (w); |
|
|
530 | } |
994 | } |
531 | |
995 | |
532 | MODULE = EV PACKAGE = EV::Time |
996 | int signal (ev_signal *w, SV *new_signal = 0) |
|
|
997 | CODE: |
|
|
998 | { |
|
|
999 | RETVAL = w->signum; |
|
|
1000 | |
|
|
1001 | if (items > 1) |
|
|
1002 | { |
|
|
1003 | Signal signum = s_signum (new_signal); |
|
|
1004 | CHECK_SIG (new_signal, signum); |
|
|
1005 | |
|
|
1006 | RESET_SIGNAL (w, (w, signum)); |
|
|
1007 | } |
|
|
1008 | } |
|
|
1009 | OUTPUT: |
|
|
1010 | RETVAL |
533 | |
1011 | |
534 | MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ |
1012 | MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ |
535 | |
1013 | |
536 | void ev_timer_start (struct ev_timer *w) |
1014 | void ev_timer_start (ev_timer *w) |
537 | INIT: |
1015 | INIT: |
538 | CHECK_REPEAT (w->repeat); |
1016 | CHECK_REPEAT (w->repeat); |
|
|
1017 | CODE: |
|
|
1018 | START (timer, w); |
539 | |
1019 | |
540 | void ev_timer_stop (struct ev_timer *w) |
1020 | void ev_timer_stop (ev_timer *w) |
|
|
1021 | CODE: |
|
|
1022 | STOP (timer, w); |
541 | |
1023 | |
542 | void ev_timer_again (struct ev_timer *w) |
1024 | void ev_timer_again (ev_timer *w) |
543 | INIT: |
1025 | INIT: |
544 | CHECK_REPEAT (w->repeat); |
1026 | CHECK_REPEAT (w->repeat); |
|
|
1027 | CODE: |
|
|
1028 | ev_timer_again (e_loop (w), w); |
|
|
1029 | UNREF (w); |
545 | |
1030 | |
|
|
1031 | NV ev_timer_remaining (ev_timer *w) |
|
|
1032 | C_ARGS: e_loop (w), w |
|
|
1033 | |
546 | void DESTROY (struct ev_timer *w) |
1034 | void DESTROY (ev_timer *w) |
547 | CODE: |
1035 | CODE: |
548 | ev_timer_stop (w); |
1036 | STOP (timer, w); |
549 | e_destroy (w); |
1037 | e_destroy (w); |
550 | |
1038 | |
551 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
1039 | void set (ev_timer *w, NV after, NV repeat = 0.) |
552 | INIT: |
1040 | INIT: |
553 | CHECK_REPEAT (repeat); |
1041 | CHECK_REPEAT (repeat); |
554 | CODE: |
1042 | CODE: |
555 | { |
|
|
556 | int active = w->active; |
|
|
557 | if (active) ev_timer_stop (w); |
|
|
558 | ev_timer_set (w, after, repeat); |
1043 | RESET (timer, w, (w, after, repeat)); |
559 | if (active) ev_timer_start (w); |
|
|
560 | } |
|
|
561 | |
1044 | |
562 | MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ |
1045 | MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ |
563 | |
1046 | |
564 | void ev_periodic_start (struct ev_periodic *w) |
1047 | void ev_periodic_start (ev_periodic *w) |
565 | INIT: |
1048 | INIT: |
566 | CHECK_REPEAT (w->interval); |
1049 | CHECK_REPEAT (w->interval); |
|
|
1050 | CODE: |
|
|
1051 | START (periodic, w); |
567 | |
1052 | |
568 | void ev_periodic_stop (struct ev_periodic *w) |
1053 | void ev_periodic_stop (ev_periodic *w) |
|
|
1054 | CODE: |
|
|
1055 | STOP (periodic, w); |
569 | |
1056 | |
|
|
1057 | void ev_periodic_again (ev_periodic *w) |
|
|
1058 | CODE: |
|
|
1059 | ev_periodic_again (e_loop (w), w); |
|
|
1060 | UNREF (w); |
|
|
1061 | |
570 | void DESTROY (struct ev_periodic *w) |
1062 | void DESTROY (ev_periodic *w) |
571 | CODE: |
1063 | CODE: |
572 | ev_periodic_stop (w); |
1064 | STOP (periodic, w); |
573 | e_destroy (w); |
1065 | e_destroy (w); |
574 | |
1066 | |
575 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
1067 | void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef) |
576 | INIT: |
1068 | INIT: |
577 | CHECK_REPEAT (interval); |
1069 | CHECK_REPEAT (interval); |
578 | CODE: |
1070 | CODE: |
579 | { |
1071 | { |
580 | int active = w->active; |
1072 | SvREFCNT_dec (e_fh (w)); |
581 | if (active) ev_periodic_stop (w); |
1073 | e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
582 | ev_periodic_set (w, at, interval); |
1074 | |
583 | if (active) ev_periodic_start (w); |
1075 | RESET (periodic, w, (w, at, interval, e_fh (w) ? e_periodic_cb : 0)); |
584 | } |
1076 | } |
|
|
1077 | |
|
|
1078 | NV at (ev_periodic *w) |
|
|
1079 | CODE: |
|
|
1080 | RETVAL = ev_periodic_at (w); |
|
|
1081 | OUTPUT: |
|
|
1082 | RETVAL |
585 | |
1083 | |
586 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
1084 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
587 | |
1085 | |
588 | void ev_idle_start (struct ev_idle *w) |
1086 | void ev_idle_start (ev_idle *w) |
|
|
1087 | CODE: |
|
|
1088 | START (idle, w); |
589 | |
1089 | |
590 | void ev_idle_stop (struct ev_idle *w) |
1090 | void ev_idle_stop (ev_idle *w) |
|
|
1091 | CODE: |
|
|
1092 | STOP (idle, w); |
591 | |
1093 | |
592 | void DESTROY (struct ev_idle *w) |
1094 | void DESTROY (ev_idle *w) |
593 | CODE: |
1095 | CODE: |
594 | ev_idle_stop (w); |
1096 | STOP (idle, w); |
595 | e_destroy (w); |
1097 | e_destroy (w); |
596 | |
1098 | |
597 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
1099 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_prepare_ |
598 | |
1100 | |
599 | void ev_prepare_start (struct ev_prepare *w) |
1101 | void ev_prepare_start (ev_prepare *w) |
|
|
1102 | CODE: |
|
|
1103 | START (prepare, w); |
600 | |
1104 | |
601 | void ev_prepare_stop (struct ev_prepare *w) |
1105 | void ev_prepare_stop (ev_prepare *w) |
|
|
1106 | CODE: |
|
|
1107 | STOP (prepare, w); |
602 | |
1108 | |
603 | void DESTROY (struct ev_prepare *w) |
1109 | void DESTROY (ev_prepare *w) |
604 | CODE: |
1110 | CODE: |
605 | ev_prepare_stop (w); |
1111 | STOP (prepare, w); |
606 | e_destroy (w); |
1112 | e_destroy (w); |
607 | |
1113 | |
608 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
1114 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
609 | |
1115 | |
610 | void ev_check_start (struct ev_check *w) |
1116 | void ev_check_start (ev_check *w) |
|
|
1117 | CODE: |
|
|
1118 | START (check, w); |
611 | |
1119 | |
612 | void ev_check_stop (struct ev_check *w) |
1120 | void ev_check_stop (ev_check *w) |
|
|
1121 | CODE: |
|
|
1122 | STOP (check, w); |
613 | |
1123 | |
614 | void DESTROY (struct ev_check *w) |
1124 | void DESTROY (ev_check *w) |
615 | CODE: |
1125 | CODE: |
616 | ev_check_stop (w); |
1126 | STOP (check, w); |
617 | e_destroy (w); |
1127 | e_destroy (w); |
618 | |
1128 | |
|
|
1129 | MODULE = EV PACKAGE = EV::Fork PREFIX = ev_fork_ |
|
|
1130 | |
|
|
1131 | void ev_fork_start (ev_fork *w) |
|
|
1132 | CODE: |
|
|
1133 | START (fork, w); |
|
|
1134 | |
|
|
1135 | void ev_fork_stop (ev_fork *w) |
|
|
1136 | CODE: |
|
|
1137 | STOP (fork, w); |
|
|
1138 | |
|
|
1139 | void DESTROY (ev_fork *w) |
|
|
1140 | CODE: |
|
|
1141 | STOP (fork, w); |
|
|
1142 | e_destroy (w); |
|
|
1143 | |
|
|
1144 | MODULE = EV PACKAGE = EV::Cleanup PREFIX = ev_cleanup_ |
|
|
1145 | |
|
|
1146 | void ev_cleanup_start (ev_cleanup *w) |
|
|
1147 | CODE: |
|
|
1148 | START (cleanup, w); |
|
|
1149 | |
|
|
1150 | void ev_cleanup_stop (ev_cleanup *w) |
|
|
1151 | CODE: |
|
|
1152 | STOP (cleanup, w); |
|
|
1153 | |
|
|
1154 | void DESTROY (ev_cleanup *w) |
|
|
1155 | CODE: |
|
|
1156 | STOP (cleanup, w); |
|
|
1157 | e_destroy (w); |
|
|
1158 | |
|
|
1159 | int keepalive (ev_watcher *w, int new_value = 0) |
|
|
1160 | CODE: |
|
|
1161 | RETVAL = 0; |
|
|
1162 | OUTPUT: |
|
|
1163 | RETVAL |
|
|
1164 | |
619 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
1165 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
620 | |
1166 | |
|
|
1167 | #if EV_CHILD_ENABLE |
|
|
1168 | |
621 | void ev_child_start (struct ev_child *w) |
1169 | void ev_child_start (ev_child *w) |
|
|
1170 | CODE: |
|
|
1171 | START (child, w); |
622 | |
1172 | |
623 | void ev_child_stop (struct ev_child *w) |
1173 | void ev_child_stop (ev_child *w) |
|
|
1174 | CODE: |
|
|
1175 | STOP (child, w); |
624 | |
1176 | |
625 | void DESTROY (struct ev_child *w) |
1177 | void DESTROY (ev_child *w) |
626 | CODE: |
1178 | CODE: |
627 | ev_child_stop (w); |
1179 | STOP (child, w); |
628 | e_destroy (w); |
1180 | e_destroy (w); |
629 | |
1181 | |
630 | void set (struct ev_child *w, int pid) |
1182 | void set (ev_child *w, int pid, int trace) |
631 | CODE: |
1183 | CODE: |
632 | { |
1184 | RESET (child, w, (w, pid, trace)); |
633 | int active = w->active; |
|
|
634 | if (active) ev_child_stop (w); |
|
|
635 | ev_child_set (w, pid); |
|
|
636 | if (active) ev_child_start (w); |
|
|
637 | } |
|
|
638 | |
1185 | |
639 | int status (struct ev_child *w) |
1186 | int pid (ev_child *w) |
|
|
1187 | ALIAS: |
|
|
1188 | rpid = 1 |
|
|
1189 | rstatus = 2 |
640 | CODE: |
1190 | CODE: |
641 | RETVAL = w->status; |
1191 | RETVAL = ix == 0 ? w->pid |
|
|
1192 | : ix == 1 ? w->rpid |
|
|
1193 | : w->rstatus; |
642 | OUTPUT: |
1194 | OUTPUT: |
643 | RETVAL |
1195 | RETVAL |
644 | |
1196 | |
|
|
1197 | #endif |
|
|
1198 | |
645 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
1199 | MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ |
646 | |
1200 | |
647 | BOOT: |
1201 | void ev_stat_start (ev_stat *w) |
648 | { |
1202 | CODE: |
649 | HV *stash = gv_stashpv ("EV::DNS", 1); |
1203 | START (stat, w); |
650 | |
1204 | |
651 | static const struct { |
1205 | void ev_stat_stop (ev_stat *w) |
652 | const char *name; |
1206 | CODE: |
653 | IV iv; |
1207 | STOP (stat, w); |
654 | } *civ, const_iv[] = { |
|
|
655 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
656 | const_iv (DNS_, ERR_NONE) |
|
|
657 | const_iv (DNS_, ERR_FORMAT) |
|
|
658 | const_iv (DNS_, ERR_SERVERFAILED) |
|
|
659 | const_iv (DNS_, ERR_NOTEXIST) |
|
|
660 | const_iv (DNS_, ERR_NOTIMPL) |
|
|
661 | const_iv (DNS_, ERR_REFUSED) |
|
|
662 | const_iv (DNS_, ERR_TRUNCATED) |
|
|
663 | const_iv (DNS_, ERR_UNKNOWN) |
|
|
664 | const_iv (DNS_, ERR_TIMEOUT) |
|
|
665 | const_iv (DNS_, ERR_SHUTDOWN) |
|
|
666 | const_iv (DNS_, IPv4_A) |
|
|
667 | const_iv (DNS_, PTR) |
|
|
668 | const_iv (DNS_, IPv6_AAAA) |
|
|
669 | const_iv (DNS_, QUERY_NO_SEARCH) |
|
|
670 | const_iv (DNS_, OPTION_SEARCH) |
|
|
671 | const_iv (DNS_, OPTION_NAMESERVERS) |
|
|
672 | const_iv (DNS_, OPTION_MISC) |
|
|
673 | const_iv (DNS_, OPTIONS_ALL) |
|
|
674 | const_iv (DNS_, NO_SEARCH) |
|
|
675 | }; |
|
|
676 | |
1208 | |
677 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1209 | void DESTROY (ev_stat *w) |
678 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1210 | CODE: |
679 | } |
1211 | STOP (stat, w); |
|
|
1212 | e_destroy (w); |
680 | |
1213 | |
681 | int evdns_init () |
1214 | void set (ev_stat *w, SV *path, NV interval) |
|
|
1215 | CODE: |
|
|
1216 | { |
|
|
1217 | sv_setsv (e_fh (w), path); |
|
|
1218 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval)); |
|
|
1219 | } |
682 | |
1220 | |
683 | void evdns_shutdown (int fail_requests = 1) |
1221 | SV *path (ev_stat *w, SV *new_path = 0) |
|
|
1222 | CODE: |
|
|
1223 | { |
|
|
1224 | RETVAL = SvREFCNT_inc (e_fh (w)); |
684 | |
1225 | |
685 | const char *evdns_err_to_string (int err) |
1226 | if (items > 1) |
|
|
1227 | { |
|
|
1228 | SvREFCNT_dec (e_fh (w)); |
|
|
1229 | e_fh (w) = newSVsv (new_path); |
|
|
1230 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval)); |
|
|
1231 | } |
|
|
1232 | } |
|
|
1233 | OUTPUT: |
|
|
1234 | RETVAL |
686 | |
1235 | |
687 | int evdns_nameserver_add (U32 address) |
1236 | NV interval (ev_stat *w, NV new_interval = 0.) |
|
|
1237 | CODE: |
|
|
1238 | { |
|
|
1239 | RETVAL = w->interval; |
688 | |
1240 | |
689 | int evdns_count_nameservers () |
1241 | if (items > 1) |
|
|
1242 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval)); |
|
|
1243 | } |
|
|
1244 | OUTPUT: |
|
|
1245 | RETVAL |
690 | |
1246 | |
691 | int evdns_clear_nameservers_and_suspend () |
1247 | void prev (ev_stat *w) |
692 | |
|
|
693 | int evdns_resume () |
|
|
694 | |
|
|
695 | int evdns_nameserver_ip_add (char *ip_as_string) |
|
|
696 | |
|
|
697 | int evdns_resolve_ipv4 (const char *name, int flags, SV *cb) |
|
|
698 | C_ARGS: name, flags, dns_cb, (void *)SvREFCNT_inc (cb) |
|
|
699 | |
|
|
700 | int evdns_resolve_ipv6 (const char *name, int flags, SV *cb) |
|
|
701 | C_ARGS: name, flags, dns_cb, (void *)SvREFCNT_inc (cb) |
|
|
702 | |
|
|
703 | int evdns_resolve_reverse (SV *addr, int flags, SV *cb) |
|
|
704 | ALIAS: |
1248 | ALIAS: |
705 | evdns_resolve_reverse_ipv6 = 1 |
1249 | stat = 1 |
|
|
1250 | attr = 2 |
|
|
1251 | PPCODE: |
|
|
1252 | { |
|
|
1253 | ev_statdata *s = ix ? &w->attr : &w->prev; |
|
|
1254 | |
|
|
1255 | if (ix == 1) |
|
|
1256 | ev_stat_stat (e_loop (w), w); |
|
|
1257 | else if (!s->st_nlink) |
|
|
1258 | errno = ENOENT; |
|
|
1259 | |
|
|
1260 | PL_statcache.st_dev = s->st_nlink; |
|
|
1261 | PL_statcache.st_ino = s->st_ino; |
|
|
1262 | PL_statcache.st_mode = s->st_mode; |
|
|
1263 | PL_statcache.st_nlink = s->st_nlink; |
|
|
1264 | PL_statcache.st_uid = s->st_uid; |
|
|
1265 | PL_statcache.st_gid = s->st_gid; |
|
|
1266 | PL_statcache.st_rdev = s->st_rdev; |
|
|
1267 | PL_statcache.st_size = s->st_size; |
|
|
1268 | PL_statcache.st_atime = s->st_atime; |
|
|
1269 | PL_statcache.st_mtime = s->st_mtime; |
|
|
1270 | PL_statcache.st_ctime = s->st_ctime; |
|
|
1271 | |
|
|
1272 | if (GIMME_V == G_SCALAR) |
|
|
1273 | XPUSHs (boolSV (s->st_nlink)); |
|
|
1274 | else if (GIMME_V == G_ARRAY && s->st_nlink) |
|
|
1275 | { |
|
|
1276 | EXTEND (SP, 13); |
|
|
1277 | PUSHs (sv_2mortal (newSViv (s->st_dev))); |
|
|
1278 | PUSHs (sv_2mortal (newSViv (s->st_ino))); |
|
|
1279 | PUSHs (sv_2mortal (newSVuv (s->st_mode))); |
|
|
1280 | PUSHs (sv_2mortal (newSVuv (s->st_nlink))); |
|
|
1281 | PUSHs (sv_2mortal (newSViv (s->st_uid))); |
|
|
1282 | PUSHs (sv_2mortal (newSViv (s->st_gid))); |
|
|
1283 | PUSHs (sv_2mortal (newSViv (s->st_rdev))); |
|
|
1284 | PUSHs (sv_2mortal (newSVnv ((NV)s->st_size))); |
|
|
1285 | PUSHs (sv_2mortal (newSVnv (s->st_atime))); |
|
|
1286 | PUSHs (sv_2mortal (newSVnv (s->st_mtime))); |
|
|
1287 | PUSHs (sv_2mortal (newSVnv (s->st_ctime))); |
|
|
1288 | PUSHs (sv_2mortal (newSVuv (4096))); |
|
|
1289 | PUSHs (sv_2mortal (newSVnv ((NV)((s->st_size + 4095) / 4096)))); |
|
|
1290 | } |
|
|
1291 | } |
|
|
1292 | |
|
|
1293 | MODULE = EV PACKAGE = EV::Embed PREFIX = ev_embed_ |
|
|
1294 | |
|
|
1295 | void ev_embed_start (ev_embed *w) |
|
|
1296 | CODE: |
|
|
1297 | START (embed, w); |
|
|
1298 | |
|
|
1299 | void ev_embed_stop (ev_embed *w) |
|
|
1300 | CODE: |
|
|
1301 | STOP (embed, w); |
|
|
1302 | |
|
|
1303 | void DESTROY (ev_embed *w) |
|
|
1304 | CODE: |
|
|
1305 | STOP (embed, w); |
|
|
1306 | e_destroy (w); |
|
|
1307 | |
|
|
1308 | void set (ev_embed *w, struct ev_loop *loop) |
|
|
1309 | CODE: |
|
|
1310 | { |
|
|
1311 | sv_setsv (e_fh (w), ST (1)); |
|
|
1312 | RESET (embed, w, (w, loop)); |
|
|
1313 | } |
|
|
1314 | |
|
|
1315 | SV *other (ev_embed *w) |
|
|
1316 | CODE: |
|
|
1317 | RETVAL = newSVsv (e_fh (w)); |
|
|
1318 | OUTPUT: |
|
|
1319 | RETVAL |
|
|
1320 | |
|
|
1321 | void ev_embed_sweep (ev_embed *w) |
|
|
1322 | C_ARGS: e_loop (w), w |
|
|
1323 | |
|
|
1324 | MODULE = EV PACKAGE = EV::Async PREFIX = ev_async_ |
|
|
1325 | |
|
|
1326 | void ev_async_start (ev_async *w) |
|
|
1327 | CODE: |
|
|
1328 | START (async, w); |
|
|
1329 | |
|
|
1330 | void ev_async_stop (ev_async *w) |
|
|
1331 | CODE: |
|
|
1332 | STOP (async, w); |
|
|
1333 | |
|
|
1334 | void DESTROY (ev_async *w) |
|
|
1335 | CODE: |
|
|
1336 | STOP (async, w); |
|
|
1337 | e_destroy (w); |
|
|
1338 | |
|
|
1339 | void ev_async_send (ev_async *w) |
|
|
1340 | C_ARGS: e_loop (w), w |
|
|
1341 | |
|
|
1342 | SV *ev_async_async_pending (ev_async *w) |
706 | CODE: |
1343 | CODE: |
707 | { |
1344 | RETVAL = boolSV (ev_async_pending (w)); |
708 | STRLEN len; |
1345 | OUTPUT: |
709 | char *data = SvPVbyte (addr, len); |
|
|
710 | if (len != (ix ? 16 : 4)) |
|
|
711 | croak ("ipv4/ipv6 address to be resolved must be given as 4/16 byte octet string"); |
|
|
712 | |
|
|
713 | RETVAL = ix |
1346 | RETVAL |
714 | ? evdns_resolve_reverse_ipv6 ((struct in6_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb)) |
|
|
715 | : evdns_resolve_reverse ((struct in_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb)); |
|
|
716 | } |
|
|
717 | OUTPUT: |
|
|
718 | RETVAL |
|
|
719 | |
1347 | |
720 | int evdns_set_option (char *option, char *val, int flags) |
1348 | #ifndef EV_NO_LOOPS |
721 | |
1349 | |
722 | int evdns_resolv_conf_parse (int flags, const char *filename) |
1350 | MODULE = EV PACKAGE = EV::Loop PREFIX = ev_ |
723 | |
1351 | |
724 | #ifdef MS_WINDOWS |
1352 | SV *new (SV *klass, unsigned int flags = 0) |
|
|
1353 | CODE: |
|
|
1354 | { |
|
|
1355 | struct ev_loop *loop = ev_loop_new (flags); |
725 | |
1356 | |
726 | int evdns_config_windows_nameservers () |
1357 | if (!loop) |
|
|
1358 | XSRETURN_UNDEF; |
|
|
1359 | |
|
|
1360 | RETVAL = sv_bless (newRV_noinc (newSViv (PTR2IV (loop))), stash_loop); |
|
|
1361 | } |
|
|
1362 | OUTPUT: |
|
|
1363 | RETVAL |
|
|
1364 | |
|
|
1365 | void DESTROY (struct ev_loop *loop) |
|
|
1366 | CODE: |
|
|
1367 | /* 1. the default loop shouldn't be freed by destroying it'S pelr loop object */ |
|
|
1368 | /* 2. not doing so helps avoid many global destruction bugs in perl, too */ |
|
|
1369 | if (loop != evapi.default_loop) |
|
|
1370 | ev_loop_destroy (loop); |
|
|
1371 | |
|
|
1372 | void ev_loop_fork (struct ev_loop *loop) |
|
|
1373 | |
|
|
1374 | NV ev_now (struct ev_loop *loop) |
|
|
1375 | |
|
|
1376 | void ev_now_update (struct ev_loop *loop) |
|
|
1377 | |
|
|
1378 | void ev_suspend (struct ev_loop *loop) |
|
|
1379 | |
|
|
1380 | void ev_resume (struct ev_loop *loop) |
|
|
1381 | |
|
|
1382 | void ev_set_io_collect_interval (struct ev_loop *loop, NV interval) |
|
|
1383 | |
|
|
1384 | void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval) |
|
|
1385 | |
|
|
1386 | unsigned int ev_backend (struct ev_loop *loop) |
|
|
1387 | |
|
|
1388 | void ev_verify (struct ev_loop *loop) |
|
|
1389 | ALIAS: |
|
|
1390 | loop_verify = 1 |
|
|
1391 | |
|
|
1392 | unsigned int ev_iteration (struct ev_loop *loop) |
|
|
1393 | ALIAS: |
|
|
1394 | loop_count = 1 |
|
|
1395 | |
|
|
1396 | unsigned int ev_depth (struct ev_loop *loop) |
|
|
1397 | ALIAS: |
|
|
1398 | loop_depth = 1 |
|
|
1399 | |
|
|
1400 | void ev_run (struct ev_loop *loop, int flags = 0) |
|
|
1401 | ALIAS: |
|
|
1402 | loop = 1 |
|
|
1403 | |
|
|
1404 | void ev_break (struct ev_loop *loop, int how = 1) |
|
|
1405 | ALIAS: |
|
|
1406 | unloop = 1 |
|
|
1407 | |
|
|
1408 | void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) |
|
|
1409 | |
|
|
1410 | unsigned int ev_pending_count (struct ev_loop *loop) |
|
|
1411 | |
|
|
1412 | void ev_invoke_pending (struct ev_loop *loop) |
|
|
1413 | |
|
|
1414 | #if 0 |
|
|
1415 | |
|
|
1416 | void ev_feed_signal_event (struct ev_loop *loop, SV *signal) |
|
|
1417 | CODE: |
|
|
1418 | { |
|
|
1419 | Signal signum = s_signum (signal); |
|
|
1420 | CHECK_SIG (signal, signum); |
|
|
1421 | |
|
|
1422 | ev_feed_signal_event (loop, signum); |
|
|
1423 | } |
727 | |
1424 | |
728 | #endif |
1425 | #endif |
729 | |
1426 | |
730 | void evdns_search_clear () |
1427 | ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) |
731 | |
1428 | ALIAS: |
732 | void evdns_search_add (char *domain) |
1429 | io_ns = 1 |
733 | |
1430 | CODE: |
734 | void evdns_search_ndots_set (int ndots) |
|
|
735 | |
|
|
736 | #if 0 |
|
|
737 | |
|
|
738 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
|
|
739 | |
|
|
740 | BOOT: |
|
|
741 | { |
1431 | { |
742 | HV *stash = gv_stashpv ("EV::HTTP", 1); |
1432 | int fd = s_fileno (fh, events & EV_WRITE); |
|
|
1433 | CHECK_FD (fh, fd); |
743 | |
1434 | |
744 | static const struct { |
1435 | RETVAL = e_new (sizeof (ev_io), cb, ST (0)); |
745 | const char *name; |
1436 | e_fh (RETVAL) = newSVsv (fh); |
746 | IV iv; |
1437 | ev_io_set (RETVAL, fd, events); |
747 | } *civ, const_iv[] = { |
1438 | if (!ix) START (io, RETVAL); |
748 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
749 | const_iv (HTTP_, OK) |
|
|
750 | const_iv (HTTP_, NOCONTENT) |
|
|
751 | const_iv (HTTP_, MOVEPERM) |
|
|
752 | const_iv (HTTP_, MOVETEMP) |
|
|
753 | const_iv (HTTP_, NOTMODIFIED) |
|
|
754 | const_iv (HTTP_, BADREQUEST) |
|
|
755 | const_iv (HTTP_, NOTFOUND) |
|
|
756 | const_iv (HTTP_, SERVUNAVAIL) |
|
|
757 | const_iv (EVHTTP_, REQ_OWN_CONNECTION) |
|
|
758 | const_iv (EVHTTP_, PROXY_REQUEST) |
|
|
759 | const_iv (EVHTTP_, REQ_GET) |
|
|
760 | const_iv (EVHTTP_, REQ_POST) |
|
|
761 | const_iv (EVHTTP_, REQ_HEAD) |
|
|
762 | const_iv (EVHTTP_, REQUEST) |
|
|
763 | const_iv (EVHTTP_, RESPONSE) |
|
|
764 | }; |
|
|
765 | |
|
|
766 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
|
|
767 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
768 | } |
1439 | } |
|
|
1440 | OUTPUT: |
|
|
1441 | RETVAL |
769 | |
1442 | |
770 | MODULE = EV PACKAGE = EV::HTTP::Request PREFIX = evhttp_request_ |
1443 | ev_timer *timer (struct ev_loop *loop, NV after, NV repeat, SV *cb) |
|
|
1444 | ALIAS: |
|
|
1445 | timer_ns = 1 |
|
|
1446 | INIT: |
|
|
1447 | CHECK_REPEAT (repeat); |
|
|
1448 | CODE: |
|
|
1449 | RETVAL = e_new (sizeof (ev_timer), cb, ST (0)); |
|
|
1450 | ev_timer_set (RETVAL, after, repeat); |
|
|
1451 | if (!ix) START (timer, RETVAL); |
|
|
1452 | OUTPUT: |
|
|
1453 | RETVAL |
771 | |
1454 | |
772 | #HttpRequest new (SV *klass, SV *cb) |
1455 | SV *periodic (struct ev_loop *loop, NV at, NV interval, SV *reschedule_cb, SV *cb) |
|
|
1456 | ALIAS: |
|
|
1457 | periodic_ns = 1 |
|
|
1458 | INIT: |
|
|
1459 | CHECK_REPEAT (interval); |
|
|
1460 | CODE: |
|
|
1461 | { |
|
|
1462 | ev_periodic *w; |
|
|
1463 | w = e_new (sizeof (ev_periodic), cb, ST (0)); |
|
|
1464 | e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
|
|
1465 | ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0); |
|
|
1466 | RETVAL = e_bless ((ev_watcher *)w, stash_periodic); |
|
|
1467 | if (!ix) START (periodic, w); |
|
|
1468 | } |
|
|
1469 | OUTPUT: |
|
|
1470 | RETVAL |
773 | |
1471 | |
774 | #void DESTROY (struct evhttp_request *req); |
1472 | ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb) |
|
|
1473 | ALIAS: |
|
|
1474 | signal_ns = 1 |
|
|
1475 | CODE: |
|
|
1476 | { |
|
|
1477 | Signal signum = s_signum (signal); |
|
|
1478 | CHECK_SIG (signal, signum); |
775 | |
1479 | |
|
|
1480 | RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); |
|
|
1481 | ev_signal_set (RETVAL, signum); |
|
|
1482 | if (!ix) START_SIGNAL (RETVAL); |
|
|
1483 | } |
|
|
1484 | OUTPUT: |
|
|
1485 | RETVAL |
|
|
1486 | |
|
|
1487 | ev_idle *idle (struct ev_loop *loop, SV *cb) |
|
|
1488 | ALIAS: |
|
|
1489 | idle_ns = 1 |
|
|
1490 | CODE: |
|
|
1491 | RETVAL = e_new (sizeof (ev_idle), cb, ST (0)); |
|
|
1492 | ev_idle_set (RETVAL); |
|
|
1493 | if (!ix) START (idle, RETVAL); |
|
|
1494 | OUTPUT: |
|
|
1495 | RETVAL |
|
|
1496 | |
|
|
1497 | ev_prepare *prepare (struct ev_loop *loop, SV *cb) |
|
|
1498 | ALIAS: |
|
|
1499 | prepare_ns = 1 |
|
|
1500 | CODE: |
|
|
1501 | RETVAL = e_new (sizeof (ev_prepare), cb, ST (0)); |
|
|
1502 | ev_prepare_set (RETVAL); |
|
|
1503 | if (!ix) START (prepare, RETVAL); |
|
|
1504 | OUTPUT: |
|
|
1505 | RETVAL |
|
|
1506 | |
|
|
1507 | ev_check *check (struct ev_loop *loop, SV *cb) |
|
|
1508 | ALIAS: |
|
|
1509 | check_ns = 1 |
|
|
1510 | CODE: |
|
|
1511 | RETVAL = e_new (sizeof (ev_check), cb, ST (0)); |
|
|
1512 | ev_check_set (RETVAL); |
|
|
1513 | if (!ix) START (check, RETVAL); |
|
|
1514 | OUTPUT: |
|
|
1515 | RETVAL |
|
|
1516 | |
|
|
1517 | ev_fork *fork (struct ev_loop *loop, SV *cb) |
|
|
1518 | ALIAS: |
|
|
1519 | fork_ns = 1 |
|
|
1520 | CODE: |
|
|
1521 | RETVAL = e_new (sizeof (ev_fork), cb, ST (0)); |
|
|
1522 | ev_fork_set (RETVAL); |
|
|
1523 | if (!ix) START (fork, RETVAL); |
|
|
1524 | OUTPUT: |
|
|
1525 | RETVAL |
|
|
1526 | |
|
|
1527 | ev_cleanup *cleanup (struct ev_loop *loop, SV *cb) |
|
|
1528 | ALIAS: |
|
|
1529 | cleanup_ns = 1 |
|
|
1530 | CODE: |
|
|
1531 | RETVAL = e_new (sizeof (ev_cleanup), cb, ST (0)); |
|
|
1532 | ev_cleanup_set (RETVAL); |
|
|
1533 | if (!ix) START (cleanup, RETVAL); |
|
|
1534 | OUTPUT: |
|
|
1535 | RETVAL |
|
|
1536 | |
|
|
1537 | ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) |
|
|
1538 | ALIAS: |
|
|
1539 | child_ns = 1 |
|
|
1540 | CODE: |
|
|
1541 | #if EV_CHILD_ENABLE |
|
|
1542 | RETVAL = e_new (sizeof (ev_child), cb, ST (0)); |
|
|
1543 | ev_child_set (RETVAL, pid, trace); |
|
|
1544 | if (!ix) START (child, RETVAL); |
|
|
1545 | #else |
|
|
1546 | croak ("EV::child watchers not supported on this platform"); |
776 | #endif |
1547 | #endif |
|
|
1548 | OUTPUT: |
|
|
1549 | RETVAL |
777 | |
1550 | |
|
|
1551 | ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb) |
|
|
1552 | ALIAS: |
|
|
1553 | stat_ns = 1 |
|
|
1554 | CODE: |
|
|
1555 | RETVAL = e_new (sizeof (ev_stat), cb, ST (0)); |
|
|
1556 | e_fh (RETVAL) = newSVsv (path); |
|
|
1557 | ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval); |
|
|
1558 | if (!ix) START (stat, RETVAL); |
|
|
1559 | OUTPUT: |
|
|
1560 | RETVAL |
778 | |
1561 | |
|
|
1562 | ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0) |
|
|
1563 | ALIAS: |
|
|
1564 | embed_ns = 1 |
|
|
1565 | CODE: |
|
|
1566 | { |
|
|
1567 | if (!(ev_backend (other) & ev_embeddable_backends ())) |
|
|
1568 | croak ("passed loop is not embeddable via EV::embed,"); |
779 | |
1569 | |
|
|
1570 | RETVAL = e_new (sizeof (ev_embed), cb, ST (0)); |
|
|
1571 | e_fh (RETVAL) = newSVsv (ST (1)); |
|
|
1572 | ev_embed_set (RETVAL, other); |
|
|
1573 | if (!ix) START (embed, RETVAL); |
|
|
1574 | } |
|
|
1575 | OUTPUT: |
|
|
1576 | RETVAL |
780 | |
1577 | |
|
|
1578 | ev_async *async (struct ev_loop *loop, SV *cb) |
|
|
1579 | ALIAS: |
|
|
1580 | async_ns = 1 |
|
|
1581 | CODE: |
|
|
1582 | RETVAL = e_new (sizeof (ev_async), cb, ST (0)); |
|
|
1583 | ev_async_set (RETVAL); |
|
|
1584 | if (!ix) START (async, RETVAL); |
|
|
1585 | OUTPUT: |
|
|
1586 | RETVAL |
781 | |
1587 | |
|
|
1588 | void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb) |
|
|
1589 | CODE: |
|
|
1590 | ev_once ( |
|
|
1591 | loop, |
|
|
1592 | s_fileno (fh, events & EV_WRITE), events, |
|
|
1593 | SvOK (timeout) ? SvNV (timeout) : -1., |
|
|
1594 | e_once_cb, |
|
|
1595 | newSVsv (cb) |
|
|
1596 | ); |
782 | |
1597 | |
|
|
1598 | #endif |
783 | |
1599 | |
784 | |
|
|