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

Comparing libev/ev.pod (file contents):
Revision 1.388 by root, Tue Dec 20 04:08:35 2011 UTC vs.
Revision 1.392 by root, Tue Dec 20 20:04:51 2011 UTC

1878 // timeout occurred, take action 1878 // timeout occurred, take action
1879 } 1879 }
1880 else 1880 else
1881 { 1881 {
1882 // callback was invoked, but there was some recent 1882 // callback was invoked, but there was some recent
1883 // activity. simply restart the timer to time out 1883 // activity. simply restart the timer to time out
1884 // after "after" seconds, which is the earliest time 1884 // after "after" seconds, which is the earliest time
1885 // the timeout can occur. 1885 // the timeout can occur.
1886 ev_timer_set (w, after, 0.); 1886 ev_timer_set (w, after, 0.);
1887 ev_timer_start (EV_A_ w); 1887 ev_timer_start (EV_A_ w);
1888 } 1888 }
3633 int exit_main_loop = 0; 3633 int exit_main_loop = 0;
3634 3634
3635 while (!exit_main_loop) 3635 while (!exit_main_loop)
3636 ev_run (EV_DEFAULT_ EVRUN_ONCE); 3636 ev_run (EV_DEFAULT_ EVRUN_ONCE);
3637 3637
3638 // in a model watcher 3638 // in a modal watcher
3639 int exit_nested_loop = 0; 3639 int exit_nested_loop = 0;
3640 3640
3641 while (!exit_nested_loop) 3641 while (!exit_nested_loop)
3642 ev_run (EV_A_ EVRUN_ONCE); 3642 ev_run (EV_A_ EVRUN_ONCE);
3643 3643
3823 switch_to (libev_coro); 3823 switch_to (libev_coro);
3824 } 3824 }
3825 3825
3826That basically suspends the coroutine inside C<wait_for_event> and 3826That basically suspends the coroutine inside C<wait_for_event> and
3827continues the libev coroutine, which, when appropriate, switches back to 3827continues the libev coroutine, which, when appropriate, switches back to
3828this or any other coroutine. I am sure if you sue this your own :) 3828this or any other coroutine.
3829 3829
3830You can do similar tricks if you have, say, threads with an event queue - 3830You can do similar tricks if you have, say, threads with an event queue -
3831instead of storing a coroutine, you store the queue object and instead of 3831instead of storing a coroutine, you store the queue object and instead of
3832switching to a coroutine, you push the watcher onto the queue and notify 3832switching to a coroutine, you push the watcher onto the queue and notify
3833any waiters. 3833any waiters.
3926=item C<ev::io>, C<ev::timer>, C<ev::periodic>, C<ev::idle>, C<ev::sig> etc. 3926=item C<ev::io>, C<ev::timer>, C<ev::periodic>, C<ev::idle>, C<ev::sig> etc.
3927 3927
3928For each C<ev_TYPE> watcher in F<ev.h> there is a corresponding class of 3928For each C<ev_TYPE> watcher in F<ev.h> there is a corresponding class of
3929the same name in the C<ev> namespace, with the exception of C<ev_signal> 3929the same name in the C<ev> namespace, with the exception of C<ev_signal>
3930which is called C<ev::sig> to avoid clashes with the C<signal> macro 3930which is called C<ev::sig> to avoid clashes with the C<signal> macro
3931defines by many implementations. 3931defined by many implementations.
3932 3932
3933All of those classes have these methods: 3933All of those classes have these methods:
3934 3934
3935=over 4 3935=over 4
3936 3936

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines