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