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.10 by root, Mon Jul 20 03:45:46 2009 UTC vs.
Revision 1.11 by root, Wed Mar 31 01:05:46 2010 UTC

10 10
11#include "EVAPI.h" 11#include "EVAPI.h"
12 12
13/* our userdata */ 13/* our userdata */
14typedef struct { 14typedef struct {
15 mutex_t lock; /* global loop lock */ 15 xmutex_t lock; /* global loop lock */
16 void (*signal_func) (void *signal_arg, int value); 16 void (*signal_func) (void *signal_arg, int value);
17 void *signal_arg; 17 void *signal_arg;
18 ev_async async_w; 18 ev_async async_w;
19 thread_t tid; 19 xthread_t tid;
20 unsigned int max_loops; 20 unsigned int max_loops;
21 unsigned int count; 21 unsigned int count;
22 22
23 cond_t invoke_cv; 23 xcond_t invoke_cv;
24 24
25 SV *interrupt; 25 SV *interrupt;
26#if defined(_WIN32) && defined(USE_ITHREADS) 26#if defined(_WIN32) && defined(USE_ITHREADS)
27 void *thx; 27 void *thx;
28#endif 28#endif
163 PUSHs (sv_2mortal (newSViv (PTR2IV (c_func)))); 163 PUSHs (sv_2mortal (newSViv (PTR2IV (c_func))));
164 PUSHs (sv_2mortal (newSViv (SvIVX (SvRV (loop))))); 164 PUSHs (sv_2mortal (newSViv (SvIVX (SvRV (loop)))));
165 165
166void 166void
167_attach (SV *loop_, SV *interrupt, IV sig_func, void *sig_arg) 167_attach (SV *loop_, SV *interrupt, IV sig_func, void *sig_arg)
168 PROTOTYPE: @
168 CODE: 169 CODE:
169{ 170{
170 pthread_mutexattr_t ma; 171 pthread_mutexattr_t ma;
171 struct ev_loop *loop = (struct ev_loop *)SvIVX (SvRV (loop_)); 172 struct ev_loop *loop = (struct ev_loop *)SvIVX (SvRV (loop_));
172 udat *u; 173 udat *u;
181 182
182 ev_async_init (&u->async_w, async_cb); 183 ev_async_init (&u->async_w, async_cb);
183 ev_async_start (EV_A, &u->async_w); 184 ev_async_start (EV_A, &u->async_w);
184 185
185 pthread_mutexattr_init (&ma); 186 pthread_mutexattr_init (&ma);
187#ifdef PTHREAD_MUTEX_RECURSIVE
186 pthread_mutexattr_settype (&ma, PTHREAD_MUTEX_RECURSIVE); 188 pthread_mutexattr_settype (&ma, PTHREAD_MUTEX_RECURSIVE);
189#else
190 pthread_mutexattr_settype (&ma, PTHREAD_MUTEX_RECURSIVE_NP);
191#endif
187 pthread_mutex_init (&u->lock, &ma); 192 pthread_mutex_init (&u->lock, &ma);
188 pthread_mutexattr_destroy (&ma); 193 pthread_mutexattr_destroy (&ma);
189 194
190 pthread_cond_init (&u->invoke_cv, 0); 195 pthread_cond_init (&u->invoke_cv, 0);
191 196

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines