mirror of
https://github.com/cuberite/libevent.git
synced 2025-08-04 01:36:23 -04:00
Add a few more evmap/changelist comments
This commit is contained in:
parent
c87272b7b9
commit
c247adc79c
@ -88,7 +88,7 @@ void event_changelist_init(struct event_changelist *changelist);
|
||||
* after making all the changes in the changelist. */
|
||||
void event_changelist_remove_all(struct event_changelist *changelist,
|
||||
struct event_base *base);
|
||||
/** Free all memory held in a changelist, and return it. */
|
||||
/** Free all memory held in a changelist. */
|
||||
void event_changelist_freemem(struct event_changelist *changelist);
|
||||
|
||||
/** Implementation of eventop_add that queues the event in a changelist. */
|
||||
|
@ -53,6 +53,8 @@ void evmap_signal_clear(struct event_signal_map* ctx);
|
||||
event_base's list of events on a given file descriptor, and tell the
|
||||
underlying eventops about the fd if its state has changed.
|
||||
|
||||
Requires that ev is not already added.
|
||||
|
||||
@param base the event_base to operate on.
|
||||
@param fd the file descriptor corresponding to ev.
|
||||
@param ev the event to add.
|
||||
@ -75,9 +77,13 @@ int evmap_io_del(struct event_base *base, evutil_socket_t fd, struct event *ev);
|
||||
*/
|
||||
void evmap_io_active(struct event_base *base, evutil_socket_t fd, short events);
|
||||
|
||||
|
||||
/* These functions behave in the same way as evmap_io_*, except they work on
|
||||
* signals rather than fds. signals use a linear map everywhere; fds use
|
||||
* either a linear map or a hashtable. */
|
||||
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 fd, int ncalls);
|
||||
void evmap_signal_active(struct event_base *base, evutil_socket_t signum, int ncalls);
|
||||
|
||||
void *evmap_io_get_fdinfo(struct event_io_map *ctx, evutil_socket_t fd);
|
||||
|
||||
|
21
evmap.c
21
evmap.c
@ -83,6 +83,8 @@ struct event_map_entry {
|
||||
} ent;
|
||||
};
|
||||
|
||||
/* Helper used by the event_io_map hashtable code; tries to return a good hash
|
||||
* of the fd in e->fd. */
|
||||
static inline unsigned
|
||||
hashsocket(struct event_map_entry *e)
|
||||
{
|
||||
@ -94,6 +96,8 @@ hashsocket(struct event_map_entry *e)
|
||||
return h;
|
||||
}
|
||||
|
||||
/* Helper used by the event_io_map hashtable code; returns true iff e1 and e2
|
||||
* have the same e->fd. */
|
||||
static inline int
|
||||
eqsocket(struct event_map_entry *e1, struct event_map_entry *e2)
|
||||
{
|
||||
@ -261,9 +265,7 @@ evmap_io_add(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
int nread, nwrite, retval = 0;
|
||||
short res = 0, old = 0;
|
||||
|
||||
EVUTIL_ASSERT(fd == ev->ev_fd); /*XXX(nickm) always true? */
|
||||
/*XXX(nickm) Should we assert that ev is not already inserted, or should
|
||||
* we make this function idempotent? */
|
||||
EVUTIL_ASSERT(fd == ev->ev_fd);
|
||||
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
@ -326,9 +328,7 @@ evmap_io_del(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
|
||||
EVUTIL_ASSERT(fd == ev->ev_fd); /*XXX(nickm) always true? */
|
||||
/*XXX(nickm) Should we assert that ev is not already inserted, or should
|
||||
* we make this function idempotent? */
|
||||
EVUTIL_ASSERT(fd == ev->ev_fd);
|
||||
|
||||
#ifndef EVMAP_USE_HT
|
||||
if (fd >= io->nentries)
|
||||
@ -674,11 +674,12 @@ event_changelist_del(struct event_base *base, evutil_socket_t fd, short old, sho
|
||||
|
||||
/* A delete removes any previous add, rather than replacing it:
|
||||
on those platforms where "add, delete, dispatch" is not the same
|
||||
as "no-op" dispatch, we want the no-op behavior.
|
||||
as "no-op, dispatch", we want the no-op behavior.
|
||||
|
||||
If we have a no-op item, we could it from the list entirely, but
|
||||
really there's not much point: skipping the no-op change when we do
|
||||
the dispatch later is far cheaper than rejuggling the array now.
|
||||
If we have a no-op item, we could remove it it from the list
|
||||
entirely, but really there's not much point: skipping the no-op
|
||||
change when we do the dispatch later is far cheaper than rejuggling
|
||||
the array now.
|
||||
*/
|
||||
|
||||
if (events & (EV_READ|EV_SIGNAL)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user