… | |
… | |
94 | |
94 | |
95 | static void |
95 | static void |
96 | slf_init_timed_io (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items) |
96 | slf_init_timed_io (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items) |
97 | { |
97 | { |
98 | SV *data; |
98 | SV *data; |
|
|
99 | int fd; |
99 | |
100 | |
100 | if (items < 2 || items > 3) |
101 | if (items < 2 || items > 3) |
101 | croak ("Coro::EV::timed_io_once requires exactly two or three parameters, not %d.\n", items); |
102 | croak ("Coro::EV::timed_io_once requires exactly two or three parameters, not %d.\n", items); |
102 | |
103 | |
103 | SvGETMAGIC (arg [0]); |
104 | SvGETMAGIC (arg [0]); |
104 | SvGETMAGIC (arg [1]); |
105 | SvGETMAGIC (arg [1]); |
105 | |
106 | |
106 | if (items >= 3) |
107 | if (items >= 3) |
107 | SvGETMAGIC (arg [2]); |
108 | SvGETMAGIC (arg [2]); |
|
|
109 | |
|
|
110 | fd = sv_fileno (arg [0]); |
108 | |
111 | |
109 | data = sv_2mortal (newRV_inc (CORO_CURRENT)); |
112 | data = sv_2mortal (newRV_inc (CORO_CURRENT)); |
110 | frame->data = (void *)data; |
113 | frame->data = (void *)data; |
111 | frame->prepare = GCoroAPI->prepare_schedule; |
114 | frame->prepare = GCoroAPI->prepare_schedule; |
112 | frame->check = slf_check_once; |
115 | frame->check = slf_check_once; |
113 | |
116 | |
114 | ev_once ( |
117 | ev_once ( |
115 | EV_DEFAULT_UC, |
118 | EV_DEFAULT_UC, |
116 | sv_fileno (arg [0]), |
119 | fd, |
117 | SvIV (arg [1]), |
120 | SvIV (arg [1]), |
118 | items >= 3 && SvOK (arg [2]) ? SvNV (arg [2]) : -1., |
121 | items >= 3 && SvOK (arg [2]) ? SvNV (arg [2]) : -1., |
119 | once_cb, |
122 | once_cb, |
120 | SvREFCNT_inc (data) |
123 | SvREFCNT_inc (data) |
121 | ); |
124 | ); |