diff options
| -rw-r--r-- | Changes | 5 | ||||
| -rw-r--r-- | ev.c | 3 | ||||
| -rw-r--r-- | ev.h | 12 | ||||
| -rw-r--r-- | ev.pod | 26 | 
4 files changed, 41 insertions, 5 deletions
| @@ -1,8 +1,8 @@  Revision history for libev, a high-performance and full-featured event loop. -TODO: ev_time_freeze, ev_time_thaw  TODO: ev_walk -TODO: ev_stop_all +TODO: ev_stop_all docs +TODO: priority/idle docs  TODO: fix signal handling(?) under win32  3.54  	- multiple timers becoming ready within an event loop iteration @@ -14,6 +14,7 @@ TODO: fix signal handling(?) under win32  	- correctly zero the idx values for arrays, so destroying and            reinitialising the default loop actually works (patch by            Malek Hadj-Ali). +        - implement ev_suspend and ev_resume.          - new EV_CUSTOM revents flag for use by applications.  3.53 Sun Feb 15 02:38:20 CET 2009 @@ -2135,9 +2135,10 @@ ev_resume (EV_P)    ev_tstamp mn_prev = mn_now;    ev_now_update (EV_A); -  printf ("update %f\n", mn_now - mn_prev);//D    timers_reschedule (EV_A_ mn_now - mn_prev); +#if EV_PERIODIC_ENABLE    periodics_reschedule (EV_A); +#endif  }  /*****************************************************************************/ @@ -526,8 +526,16 @@ void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval); /* sleep at lea  void ev_ref   (EV_P);  void ev_unref (EV_P); -/* convenience function, wait for a single event, without registering an event watcher */ -/* if timeout is < 0, do wait indefinitely */ +/* + * stop/start the timer handling. + */ +void ev_suspend (EV_P); +void ev_resume  (EV_P); + +/* + * convenience function, wait for a single event, without registering an event watcher + * if timeout is < 0, do wait indefinitely + */  void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg);  #endif @@ -636,6 +636,32 @@ the current time is a good idea.  See also "The special problem of time updates" in the C<ev_timer> section. +=item ev_suspend (loop) + +=item ev_resume (loop) + +These two functions suspend and resume a loop, for use when the loop is +not used for a while and timeouts should not be processed. + +A typical use case would be an interactive program such as a game:  When +the user presses C<^Z> to suspend the game and resumes it an hour later it +would be best to handle timeouts as if no time had actually passed while +the program was suspended. This can be achieved by calling C<ev_suspend> +in your C<SIGTSTP> handler, sending yourself a C<SIGSTOP> and calling +C<ev_resume> directly afterwards to resume timer processing. + +Effectively, all C<ev_timer> watchers will be delayed by the time spend +between C<ev_suspend> and C<ev_resume>, and all C<ev_periodic> watchers +will be rescheduled (that is, they will lose any events that would have +occured while suspended). + +After calling C<ev_suspend> you B<must not> call I<any> function on the +given loop other than C<ev_resume>, and you B<must not> call C<ev_resume> +without a previous call to C<ev_suspend>. + +Calling C<ev_suspend>/C<ev_resume> has the side effect of updating the +event loop time (see C<ev_now_update>). +  =item ev_loop (loop, int flags)  Finally, this is it, the event handler. This function usually is called | 
