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 <math.h> |
|
|
6 | #include <netinet/in.h> |
5 | /*#include <netinet/in.h>*/ |
7 | |
6 | |
8 | #define TIMEOUT_NONE HUGE_VAL |
7 | #define EV_PROTOTYPES 1 |
9 | |
|
|
10 | #define EV_COMMON \ |
|
|
11 | SV *self; /* contains this struct */ \ |
|
|
12 | SV *cb_sv, *fh; |
|
|
13 | |
|
|
14 | #include "EV/EVAPI.h" |
8 | #include "EV/EVAPI.h" |
15 | |
9 | |
16 | #include "libev/ev.c" |
10 | #include "libev/ev.c" |
|
|
11 | #include "libev/event.h" |
|
|
12 | #include "libev/event.c" |
|
|
13 | #include "libev/evdns.c" |
17 | |
14 | |
18 | typedef int Signal; |
15 | typedef int Signal; |
19 | |
16 | |
20 | static struct EVAPI evapi; |
17 | static struct EVAPI evapi; |
21 | |
18 | |
22 | static HV |
19 | static HV |
23 | *stash_watcher, |
20 | *stash_watcher, |
24 | *stash_io, |
21 | *stash_io, |
25 | *stash_time, |
|
|
26 | *stash_timer, |
22 | *stash_timer, |
27 | *stash_periodic, |
23 | *stash_periodic, |
28 | *stash_signal, |
24 | *stash_signal, |
29 | *stash_idle, |
25 | *stash_idle, |
|
|
26 | *stash_prepare, |
30 | *stash_check; |
27 | *stash_check, |
|
|
28 | *stash_child; |
31 | |
29 | |
32 | static int |
30 | static int |
33 | sv_signum (SV *sig) |
31 | sv_signum (SV *sig) |
34 | { |
32 | { |
35 | int signum; |
33 | int signum; |
36 | |
34 | |
37 | if (SvIV (sig) > 0) |
35 | SvGETMAGIC (sig); |
38 | return SvIV (sig); |
|
|
39 | |
36 | |
40 | for (signum = 1; signum < SIG_SIZE; ++signum) |
37 | for (signum = 1; signum < SIG_SIZE; ++signum) |
41 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
38 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
42 | return signum; |
39 | return signum; |
43 | |
40 | |
|
|
41 | if (SvIV (sig) > 0) |
|
|
42 | return SvIV (sig); |
|
|
43 | |
44 | return -1; |
44 | return -1; |
45 | } |
|
|
46 | |
|
|
47 | static void |
|
|
48 | api_once (int fd, short events, double timeout, void (*cb)(int, short, void *), void *arg) |
|
|
49 | { |
|
|
50 | #if 0 |
|
|
51 | if (timeout >= 0.) |
|
|
52 | { |
|
|
53 | struct timeval tv; |
|
|
54 | tv_set (&tv, timeout); |
|
|
55 | event_once (fd, events, cb, arg, &tv); |
|
|
56 | } |
|
|
57 | else |
|
|
58 | event_once (fd, events, cb, arg, 0); |
|
|
59 | #endif |
|
|
60 | } |
45 | } |
61 | |
46 | |
62 | ///////////////////////////////////////////////////////////////////////////// |
47 | ///////////////////////////////////////////////////////////////////////////// |
63 | // Event |
48 | // Event |
64 | |
49 | |
… | |
… | |
73 | fh = SvRV (fh); |
58 | fh = SvRV (fh); |
74 | |
59 | |
75 | if (SvTYPE (fh) == SVt_PVGV) |
60 | if (SvTYPE (fh) == SVt_PVGV) |
76 | return PerlIO_fileno (IoIFP (sv_2io (fh))); |
61 | return PerlIO_fileno (IoIFP (sv_2io (fh))); |
77 | |
62 | |
78 | if (SvIOK (fh)) |
63 | if ((SvIV (fh) >= 0) && (SvIV (fh) < 0x7ffffff)) |
79 | return SvIV (fh); |
64 | return SvIV (fh); |
80 | |
65 | |
81 | return -1; |
66 | return -1; |
82 | } |
67 | } |
83 | |
68 | |
… | |
… | |
89 | SvPOK_only (self); |
74 | SvPOK_only (self); |
90 | SvCUR_set (self, size); |
75 | SvCUR_set (self, size); |
91 | |
76 | |
92 | w = (struct ev_watcher *)SvPVX (self); |
77 | w = (struct ev_watcher *)SvPVX (self); |
93 | |
78 | |
94 | evw_init (w, e_cb); |
79 | ev_watcher_init (w, e_cb); |
95 | |
80 | |
96 | w->fh = 0; |
81 | w->fh = 0; |
97 | w->cb_sv = newSVsv (cb_sv); |
82 | w->cb_sv = newSVsv (cb_sv); |
98 | w->self = self; |
83 | w->self = self; |
99 | |
84 | |
100 | return (void *)w; |
85 | return (void *)w; |
|
|
86 | } |
|
|
87 | |
|
|
88 | static void * |
|
|
89 | e_destroy (void *w_) |
|
|
90 | { |
|
|
91 | struct ev_watcher *w = w_; |
|
|
92 | |
|
|
93 | SvREFCNT_dec (w->fh ); w->fh = 0; |
|
|
94 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
101 | } |
95 | } |
102 | |
96 | |
103 | static SV * |
97 | static SV * |
104 | e_bless (struct ev_watcher *w, HV *stash) |
98 | e_bless (struct ev_watcher *w, HV *stash) |
105 | { |
99 | { |
… | |
… | |
120 | static void |
114 | static void |
121 | e_cb (struct ev_watcher *w, int revents) |
115 | e_cb (struct ev_watcher *w, int revents) |
122 | { |
116 | { |
123 | dSP; |
117 | dSP; |
124 | I32 mark = SP - PL_stack_base; |
118 | I32 mark = SP - PL_stack_base; |
125 | SV *sv_self, *sv_events; |
119 | SV *sv_self, *sv_events, *sv_status = 0; |
126 | static SV *sv_events_cache; |
120 | static SV *sv_events_cache; |
127 | |
121 | |
128 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
122 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
129 | |
123 | |
130 | if (sv_events_cache) |
124 | if (sv_events_cache) |
… | |
… | |
137 | |
131 | |
138 | PUSHMARK (SP); |
132 | PUSHMARK (SP); |
139 | EXTEND (SP, 2); |
133 | EXTEND (SP, 2); |
140 | PUSHs (sv_self); |
134 | PUSHs (sv_self); |
141 | PUSHs (sv_events); |
135 | PUSHs (sv_events); |
|
|
136 | |
|
|
137 | if (revents & EV_CHILD) |
|
|
138 | XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status)); |
|
|
139 | |
142 | PUTBACK; |
140 | PUTBACK; |
143 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
141 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
144 | SP = PL_stack_base + mark; PUTBACK; |
142 | SP = PL_stack_base + mark; PUTBACK; |
145 | |
143 | |
146 | SvREFCNT_dec (sv_self); |
144 | SvREFCNT_dec (sv_self); |
|
|
145 | SvREFCNT_dec (sv_status); |
147 | |
146 | |
148 | if (sv_events_cache) |
147 | if (sv_events_cache) |
149 | SvREFCNT_dec (sv_events); |
148 | SvREFCNT_dec (sv_events); |
150 | else |
149 | else |
151 | sv_events_cache = sv_events; |
150 | sv_events_cache = sv_events; |
… | |
… | |
157 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
156 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
158 | SP = PL_stack_base + mark; PUTBACK; |
157 | SP = PL_stack_base + mark; PUTBACK; |
159 | } |
158 | } |
160 | } |
159 | } |
161 | |
160 | |
162 | #if 0 |
|
|
163 | ///////////////////////////////////////////////////////////////////////////// |
161 | ///////////////////////////////////////////////////////////////////////////// |
164 | // DNS |
162 | // DNS |
165 | |
163 | |
166 | static void |
164 | static void |
167 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
165 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
… | |
… | |
209 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
207 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
210 | } |
208 | } |
211 | |
209 | |
212 | LEAVE; |
210 | LEAVE; |
213 | } |
211 | } |
214 | #endif |
212 | |
|
|
213 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
|
|
214 | croak (# repeat " value must be >= 0"); |
|
|
215 | |
|
|
216 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
|
|
217 | croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); |
215 | |
218 | |
216 | ///////////////////////////////////////////////////////////////////////////// |
219 | ///////////////////////////////////////////////////////////////////////////// |
217 | // XS interface functions |
220 | // XS interface functions |
218 | |
221 | |
219 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
222 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
|
|
223 | |
|
|
224 | PROTOTYPES: ENABLE |
220 | |
225 | |
221 | BOOT: |
226 | BOOT: |
222 | { |
227 | { |
223 | int i; |
228 | int i; |
224 | HV *stash = gv_stashpv ("EV", 1); |
229 | HV *stash = gv_stashpv ("EV", 1); |
… | |
… | |
226 | static const struct { |
231 | static const struct { |
227 | const char *name; |
232 | const char *name; |
228 | IV iv; |
233 | IV iv; |
229 | } *civ, const_iv[] = { |
234 | } *civ, const_iv[] = { |
230 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
235 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
236 | const_iv (EV_, UNDEF) |
231 | const_iv (EV_, NONE) |
237 | const_iv (EV_, NONE) |
232 | const_iv (EV_, TIMEOUT) |
238 | const_iv (EV_, TIMEOUT) |
233 | const_iv (EV_, READ) |
239 | const_iv (EV_, READ) |
234 | const_iv (EV_, WRITE) |
240 | const_iv (EV_, WRITE) |
235 | const_iv (EV_, SIGNAL) |
241 | const_iv (EV_, SIGNAL) |
236 | const_iv (EV_, IDLE) |
242 | const_iv (EV_, IDLE) |
237 | const_iv (EV_, CHECK) |
243 | const_iv (EV_, CHECK) |
|
|
244 | const_iv (EV_, ERROR) |
238 | |
245 | |
239 | const_iv (EV, LOOP_ONESHOT) |
246 | const_iv (EV, LOOP_ONESHOT) |
240 | const_iv (EV, LOOP_NONBLOCK) |
247 | const_iv (EV, LOOP_NONBLOCK) |
241 | |
248 | |
242 | const_iv (EV, METHOD_NONE) |
249 | const_iv (EV, METHOD_NONE) |
… | |
… | |
246 | |
253 | |
247 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
254 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
248 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
255 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
249 | |
256 | |
250 | stash_watcher = gv_stashpv ("EV::Watcher" , 1); |
257 | stash_watcher = gv_stashpv ("EV::Watcher" , 1); |
251 | stash_io = gv_stashpv ("EV::IO" , 1); |
258 | stash_io = gv_stashpv ("EV::Io" , 1); |
252 | stash_time = gv_stashpv ("EV::Time" , 1); |
|
|
253 | stash_timer = gv_stashpv ("EV::Timer" , 1); |
259 | stash_timer = gv_stashpv ("EV::Timer" , 1); |
254 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
260 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
255 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
261 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
256 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
262 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
|
|
263 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
257 | stash_check = gv_stashpv ("EV::Check" , 1); |
264 | stash_check = gv_stashpv ("EV::Check" , 1); |
|
|
265 | stash_child = gv_stashpv ("EV::Child" , 1); |
258 | |
266 | |
259 | { |
267 | { |
260 | SV *sv = perl_get_sv ("EV::API", TRUE); |
268 | SV *sv = perl_get_sv ("EV::API", TRUE); |
261 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
269 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
262 | |
270 | |
263 | /* the poor man's shared library emulator */ |
271 | /* the poor man's shared library emulator */ |
264 | evapi.ver = EV_API_VERSION; |
272 | evapi.ver = EV_API_VERSION; |
265 | evapi.rev = EV_API_REVISION; |
273 | evapi.rev = EV_API_REVISION; |
266 | evapi.once = api_once; |
|
|
267 | evapi.sv_fileno = sv_fileno; |
274 | evapi.sv_fileno = sv_fileno; |
268 | evapi.sv_signum = sv_signum; |
275 | evapi.sv_signum = sv_signum; |
269 | evapi.now = &ev_now; |
276 | evapi.now = &ev_now; |
270 | evapi.method = &ev_method; |
277 | evapi.method = &ev_method; |
271 | evapi.loop_done = &ev_loop_done; |
278 | evapi.loop_done = &ev_loop_done; |
272 | evapi.time = ev_time; |
279 | evapi.time = ev_time; |
273 | evapi.loop = ev_loop; |
280 | evapi.loop = ev_loop; |
|
|
281 | evapi.once = ev_once; |
274 | evapi.io_start = evio_start; |
282 | evapi.io_start = ev_io_start; |
275 | evapi.io_stop = evio_stop; |
283 | evapi.io_stop = ev_io_stop; |
276 | evapi.timer_start = evtimer_start; |
284 | evapi.timer_start = ev_timer_start; |
277 | evapi.timer_stop = evtimer_stop; |
285 | evapi.timer_stop = ev_timer_stop; |
278 | evapi.timer_again = evtimer_again; |
286 | evapi.timer_again = ev_timer_again; |
279 | evapi.periodic_start = evperiodic_start; |
287 | evapi.periodic_start = ev_periodic_start; |
280 | evapi.periodic_stop = evperiodic_stop; |
288 | evapi.periodic_stop = ev_periodic_stop; |
281 | evapi.signal_start = evsignal_start; |
289 | evapi.signal_start = ev_signal_start; |
282 | evapi.signal_stop = evsignal_stop; |
290 | evapi.signal_stop = ev_signal_stop; |
283 | evapi.idle_start = evidle_start; |
291 | evapi.idle_start = ev_idle_start; |
284 | evapi.idle_stop = evidle_stop; |
292 | evapi.idle_stop = ev_idle_stop; |
|
|
293 | evapi.prepare_start = ev_prepare_start; |
|
|
294 | evapi.prepare_stop = ev_prepare_stop; |
285 | evapi.check_start = evcheck_start; |
295 | evapi.check_start = ev_check_start; |
286 | evapi.check_stop = evcheck_stop; |
296 | evapi.check_stop = ev_check_stop; |
|
|
297 | evapi.child_start = ev_child_start; |
|
|
298 | evapi.child_stop = ev_child_stop; |
287 | |
299 | |
288 | sv_setiv (sv, (IV)&evapi); |
300 | sv_setiv (sv, (IV)&evapi); |
289 | SvREADONLY_on (sv); |
301 | SvREADONLY_on (sv); |
290 | } |
302 | } |
|
|
303 | |
|
|
304 | pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); |
291 | } |
305 | } |
292 | |
306 | |
293 | NV ev_now () |
307 | NV ev_now () |
294 | CODE: |
308 | CODE: |
295 | RETVAL = ev_now; |
309 | RETVAL = ev_now; |
… | |
… | |
314 | |
328 | |
315 | struct ev_io *io (SV *fh, int events, SV *cb) |
329 | struct ev_io *io (SV *fh, int events, SV *cb) |
316 | ALIAS: |
330 | ALIAS: |
317 | io_ns = 1 |
331 | io_ns = 1 |
318 | CODE: |
332 | CODE: |
|
|
333 | { |
|
|
334 | int fd = sv_fileno (fh); |
|
|
335 | CHECK_FD (fh, fd); |
|
|
336 | |
319 | RETVAL = e_new (sizeof (struct ev_io), cb); |
337 | RETVAL = e_new (sizeof (struct ev_io), cb); |
320 | RETVAL->fh = newSVsv (fh); |
338 | RETVAL->fh = newSVsv (fh); |
321 | evio_set (RETVAL, sv_fileno (RETVAL->fh), events); |
339 | ev_io_set (RETVAL, fd, events); |
322 | if (!ix) evio_start (RETVAL); |
340 | if (!ix) ev_io_start (RETVAL); |
|
|
341 | } |
323 | OUTPUT: |
342 | OUTPUT: |
324 | RETVAL |
343 | RETVAL |
325 | |
344 | |
326 | struct ev_timer *timer (NV after, NV repeat, SV *cb) |
345 | struct ev_timer *timer (NV after, NV repeat, SV *cb) |
327 | ALIAS: |
346 | ALIAS: |
328 | timer_ns = 1 |
347 | timer_ns = 1 |
|
|
348 | INIT: |
|
|
349 | CHECK_REPEAT (repeat); |
329 | CODE: |
350 | CODE: |
330 | RETVAL = e_new (sizeof (struct ev_timer), cb); |
351 | RETVAL = e_new (sizeof (struct ev_timer), cb); |
331 | evtimer_set (RETVAL, after, repeat); |
352 | ev_timer_set (RETVAL, after, repeat); |
332 | if (!ix) evtimer_start (RETVAL); |
353 | if (!ix) ev_timer_start (RETVAL); |
333 | OUTPUT: |
354 | OUTPUT: |
334 | RETVAL |
355 | RETVAL |
335 | |
356 | |
336 | struct ev_periodic *periodic (NV at, NV interval, SV *cb) |
357 | struct ev_periodic *periodic (NV at, NV interval, SV *cb) |
337 | ALIAS: |
358 | ALIAS: |
338 | periodic_ns = 1 |
359 | periodic_ns = 1 |
|
|
360 | INIT: |
|
|
361 | CHECK_REPEAT (interval); |
339 | CODE: |
362 | CODE: |
340 | RETVAL = e_new (sizeof (struct ev_periodic), cb); |
363 | RETVAL = e_new (sizeof (struct ev_periodic), cb); |
341 | evperiodic_set (RETVAL, at, interval); |
364 | ev_periodic_set (RETVAL, at, interval); |
342 | if (!ix) evperiodic_start (RETVAL); |
365 | if (!ix) ev_periodic_start (RETVAL); |
343 | OUTPUT: |
366 | OUTPUT: |
344 | RETVAL |
367 | RETVAL |
345 | |
368 | |
346 | struct ev_signal *signal (Signal signum, SV *cb) |
369 | struct ev_signal *signal (Signal signum, SV *cb) |
347 | ALIAS: |
370 | ALIAS: |
348 | signal_ns = 1 |
371 | signal_ns = 1 |
349 | CODE: |
372 | CODE: |
350 | RETVAL = e_new (sizeof (struct ev_signal), cb); |
373 | RETVAL = e_new (sizeof (struct ev_signal), cb); |
351 | evsignal_set (RETVAL, signum); |
374 | ev_signal_set (RETVAL, signum); |
352 | if (!ix) evsignal_start (RETVAL); |
375 | if (!ix) ev_signal_start (RETVAL); |
353 | OUTPUT: |
376 | OUTPUT: |
354 | RETVAL |
377 | RETVAL |
355 | |
378 | |
356 | struct ev_idle *idle (SV *cb) |
379 | struct ev_idle *idle (SV *cb) |
357 | ALIAS: |
380 | ALIAS: |
358 | idle_ns = 1 |
381 | idle_ns = 1 |
359 | CODE: |
382 | CODE: |
360 | RETVAL = e_new (sizeof (struct ev_idle), cb); |
383 | RETVAL = e_new (sizeof (struct ev_idle), cb); |
361 | evidle_set (RETVAL); |
384 | ev_idle_set (RETVAL); |
362 | if (!ix) evidle_start (RETVAL); |
385 | if (!ix) ev_idle_start (RETVAL); |
|
|
386 | OUTPUT: |
|
|
387 | RETVAL |
|
|
388 | |
|
|
389 | struct ev_prepare *prepare (SV *cb) |
|
|
390 | ALIAS: |
|
|
391 | prepare_ns = 1 |
|
|
392 | CODE: |
|
|
393 | RETVAL = e_new (sizeof (struct ev_prepare), cb); |
|
|
394 | ev_prepare_set (RETVAL); |
|
|
395 | if (!ix) ev_prepare_start (RETVAL); |
363 | OUTPUT: |
396 | OUTPUT: |
364 | RETVAL |
397 | RETVAL |
365 | |
398 | |
366 | struct ev_check *check (SV *cb) |
399 | struct ev_check *check (SV *cb) |
367 | ALIAS: |
400 | ALIAS: |
368 | check_ns = 1 |
401 | check_ns = 1 |
369 | CODE: |
402 | CODE: |
370 | RETVAL = e_new (sizeof (struct ev_check), cb); |
403 | RETVAL = e_new (sizeof (struct ev_check), cb); |
371 | evcheck_set (RETVAL); |
404 | ev_check_set (RETVAL); |
372 | if (!ix) evcheck_start (RETVAL); |
405 | if (!ix) ev_check_start (RETVAL); |
|
|
406 | OUTPUT: |
|
|
407 | RETVAL |
|
|
408 | |
|
|
409 | struct ev_child *child (int pid, SV *cb) |
|
|
410 | ALIAS: |
|
|
411 | check_ns = 1 |
|
|
412 | CODE: |
|
|
413 | RETVAL = e_new (sizeof (struct ev_check), cb); |
|
|
414 | ev_child_set (RETVAL, pid); |
|
|
415 | if (!ix) ev_child_start (RETVAL); |
373 | OUTPUT: |
416 | OUTPUT: |
374 | RETVAL |
417 | RETVAL |
375 | |
418 | |
376 | |
419 | |
377 | PROTOTYPES: DISABLE |
420 | PROTOTYPES: DISABLE |
… | |
… | |
389 | sv_setsv (w->cb_sv, new_cb); |
432 | sv_setsv (w->cb_sv, new_cb); |
390 | } |
433 | } |
391 | OUTPUT: |
434 | OUTPUT: |
392 | RETVAL |
435 | RETVAL |
393 | |
436 | |
|
|
437 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
|
|
438 | CODE: |
|
|
439 | w->cb (w, revents); |
|
|
440 | |
394 | MODULE = EV PACKAGE = EV::IO PREFIX = evio_ |
441 | MODULE = EV PACKAGE = EV::Io PREFIX = ev_io_ |
395 | |
442 | |
396 | void evio_start (struct ev_io *w) |
443 | void ev_io_start (struct ev_io *w) |
397 | |
444 | |
398 | void evio_stop (struct ev_io *w) |
445 | void ev_io_stop (struct ev_io *w) |
|
|
446 | |
|
|
447 | void DESTROY (struct ev_io *w) |
|
|
448 | CODE: |
|
|
449 | ev_io_stop (w); |
|
|
450 | e_destroy (w); |
399 | |
451 | |
400 | void set (struct ev_io *w, SV *fh, int events) |
452 | void set (struct ev_io *w, SV *fh, int events) |
401 | CODE: |
453 | CODE: |
402 | { |
454 | { |
403 | int active = w->active; |
455 | int active = w->active; |
|
|
456 | int fd = sv_fileno (fh); |
|
|
457 | CHECK_FD (fh, fd); |
|
|
458 | |
404 | if (active) evio_stop (w); |
459 | if (active) ev_io_stop (w); |
405 | |
460 | |
406 | sv_setsv (w->fh, fh); |
461 | sv_setsv (w->fh, fh); |
407 | evio_set (w, sv_fileno (w->fh), events); |
462 | ev_io_set (w, fd, events); |
408 | |
463 | |
409 | if (active) evio_start (w); |
464 | if (active) ev_io_start (w); |
410 | } |
465 | } |
411 | |
466 | |
412 | SV *fh (struct ev_io *w, SV *new_fh = 0) |
467 | SV *fh (struct ev_io *w, SV *new_fh = 0) |
413 | CODE: |
468 | CODE: |
414 | { |
469 | { |
415 | RETVAL = newSVsv (w->fh); |
470 | RETVAL = newSVsv (w->fh); |
416 | |
471 | |
417 | if (items > 1) |
472 | if (items > 1) |
418 | { |
473 | { |
419 | int active = w->active; |
474 | int active = w->active; |
420 | if (active) evio_stop (w); |
475 | if (active) ev_io_stop (w); |
421 | |
476 | |
422 | sv_setsv (w->fh, new_fh); |
477 | sv_setsv (w->fh, new_fh); |
423 | evio_set (w, sv_fileno (w->fh), w->events); |
478 | ev_io_set (w, sv_fileno (w->fh), w->events); |
424 | |
479 | |
425 | if (active) evio_start (w); |
480 | if (active) ev_io_start (w); |
426 | } |
481 | } |
427 | } |
482 | } |
428 | OUTPUT: |
483 | OUTPUT: |
429 | RETVAL |
484 | RETVAL |
430 | |
485 | |
431 | short events (struct ev_io *w, short new_events = EV_UNDEF) |
486 | int events (struct ev_io *w, int new_events = EV_UNDEF) |
432 | CODE: |
487 | CODE: |
433 | { |
488 | { |
434 | RETVAL = w->events; |
489 | RETVAL = w->events; |
435 | |
490 | |
436 | if (items > 1) |
491 | if (items > 1) |
437 | { |
492 | { |
438 | int active = w->active; |
493 | int active = w->active; |
439 | if (active) evio_stop (w); |
494 | if (active) ev_io_stop (w); |
440 | |
495 | |
441 | evio_set (w, w->fd, new_events); |
496 | ev_io_set (w, w->fd, new_events); |
442 | |
497 | |
443 | if (active) evio_start (w); |
498 | if (active) ev_io_start (w); |
444 | } |
499 | } |
445 | } |
500 | } |
446 | OUTPUT: |
501 | OUTPUT: |
447 | RETVAL |
502 | RETVAL |
448 | |
503 | |
449 | MODULE = EV PACKAGE = EV::Signal PREFIX = evsignal_ |
504 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
450 | |
505 | |
451 | void evsignal_start (struct ev_signal *w) |
506 | void ev_signal_start (struct ev_signal *w) |
452 | |
507 | |
453 | void evsignal_stop (struct ev_signal *w) |
508 | void ev_signal_stop (struct ev_signal *w) |
454 | |
509 | |
|
|
510 | void DESTROY (struct ev_signal *w) |
|
|
511 | CODE: |
|
|
512 | ev_signal_stop (w); |
|
|
513 | e_destroy (w); |
|
|
514 | |
455 | void set (struct ev_signal *w, SV *signal = 0) |
515 | void set (struct ev_signal *w, SV *signal) |
456 | CODE: |
516 | CODE: |
457 | { |
517 | { |
458 | Signal signum = sv_signum (signal); /* may croak here */ |
518 | Signal signum = sv_signum (signal); /* may croak here */ |
459 | int active = w->active; |
519 | int active = w->active; |
460 | |
520 | |
461 | if (active) evsignal_stop (w); |
521 | if (active) ev_signal_stop (w); |
|
|
522 | |
462 | evsignal_set (w, signum); |
523 | ev_signal_set (w, signum); |
|
|
524 | |
463 | if (active) evsignal_start (w); |
525 | if (active) ev_signal_start (w); |
464 | } |
526 | } |
|
|
527 | |
|
|
528 | int signal (struct ev_signal *w, SV *new_signal = 0) |
|
|
529 | CODE: |
|
|
530 | { |
|
|
531 | RETVAL = w->signum; |
|
|
532 | |
|
|
533 | if (items > 1) |
|
|
534 | { |
|
|
535 | Signal signum = sv_signum (new_signal); /* may croak here */ |
|
|
536 | int active = w->active; |
|
|
537 | if (active) ev_signal_stop (w); |
|
|
538 | |
|
|
539 | ev_signal_set (w, signum); |
|
|
540 | |
|
|
541 | if (active) ev_signal_start (w); |
|
|
542 | } |
|
|
543 | } |
|
|
544 | OUTPUT: |
|
|
545 | RETVAL |
465 | |
546 | |
466 | MODULE = EV PACKAGE = EV::Time |
547 | MODULE = EV PACKAGE = EV::Time |
467 | |
548 | |
468 | MODULE = EV PACKAGE = EV::Timer PREFIX = evtimer_ |
549 | MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ |
469 | |
550 | |
470 | void evtimer_start (struct ev_timer *w) |
551 | void ev_timer_start (struct ev_timer *w) |
|
|
552 | INIT: |
|
|
553 | CHECK_REPEAT (w->repeat); |
471 | |
554 | |
472 | void evtimer_stop (struct ev_timer *w) |
555 | void ev_timer_stop (struct ev_timer *w) |
473 | |
556 | |
474 | void evtimer_again (struct ev_timer *w) |
557 | void ev_timer_again (struct ev_timer *w) |
|
|
558 | INIT: |
|
|
559 | CHECK_REPEAT (w->repeat); |
|
|
560 | |
|
|
561 | void DESTROY (struct ev_timer *w) |
|
|
562 | CODE: |
|
|
563 | ev_timer_stop (w); |
|
|
564 | e_destroy (w); |
475 | |
565 | |
476 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
566 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
|
|
567 | INIT: |
|
|
568 | CHECK_REPEAT (repeat); |
477 | CODE: |
569 | CODE: |
478 | { |
570 | { |
479 | int active = w->active; |
571 | int active = w->active; |
480 | if (active) evtimer_stop (w); |
572 | if (active) ev_timer_stop (w); |
481 | evtimer_set (w, after, repeat); |
573 | ev_timer_set (w, after, repeat); |
482 | if (active) evtimer_start (w); |
574 | if (active) ev_timer_start (w); |
483 | } |
575 | } |
484 | |
576 | |
485 | MODULE = EV PACKAGE = EV::Periodic PREFIX = evperiodic_ |
577 | MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ |
486 | |
578 | |
487 | void evperiodic_start (struct ev_periodic *w) |
579 | void ev_periodic_start (struct ev_periodic *w) |
|
|
580 | INIT: |
|
|
581 | CHECK_REPEAT (w->interval); |
488 | |
582 | |
489 | void evperiodic_stop (struct ev_periodic *w) |
583 | void ev_periodic_stop (struct ev_periodic *w) |
|
|
584 | |
|
|
585 | void DESTROY (struct ev_periodic *w) |
|
|
586 | CODE: |
|
|
587 | ev_periodic_stop (w); |
|
|
588 | e_destroy (w); |
490 | |
589 | |
491 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
590 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
|
|
591 | INIT: |
|
|
592 | CHECK_REPEAT (interval); |
492 | CODE: |
593 | CODE: |
493 | { |
594 | { |
494 | int active = w->active; |
595 | int active = w->active; |
495 | if (active) evperiodic_stop (w); |
596 | if (active) ev_periodic_stop (w); |
|
|
597 | |
496 | evperiodic_set (w, at, interval); |
598 | ev_periodic_set (w, at, interval); |
|
|
599 | |
497 | if (active) evperiodic_start (w); |
600 | if (active) ev_periodic_start (w); |
498 | } |
601 | } |
499 | |
602 | |
500 | MODULE = EV PACKAGE = EV::Idle PREFIX = evidle_ |
603 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
501 | |
604 | |
502 | void evidle_start (struct ev_idle *w) |
605 | void ev_idle_start (struct ev_idle *w) |
503 | |
606 | |
504 | void evidle_stop (struct ev_idle *w) |
607 | void ev_idle_stop (struct ev_idle *w) |
505 | |
608 | |
|
|
609 | void DESTROY (struct ev_idle *w) |
|
|
610 | CODE: |
|
|
611 | ev_idle_stop (w); |
|
|
612 | e_destroy (w); |
|
|
613 | |
|
|
614 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
|
|
615 | |
|
|
616 | void ev_prepare_start (struct ev_prepare *w) |
|
|
617 | |
|
|
618 | void ev_prepare_stop (struct ev_prepare *w) |
|
|
619 | |
|
|
620 | void DESTROY (struct ev_prepare *w) |
|
|
621 | CODE: |
|
|
622 | ev_prepare_stop (w); |
|
|
623 | e_destroy (w); |
|
|
624 | |
506 | MODULE = EV PACKAGE = EV::Check PREFIX = evcheck_ |
625 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
507 | |
626 | |
508 | void evcheck_start (struct ev_check *w) |
627 | void ev_check_start (struct ev_check *w) |
509 | |
628 | |
510 | void evcheck_stop (struct ev_check *w) |
629 | void ev_check_stop (struct ev_check *w) |
511 | |
630 | |
512 | #if 0 |
631 | void DESTROY (struct ev_check *w) |
|
|
632 | CODE: |
|
|
633 | ev_check_stop (w); |
|
|
634 | e_destroy (w); |
|
|
635 | |
|
|
636 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
|
|
637 | |
|
|
638 | void ev_child_start (struct ev_child *w) |
|
|
639 | |
|
|
640 | void ev_child_stop (struct ev_child *w) |
|
|
641 | |
|
|
642 | void DESTROY (struct ev_child *w) |
|
|
643 | CODE: |
|
|
644 | ev_child_stop (w); |
|
|
645 | e_destroy (w); |
|
|
646 | |
|
|
647 | void set (struct ev_child *w, int pid) |
|
|
648 | CODE: |
|
|
649 | { |
|
|
650 | int active = w->active; |
|
|
651 | if (active) ev_child_stop (w); |
|
|
652 | |
|
|
653 | ev_child_set (w, pid); |
|
|
654 | |
|
|
655 | if (active) ev_child_start (w); |
|
|
656 | } |
|
|
657 | |
|
|
658 | int pid (struct ev_child *w, int new_pid = 0) |
|
|
659 | CODE: |
|
|
660 | { |
|
|
661 | RETVAL = w->pid; |
|
|
662 | |
|
|
663 | if (items > 1) |
|
|
664 | { |
|
|
665 | int active = w->active; |
|
|
666 | if (active) ev_child_stop (w); |
|
|
667 | |
|
|
668 | ev_child_set (w, new_pid); |
|
|
669 | |
|
|
670 | if (active) ev_child_start (w); |
|
|
671 | } |
|
|
672 | } |
|
|
673 | OUTPUT: |
|
|
674 | RETVAL |
|
|
675 | |
|
|
676 | |
|
|
677 | int status (struct ev_child *w) |
|
|
678 | CODE: |
|
|
679 | RETVAL = w->status; |
|
|
680 | OUTPUT: |
|
|
681 | RETVAL |
513 | |
682 | |
514 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
683 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
515 | |
684 | |
516 | BOOT: |
685 | BOOT: |
517 | { |
686 | { |
… | |
… | |
600 | |
769 | |
601 | void evdns_search_add (char *domain) |
770 | void evdns_search_add (char *domain) |
602 | |
771 | |
603 | void evdns_search_ndots_set (int ndots) |
772 | void evdns_search_ndots_set (int ndots) |
604 | |
773 | |
|
|
774 | #if 0 |
605 | |
775 | |
606 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
776 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
607 | |
777 | |
608 | BOOT: |
778 | BOOT: |
609 | { |
779 | { |