]> granicus.if.org Git - libevent/commitdiff
Add an event_base_loopcontinue() to tell libevent to rescan right away
authorNick Mathewson <nickm@torproject.org>
Wed, 9 May 2012 16:05:07 +0000 (12:05 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 9 May 2012 16:06:00 +0000 (12:06 -0400)
event.c
include/event2/event.h

diff --git a/event.c b/event.c
index 56d12ab6a8672a6d6f0b0abbe9656db9583a2568..5cb5d28cffe3a85bbb0d70018b48fedee6f7fb1d 100644 (file)
--- a/event.c
+++ b/event.c
@@ -1619,6 +1619,25 @@ event_base_loopbreak(struct event_base *event_base)
        return r;
 }
 
+int
+event_base_loopcontinue(struct event_base *event_base)
+{
+       int r = 0;
+       if (event_base == NULL)
+               return (-1);
+
+       EVBASE_ACQUIRE_LOCK(event_base, th_base_lock);
+       event_base->event_continue = 1;
+
+       if (EVBASE_NEED_NOTIFY(event_base)) {
+               r = evthread_notify_base(event_base);
+       } else {
+               r = (0);
+       }
+       EVBASE_RELEASE_LOCK(event_base, th_base_lock);
+       return r;
+}
+
 int
 event_base_got_break(struct event_base *event_base)
 {
index 1cfc3ce92126b0b89f128c8307b5d7b9746fa3b5..4f5a7c8339c4e53c44f087ae33b33c01c295b77f 100644 (file)
@@ -754,6 +754,25 @@ int event_base_loopexit(struct event_base *, const struct timeval *);
  */
 int event_base_loopbreak(struct event_base *);
 
+/**
+  Tell the active event_base_loop() to scan for new events immediately.
+
+  Calling this function makes the currently active event_base_loop()
+  start the loop over again (scanning for new events) after the current
+  event callback finishes.  If the event loop is not running, this
+  function has no effect.
+
+  event_base_loopbreak() is typically invoked from this event's callback.
+  This behavior is analogous to the "continue;" statement.
+
+  Subsequent invocations of event loop will proceed normally.
+
+  @param eb the event_base structure returned by event_init()
+  @return 0 if successful, or -1 if an error occurred
+  @see event_base_loopbreak()
+ */
+int event_base_loopcontinue(struct event_base *);
+
 /**
   Checks if the event loop was told to exit by event_loopexit().