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

Comparing cvsroot/EV-Loop-Async/Async.xs (file contents):
Revision 1.9 by root, Fri Jul 17 03:28:57 2009 UTC vs.
Revision 1.10 by root, Mon Jul 20 03:45:46 2009 UTC

21 unsigned int count; 21 unsigned int count;
22 22
23 cond_t invoke_cv; 23 cond_t invoke_cv;
24 24
25 SV *interrupt; 25 SV *interrupt;
26#if defined(_WIN32) && defined(USE_ITHREADS)
27 void *thx;
28#endif
26} udat; 29} udat;
27 30
28static void loop_set_cb (EV_P); 31static void loop_set_cb (EV_P);
29 32
30static void 33static void
107} 110}
108 111
109X_THREAD_PROC(l_run) 112X_THREAD_PROC(l_run)
110{ 113{
111 struct ev_loop *loop = (struct ev_loop *)thr_arg; 114 struct ev_loop *loop = (struct ev_loop *)thr_arg;
115#if defined(_WIN32) && defined(USE_ITHREADS)
116 udat *u = ev_userdata (EV_A);
117
118 /* just setting the same context pointer as the other thread is */
119 /* probably fatal, yet, I have no clue what makes libev crash (malloc?) */
120 /* as visual c also crashes when it tries to debug the crash */
121 /* the loser platform is indeed a crashy OS */
122 PERL_SET_CONTEXT (u->thx);
123#endif
112 124
113 l_acquire (EV_A); 125 l_acquire (EV_A);
114 126
115 /* yeah */ 127 /* yeah */
116 pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0); 128 pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
161 173
162 Newz (0, u, 1, udat); 174 Newz (0, u, 1, udat);
163 u->interrupt = newSVsv (interrupt); 175 u->interrupt = newSVsv (interrupt);
164 u->signal_func = (void (*)(void *, int))sig_func; 176 u->signal_func = (void (*)(void *, int))sig_func;
165 u->signal_arg = sig_arg; 177 u->signal_arg = sig_arg;
178#if defined(_WIN32) && defined(USE_ITHREADS)
179 u->thx = PERL_GET_CONTEXT;
180#endif
166 181
167 ev_async_init (&u->async_w, async_cb); 182 ev_async_init (&u->async_w, async_cb);
168 ev_async_start (EV_A, &u->async_w); 183 ev_async_start (EV_A, &u->async_w);
169 184
170 pthread_mutexattr_init (&ma); 185 pthread_mutexattr_init (&ma);
246 { 261 {
247 X_LOCK (u->lock); 262 X_LOCK (u->lock);
248 ev_async_stop (EV_A, &u->async_w); 263 ev_async_stop (EV_A, &u->async_w);
249 /* now thread is around blocking call, or in pthread_cond_wait */ 264 /* now thread is around blocking call, or in pthread_cond_wait */
250 pthread_cancel (u->tid); 265 pthread_cancel (u->tid);
266 X_UNLOCK (u->lock);
251 pthread_mutex_destroy (&u->lock); 267 pthread_mutex_destroy (&u->lock);
252 pthread_cond_destroy (&u->invoke_cv); 268 pthread_cond_destroy (&u->invoke_cv);
253 SvREFCNT_dec (u->interrupt); 269 SvREFCNT_dec (u->interrupt);
254 Safefree (u); 270 Safefree (u);
255 } 271 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines