ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV-Glib/Glib.xs
(Generate patch)

Comparing EV-Glib/Glib.xs (file contents):
Revision 1.1 by root, Sat Dec 8 02:49:42 2007 UTC vs.
Revision 1.2 by root, Sat Dec 8 02:59:43 2007 UTC

29 29
30 GMainContext *gc; 30 GMainContext *gc;
31}; 31};
32 32
33static void 33static void
34timer_cb (ev_timer *w, int revents) 34timer_cb (EV_P_ ev_timer *w, int revents)
35{ 35{
36 /* nop */ 36 /* nop */
37} 37}
38 38
39static void 39static void
40io_cb (ev_io *w, int revents) 40io_cb (EV_P_ ev_io *w, int revents)
41{ 41{
42 GPollFD *pfd = (GPollFD *)w->data; 42 GPollFD *pfd = (GPollFD *)w->data;
43 43
44 pfd->revents |= pfd->events & 44 pfd->revents |= pfd->events &
45 ((revents & EV_READ ? G_IO_IN : 0) 45 ((revents & EV_READ ? G_IO_IN : 0)
46 | (revents & EV_READ ? G_IO_OUT : 0)); 46 | (revents & EV_READ ? G_IO_OUT : 0));
47} 47}
48 48
49static void 49static void
50cleanup (struct econtext *ctx) 50cleanup (EV_P_ struct econtext *ctx)
51{ 51{
52 int i; 52 int i;
53 53
54 for (i = 0; i < ctx->nfd; ++i) 54 for (i = 0; i < ctx->nfd; ++i)
55 { 55 {
56 ev_ref (); 56 ev_ref (EV_A);
57 ev_io_stop (EV_A_ ctx->iow + i); 57 ev_io_stop (EV_A_ ctx->iow + i);
58 } 58 }
59 59
60 ctx->nfd = 0; 60 ctx->nfd = 0;
61 61
62 if (ev_is_active (&ctx->tw)) 62 if (ev_is_active (&ctx->tw))
63 { 63 {
64 ev_ref (); 64 ev_ref (EV_A);
65 ev_timer_stop (EV_A_ &ctx->tw); 65 ev_timer_stop (EV_A_ &ctx->tw);
66 } 66 }
67} 67}
68 68
69static void 69static void
70prepare_cb (ev_prepare *w, int revents) 70prepare_cb (EV_P_ ev_prepare *w, int revents)
71{ 71{
72 struct econtext *ctx = (struct econtext *)(((char *)w) - offsetof (struct econtext, pw)); 72 struct econtext *ctx = (struct econtext *)(((char *)w) - offsetof (struct econtext, pw));
73 gint timeout; 73 gint timeout;
74 int n; 74 int n;
75 75
76 cleanup (ctx); 76 cleanup (EV_A_ ctx);
77 77
78 g_main_context_prepare (ctx->gc, &ctx->maxpri); 78 g_main_context_prepare (ctx->gc, &ctx->maxpri);
79 79
80 while (ctx->afd < (ctx->nfd = g_main_context_query ( 80 while (ctx->afd < (ctx->nfd = g_main_context_query (
81 ctx->gc, 81 ctx->gc,
110 (pfd->events & G_IO_IN ? EV_READ : 0) 110 (pfd->events & G_IO_IN ? EV_READ : 0)
111 | (pfd->events & G_IO_OUT ? EV_WRITE : 0) 111 | (pfd->events & G_IO_OUT ? EV_WRITE : 0)
112 ); 112 );
113 iow->data = (void *)pfd; 113 iow->data = (void *)pfd;
114 ev_io_start (EV_A_ iow); 114 ev_io_start (EV_A_ iow);
115 ev_unref (); 115 ev_unref (EV_A);
116 } 116 }
117 117
118 if (timeout >= 0) 118 if (timeout >= 0)
119 { 119 {
120 ev_timer_set (&ctx->tw, timeout * 1e-3, 0.); 120 ev_timer_set (&ctx->tw, timeout * 1e-3, 0.);
121 ev_timer_start (EV_A_ &ctx->tw); 121 ev_timer_start (EV_A_ &ctx->tw);
122 ev_unref (EV_A);
122 } 123 }
123} 124}
124 125
125static void 126static void
126check_cb (ev_check *w, int revents) 127check_cb (EV_P_ ev_check *w, int revents)
127{ 128{
128 struct econtext *ctx = (struct econtext *)(((char *)w) - offsetof (struct econtext, cw)); 129 struct econtext *ctx = (struct econtext *)(((char *)w) - offsetof (struct econtext, cw));
129 130
130 cleanup (ctx); 131 cleanup (EV_A_ ctx);
131 132
132 g_main_context_check (ctx->gc, ctx->maxpri, ctx->pfd, ctx->nfd); 133 g_main_context_check (ctx->gc, ctx->maxpri, ctx->pfd, ctx->nfd);
133 g_main_context_dispatch (ctx->gc); 134 g_main_context_dispatch (ctx->gc);
134} 135}
135 136

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines