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

Comparing libev/ev.3 (file contents):
Revision 1.122 by root, Mon Jun 8 11:15:59 2020 UTC vs.
Revision 1.124 by root, Sun May 9 18:41:06 2021 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-04-19" "libev-4.33" "libev - high performance full featured event loop" 136.TH LIBEV 3 "2021-01-11" "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"
1087\& \- Queue all expired timers. 1087\& \- Queue all expired timers.
1088\& \- Queue all expired periodics. 1088\& \- Queue all expired periodics.
1089\& \- Queue all idle watchers with priority higher than that of pending events. 1089\& \- Queue all idle watchers with priority higher than that of pending events.
1090\& \- Queue all check watchers. 1090\& \- Queue all check watchers.
1091\& \- Call all queued watchers in reverse order (i.e. check watchers first). 1091\& \- Call all queued watchers in reverse order (i.e. check watchers first).
1092\& Signals and child watchers are implemented as I/O watchers, and will 1092\& Signals, async and child watchers are implemented as I/O watchers, and
1093\& be handled here by queueing them when their watcher gets executed. 1093\& will be handled here by queueing them when their watcher gets executed.
1094\& \- If ev_break has been called, or EVRUN_ONCE or EVRUN_NOWAIT 1094\& \- If ev_break has been called, or EVRUN_ONCE or EVRUN_NOWAIT
1095\& were used, or there are no active watchers, goto FINISH, otherwise 1095\& were used, or there are no active watchers, goto FINISH, otherwise
1096\& continue with step LOOP. 1096\& continue with step LOOP.
1097\& FINISH: 1097\& FINISH:
1098\& \- Reset the ev_break status iff it was EVBREAK_ONE. 1098\& \- Reset the ev_break status iff it was EVBREAK_ONE.
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