… | |
… | |
86 | (pfd->events & G_IO_IN ? EV_READ : 0) |
86 | (pfd->events & G_IO_IN ? EV_READ : 0) |
87 | | (pfd->events & G_IO_OUT ? EV_WRITE : 0) |
87 | | (pfd->events & G_IO_OUT ? EV_WRITE : 0) |
88 | ); |
88 | ); |
89 | iow->data = (void *)pfd; |
89 | iow->data = (void *)pfd; |
90 | ev_set_priority (iow, EV_MINPRI); |
90 | ev_set_priority (iow, EV_MINPRI); |
91 | ev_io_start (EV_A_ iow); |
91 | ev_io_start (EV_A, iow); |
92 | } |
92 | } |
93 | |
93 | |
94 | if (timeout >= 0) |
94 | if (timeout >= 0) |
95 | { |
95 | { |
96 | ev_timer_set (&ctx->tw, timeout * 1e-3, 0.); |
96 | ev_timer_set (&ctx->tw, timeout * 1e-3, 0.); |
97 | ev_timer_start (EV_A_ &ctx->tw); |
97 | ev_timer_start (EV_A, &ctx->tw); |
98 | } |
98 | } |
99 | } |
99 | } |
100 | |
100 | |
101 | static void |
101 | static void |
102 | check_cb (EV_P_ ev_check *w, int revents) |
102 | check_cb (EV_P_ ev_check *w, int revents) |
… | |
… | |
109 | ev_io *iow = ctx->iow + i; |
109 | ev_io *iow = ctx->iow + i; |
110 | |
110 | |
111 | if (ev_is_pending (iow)) |
111 | if (ev_is_pending (iow)) |
112 | { |
112 | { |
113 | GPollFD *pfd = ctx->pfd + i; |
113 | GPollFD *pfd = ctx->pfd + i; |
114 | int revents = ev_clear_pending (iow); |
114 | int revents = ev_clear_pending (EV_A, iow); |
115 | |
115 | |
116 | pfd->revents |= pfd->events & |
116 | pfd->revents |= pfd->events & |
117 | ((revents & EV_READ ? G_IO_IN : 0) |
117 | ((revents & EV_READ ? G_IO_IN : 0) |
118 | | (revents & EV_READ ? G_IO_OUT : 0)); |
118 | | (revents & EV_READ ? G_IO_OUT : 0)); |
119 | } |
119 | } |
120 | |
120 | |
121 | ev_io_stop (EV_A_ iow); |
121 | ev_io_stop (EV_A, iow); |
122 | } |
122 | } |
123 | |
123 | |
124 | if (ev_is_active (&ctx->tw)) |
124 | if (ev_is_active (&ctx->tw)) |
125 | ev_timer_stop (EV_A_ &ctx->tw); |
125 | ev_timer_stop (EV_A, &ctx->tw); |
126 | |
126 | |
127 | g_main_context_check (ctx->gc, ctx->maxpri, ctx->pfd, ctx->nfd); |
127 | g_main_context_check (ctx->gc, ctx->maxpri, ctx->pfd, ctx->nfd); |
128 | } |
128 | } |
129 | |
129 | |
130 | static struct econtext default_context; |
130 | static struct econtext default_context; |
… | |
… | |
151 | ctx->iow = 0; |
151 | ctx->iow = 0; |
152 | ctx->pfd = 0; |
152 | ctx->pfd = 0; |
153 | |
153 | |
154 | ev_prepare_init (&ctx->pw, prepare_cb); |
154 | ev_prepare_init (&ctx->pw, prepare_cb); |
155 | ev_set_priority (&ctx->pw, EV_MINPRI); |
155 | ev_set_priority (&ctx->pw, EV_MINPRI); |
156 | ev_prepare_start (EV_DEFAULT_ &ctx->pw); |
156 | ev_prepare_start (EV_DEFAULT, &ctx->pw); |
157 | |
157 | |
158 | ev_check_init (&ctx->cw, check_cb); |
158 | ev_check_init (&ctx->cw, check_cb); |
159 | ev_set_priority (&ctx->cw, EV_MAXPRI); |
159 | ev_set_priority (&ctx->cw, EV_MAXPRI); |
160 | ev_check_start (EV_DEFAULT_ &ctx->cw); |
160 | ev_check_start (EV_DEFAULT, &ctx->cw); |
161 | |
161 | |
162 | ev_init (&ctx->tw, timer_cb); |
162 | ev_init (&ctx->tw, timer_cb); |
163 | ev_set_priority (&ctx->tw, EV_MINPRI); |
163 | ev_set_priority (&ctx->tw, EV_MINPRI); |
164 | } |
164 | } |
165 | OUTPUT: |
165 | OUTPUT: |