diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-02-11 21:01:53 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-02-20 13:55:23 -0500 |
commit | c89b4e63f6b69fa84979ff2aef44c2fdc3e1d8c9 (patch) | |
tree | b6bcbfe0bf1e426e68619244e0c715eae2fe53d5 /evmap-internal.h | |
parent | 604569bf3f57bd7bc91799083e8a3c6016be863c (diff) | |
download | libevent-c89b4e63f6b69fa84979ff2aef44c2fdc3e1d8c9.tar.gz |
Refactor the functions that run over every event.
Now there are appropriate "for each event", "for each fd", and "for
each signal" helpers that they can use; this makes the code a bit
simpler, and far less duplicated.
This lets me turn back on the functions I disabled when removing
eventlist.
Additionally, check more lists for circularity in
event_base_assert_ok().
Add typedefs for the callback types.
Name fewer things "ctx".
Adds an implementation of Floyd's tortoise-and-hare algorithm to check
for circularity in TAILQs and LISTs, to avoid the abuse of flags that
event_base_assert_ok() was doing before.
Suggested by Dave Hart.
Diffstat (limited to 'evmap-internal.h')
-rw-r--r-- | evmap-internal.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/evmap-internal.h b/evmap-internal.h index 429044ee..d2839a79 100644 --- a/evmap-internal.h +++ b/evmap-internal.h @@ -85,14 +85,33 @@ int evmap_signal_add(struct event_base *base, int signum, struct event *ev); int evmap_signal_del(struct event_base *base, int signum, struct event *ev); void evmap_signal_active(struct event_base *base, evutil_socket_t signum, int ncalls); +/* Return the fdinfo object associated with a given fd. If the fd has no + * events associated with it, the result may be NULL. + */ void *evmap_io_get_fdinfo(struct event_io_map *ctx, evutil_socket_t fd); -int evmap_io_reinit(struct event_base *base); -int evmap_signal_reinit(struct event_base *base); +/* Helper for event_reinit(): Tell the backend to re-add every fd and signal + * for which we have a pending event. + */ +int evmap_reinit(struct event_base *base); -int evmap_io_delete_all(struct event_base *base); -int evmap_signal_delete_all(struct event_base *base); +/* Helper for event_base_free(): Call event_del() on every pending fd and + * signal event. + */ +void evmap_delete_all(struct event_base *base); +/* Helper for event_base_assert_ok(): Check referential integrity of the + * evmaps. + */ void evmap_check_integrity(struct event_base *base); +/* Helper: Call fn on every fd or signal event, passing as its arguments the + * provided event_base, the event, and arg. If fn returns 0, process the next + * event. If it returns any other value, return that value and process no + * more events. + */ +int evmap_foreach_event(struct event_base *base, + event_base_foreach_event_cb fn, + void *arg); + #endif /* _EVMAP_H_ */ |