ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.3
(Generate patch)

Comparing libev/ev.3 (file contents):
Revision 1.121 by root, Wed Mar 18 12:21:48 2020 UTC vs.
Revision 1.123 by root, Sun Jul 26 11:10:45 2020 UTC

131.\} 131.\}
132.rm #[ #] #H #V #F C 132.rm #[ #] #H #V #F C
133.\" ======================================================================== 133.\" ========================================================================
134.\" 134.\"
135.IX Title "LIBEV 3" 135.IX Title "LIBEV 3"
136.TH LIBEV 3 "2020-03-12" "libev-4.31" "libev - high performance full featured event loop" 136.TH LIBEV 3 "2020-07-12" "libev-4.33" "libev - high performance full featured event loop"
137.\" For nroff, turn off justification. Always turn off hyphenation; it makes 137.\" For nroff, turn off justification. Always turn off hyphenation; it makes
138.\" way too many mistakes in technical documents. 138.\" way too many mistakes in technical documents.
139.if n .ad l 139.if n .ad l
140.nh 140.nh
141.SH "NAME" 141.SH "NAME"
1532therefore a good idea to always call its \f(CW\*(C`ev_TYPE_stop\*(C'\fR function. 1532therefore a good idea to always call its \f(CW\*(C`ev_TYPE_stop\*(C'\fR function.
1533.IP "bool ev_is_active (ev_TYPE *watcher)" 4 1533.IP "bool ev_is_active (ev_TYPE *watcher)" 4
1534.IX Item "bool ev_is_active (ev_TYPE *watcher)" 1534.IX Item "bool ev_is_active (ev_TYPE *watcher)"
1535Returns a true value iff the watcher is active (i.e. it has been started 1535Returns a true value iff the watcher is active (i.e. it has been started
1536and not yet been stopped). As long as a watcher is active you must not modify 1536and not yet been stopped). As long as a watcher is active you must not modify
1537it. 1537it unless documented otherwise.
1538.IP "bool ev_is_pending (ev_TYPE *watcher)" 4 1538.IP "bool ev_is_pending (ev_TYPE *watcher)" 4
1539.IX Item "bool ev_is_pending (ev_TYPE *watcher)" 1539.IX Item "bool ev_is_pending (ev_TYPE *watcher)"
1540Returns a true value iff the watcher is pending, (i.e. it has outstanding 1540Returns a true value iff the watcher is pending, (i.e. it has outstanding
1541events but its callback has not yet been invoked). As long as a watcher 1541events but its callback has not yet been invoked). As long as a watcher
1542is pending (but not active) you must not call an init function on it (but 1542is pending (but not active) you must not call an init function on it (but
4002.PP 4002.PP
4003First, you need to associate some data with the event loop: 4003First, you need to associate some data with the event loop:
4004.PP 4004.PP
4005.Vb 6 4005.Vb 6
4006\& typedef struct { 4006\& typedef struct {
4007\& mutex_t lock; /* global loop lock */ 4007\& pthread_mutex_t lock; /* global loop lock */
4008\& pthread_t tid;
4009\& pthread_cond_t invoke_cv;
4008\& ev_async async_w; 4010\& ev_async async_w;
4009\& thread_t tid;
4010\& cond_t invoke_cv;
4011\& } userdata; 4011\& } userdata;
4012\& 4012\&
4013\& void prepare_loop (EV_P) 4013\& void prepare_loop (EV_P)
4014\& { 4014\& {
4015\& // for simplicity, we use a static userdata struct. 4015\& // for simplicity, we use a static userdata struct.
4016\& static userdata u; 4016\& static userdata u;
4017\& 4017\&
4018\& ev_async_init (&u\->async_w, async_cb); 4018\& ev_async_init (&u.async_w, async_cb);
4019\& ev_async_start (EV_A_ &u\->async_w); 4019\& ev_async_start (EV_A_ &u.async_w);
4020\& 4020\&
4021\& pthread_mutex_init (&u\->lock, 0); 4021\& pthread_mutex_init (&u.lock, 0);
4022\& pthread_cond_init (&u\->invoke_cv, 0); 4022\& pthread_cond_init (&u.invoke_cv, 0);
4023\& 4023\&
4024\& // now associate this with the loop 4024\& // now associate this with the loop
4025\& ev_set_userdata (EV_A_ u); 4025\& ev_set_userdata (EV_A_ &u);
4026\& ev_set_invoke_pending_cb (EV_A_ l_invoke); 4026\& ev_set_invoke_pending_cb (EV_A_ l_invoke);
4027\& ev_set_loop_release_cb (EV_A_ l_release, l_acquire); 4027\& ev_set_loop_release_cb (EV_A_ l_release, l_acquire);
4028\& 4028\&
4029\& // then create the thread running ev_run 4029\& // then create the thread running ev_run
4030\& pthread_create (&u\->tid, 0, l_run, EV_A); 4030\& pthread_create (&u.tid, 0, l_run, EV_A);
4031\& } 4031\& }
4032.Ve 4032.Ve
4033.PP 4033.PP
4034The callback for the \f(CW\*(C`ev_async\*(C'\fR watcher does nothing: the watcher is used 4034The callback for the \f(CW\*(C`ev_async\*(C'\fR watcher does nothing: the watcher is used
4035solely to wake up the event loop so it takes notice of any new watchers 4035solely to wake up the event loop so it takes notice of any new watchers

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines