… | |
… | |
102 | |
102 | |
103 | w = (struct ev_watcher *)SvPVX (self); |
103 | w = (struct ev_watcher *)SvPVX (self); |
104 | |
104 | |
105 | ev_watcher_init (w, e_cb); |
105 | ev_watcher_init (w, e_cb); |
106 | |
106 | |
|
|
107 | w->data = 0; |
107 | w->fh = 0; |
108 | w->fh = 0; |
108 | w->cb_sv = newSVsv (cb_sv); |
109 | w->cb_sv = newSVsv (cb_sv); |
109 | w->self = self; |
110 | w->self = self; |
110 | |
111 | |
111 | return (void *)w; |
112 | return (void *)w; |
… | |
… | |
116 | { |
117 | { |
117 | struct ev_watcher *w = (struct ev_watcher *)w_; |
118 | struct ev_watcher *w = (struct ev_watcher *)w_; |
118 | |
119 | |
119 | SvREFCNT_dec (w->fh ); w->fh = 0; |
120 | SvREFCNT_dec (w->fh ); w->fh = 0; |
120 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
121 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
|
|
122 | SvREFCNT_dec (w->data ); w->data = 0; |
121 | } |
123 | } |
122 | |
124 | |
123 | static SV * |
125 | static SV * |
124 | e_bless (struct ev_watcher *w, HV *stash) |
126 | e_bless (struct ev_watcher *w, HV *stash) |
125 | { |
127 | { |
… | |
… | |
427 | CHECK_REPEAT (interval); |
429 | CHECK_REPEAT (interval); |
428 | CODE: |
430 | CODE: |
429 | { |
431 | { |
430 | struct ev_periodic *w; |
432 | struct ev_periodic *w; |
431 | w = e_new (sizeof (struct ev_periodic), cb); |
433 | w = e_new (sizeof (struct ev_periodic), cb); |
432 | w->fh = SvOK (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
434 | w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
433 | ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); |
435 | ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); |
434 | RETVAL = e_bless ((struct ev_watcher *)w, stash_periodic); |
436 | RETVAL = e_bless ((struct ev_watcher *)w, stash_periodic); |
435 | if (!ix) ev_periodic_start (w); |
437 | if (!ix) ev_periodic_start (w); |
436 | } |
438 | } |
437 | OUTPUT: |
439 | OUTPUT: |
… | |
… | |
499 | { |
501 | { |
500 | RETVAL = newSVsv (w->cb_sv); |
502 | RETVAL = newSVsv (w->cb_sv); |
501 | |
503 | |
502 | if (items > 1) |
504 | if (items > 1) |
503 | sv_setsv (w->cb_sv, new_cb); |
505 | sv_setsv (w->cb_sv, new_cb); |
|
|
506 | } |
|
|
507 | OUTPUT: |
|
|
508 | RETVAL |
|
|
509 | |
|
|
510 | SV *data (struct ev_watcher *w, SV *new_data = 0) |
|
|
511 | CODE: |
|
|
512 | { |
|
|
513 | RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; |
504 | } |
514 | } |
505 | OUTPUT: |
515 | OUTPUT: |
506 | RETVAL |
516 | RETVAL |
507 | |
517 | |
508 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
518 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |