From 58ef9d93fb27fd25038961a92993e81cc0bba455 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 24 Oct 2010 19:38:20 +0000 Subject: *** empty log message *** --- ev.c | 4 ++++ ev.pod | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/ev.c b/ev.c index 066cd88..b5b0c5f 100644 --- a/ev.c +++ b/ev.c @@ -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)) diff --git a/ev.pod b/ev.pod index 749f082..87bd72d 100644 --- a/ev.pod +++ b/ev.pod @@ -1114,6 +1114,10 @@ The embedded event loop specified in the C watcher needs attention. The event loop has been resumed in the child process after fork (see C). +=item C + +The event loop is abotu to be destroyed (see C). + =item C The given async watcher has been asynchronously notified (see C). @@ -3101,6 +3105,41 @@ believe me. =back +=head2 C - 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 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 - how to wake up an event loop In general, you cannot use an C from multiple threads or other -- cgit v1.2.3