Add an event_base_loopcontinue() to tell libevent to rescan right away

This commit is contained in:
Nick Mathewson 2012-05-09 12:05:07 -04:00
parent c0e425abdc
commit 7d6aa5ee68
2 changed files with 38 additions and 0 deletions

19
event.c
View File

@ -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)
{

View 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().