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