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.125 by sf-exg, Sun May 14 19:02:31 2023 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 "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.
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
4421.Sp 4421.Sp
4422For \f(CW\*(C`ev::embed\*(C'\fR watchers this method is called \f(CW\*(C`set_embed\*(C'\fR, to avoid 4422For \f(CW\*(C`ev::embed\*(C'\fR watchers this method is called \f(CW\*(C`set_embed\*(C'\fR, to avoid
4423clashing with the \f(CW\*(C`set (loop)\*(C'\fR method. 4423clashing with the \f(CW\*(C`set (loop)\*(C'\fR method.
4424.Sp 4424.Sp
4425For \f(CW\*(C`ev::io\*(C'\fR watchers there is an additional \f(CW\*(C`set\*(C'\fR method that acepts a 4425For \f(CW\*(C`ev::io\*(C'\fR watchers there is an additional \f(CW\*(C`set\*(C'\fR method that acepts a
4426new event mask only, and internally calls \f(CW\*(C`ev_io_modfify\*(C'\fR. 4426new event mask only, and internally calls \f(CW\*(C`ev_io_modify\*(C'\fR.
4427.IP "w\->start ()" 4 4427.IP "w\->start ()" 4
4428.IX Item "w->start ()" 4428.IX Item "w->start ()"
4429Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the 4429Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the
4430constructor already stores the event loop. 4430constructor already stores the event loop.
4431.IP "w\->start ([arguments])" 4 4431.IP "w\->start ([arguments])" 4

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines