eloop: allow flushing an fd
Sometimes one wants to remove all pending events for an fd. The new ev_eloop_flush_fd() call allows this in a safe way. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
335182556c
commit
f7b398a34a
13
src/eloop.c
13
src/eloop.c
@ -805,6 +805,19 @@ void ev_eloop_unref(struct ev_eloop *loop)
|
||||
free(loop);
|
||||
}
|
||||
|
||||
void ev_eloop_flush_fd(struct ev_eloop *loop, struct ev_fd *fd)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!loop || !fd)
|
||||
return;
|
||||
|
||||
for (i = 0; i < loop->cur_fds_cnt; ++i) {
|
||||
if (loop->cur_fds[i].data.ptr == fd)
|
||||
loop->cur_fds[i].data.ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int ev_eloop_dispatch(struct ev_eloop *loop, int timeout)
|
||||
{
|
||||
struct epoll_event ep[32];
|
||||
|
@ -62,6 +62,7 @@ int ev_eloop_new(struct ev_eloop **out);
|
||||
void ev_eloop_ref(struct ev_eloop *loop);
|
||||
void ev_eloop_unref(struct ev_eloop *loop);
|
||||
|
||||
void ev_eloop_flush_fd(struct ev_eloop *loop, struct ev_fd *fd);
|
||||
int ev_eloop_dispatch(struct ev_eloop *loop, int timeout);
|
||||
int ev_eloop_run(struct ev_eloop *loop, int timeout);
|
||||
void ev_eloop_exit(struct ev_eloop *loop);
|
||||
|
Loading…
x
Reference in New Issue
Block a user