diff options
| -rw-r--r-- | ev.c | 4 | ||||
| -rw-r--r-- | ev.pod | 39 | 
2 files changed, 43 insertions, 0 deletions
| @@ -1738,6 +1738,10 @@ ev_loop_destroy (EV_P)  {    int i; +  /* mimic free (0) */ +  if (!EV_A) +    return; +  #if EV_CLEANUP_ENABLE    /* queue cleanup watchers (and execute them) */    if (expect_false (cleanupcnt)) @@ -1114,6 +1114,10 @@ The embedded event loop specified in the C<ev_embed> watcher needs attention.  The event loop has been resumed in the child process after fork (see  C<ev_fork>). +=item C<EV_CLEANUP> + +The event loop is abotu to be destroyed (see C<ev_cleanup>). +  =item C<EV_ASYNC>  The given async watcher has been asynchronously notified (see C<ev_async>). @@ -3101,6 +3105,41 @@ believe me.  =back +=head2 C<ev_cleanup> - even the best things end + +Cleanup watchers are called just before the event loop they are registered +with is being destroyed. + +While there is no guarantee that the event loop gets destroyed, cleanup +watchers provide a convenient method to install cleanup watchers for your +program, worker threads and so on - you just to make sure to destroy the +loop when you want them to be invoked. + +=head3 Watcher-Specific Functions and Data Members + +=over 4 + +=item ev_cleanup_init (ev_signal *, callback) + +Initialises and configures the cleanup watcher - it has no parameters of +any kind. There is a C<ev_cleanup_set> macro, but using it is utterly +pointless, believe me. + +=back + +Example: Register an atexit handler to destroy the default loop, so any +cleanup functions are called. + +   static void +   program_exits (void) +   { +     ev_loop_destroy (EV_DEFAULT_UC); +   } + +   ... +   atexit (program_exits); + +  =head2 C<ev_async> - how to wake up an event loop  In general, you cannot use an C<ev_run> from multiple threads or other | 
