mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
provide more base-based functions :-)
svn:r125
This commit is contained in:
parent
f5a62ed30e
commit
256460459e
20
event.c
20
event.c
@ -181,13 +181,19 @@ event_init(void)
|
|||||||
current_base->evsel->name);
|
current_base->evsel->name);
|
||||||
|
|
||||||
/* allocate a single active event queue */
|
/* allocate a single active event queue */
|
||||||
event_priority_init(current_base, 1);
|
event_base_priority_init(current_base, 1);
|
||||||
|
|
||||||
return (current_base);
|
return (current_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
event_priority_init(struct event_base *base, int npriorities)
|
event_priority_init(int npriorities)
|
||||||
|
{
|
||||||
|
return event_base_priority_init(current_base, npriorities);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
event_base_priority_init(struct event_base *base, int npriorities)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -272,6 +278,12 @@ event_dispatch(void)
|
|||||||
return (event_loop(0));
|
return (event_loop(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
event_base_dispatch(struct event_base *event_base)
|
||||||
|
{
|
||||||
|
return (event_base_loop(event_base, 0));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
event_loopexit_cb(int fd, short what, void *arg)
|
event_loopexit_cb(int fd, short what, void *arg)
|
||||||
{
|
{
|
||||||
@ -293,11 +305,11 @@ event_loopexit(struct timeval *tv)
|
|||||||
int
|
int
|
||||||
event_loop(int flags)
|
event_loop(int flags)
|
||||||
{
|
{
|
||||||
return event_loop_base(current_base, flags);
|
return event_base_loop(current_base, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
event_loop_base(struct event_base *base, int flags)
|
event_base_loop(struct event_base *base, int flags)
|
||||||
{
|
{
|
||||||
const struct eventop *evsel = base->evsel;
|
const struct eventop *evsel = base->evsel;
|
||||||
void *evbase = base->evbase;
|
void *evbase = base->evbase;
|
||||||
|
6
event.h
6
event.h
@ -127,11 +127,12 @@ struct eventop {
|
|||||||
|
|
||||||
void *event_init(void);
|
void *event_init(void);
|
||||||
int event_dispatch(void);
|
int event_dispatch(void);
|
||||||
|
int event_base_dispatch(struct event_base *);
|
||||||
|
|
||||||
#define EVLOOP_ONCE 0x01
|
#define EVLOOP_ONCE 0x01
|
||||||
#define EVLOOP_NONBLOCK 0x02
|
#define EVLOOP_NONBLOCK 0x02
|
||||||
int event_loop(int);
|
int event_loop(int);
|
||||||
int event_loop_base(struct event_base *, int);
|
int event_base_loop(struct event_base *, int);
|
||||||
int event_loopexit(struct timeval *); /* Causes the loop to exit */
|
int event_loopexit(struct timeval *); /* Causes the loop to exit */
|
||||||
|
|
||||||
#define evtimer_add(ev, tv) event_add(ev, tv)
|
#define evtimer_add(ev, tv) event_add(ev, tv)
|
||||||
@ -170,7 +171,8 @@ int event_pending(struct event *, short, struct timeval *);
|
|||||||
|
|
||||||
/* These functions deal with event priorities */
|
/* These functions deal with event priorities */
|
||||||
|
|
||||||
int event_priority_init(struct event_base *, int);
|
int event_priority_init(int);
|
||||||
|
int event_base_priority_init(struct event_base *, int);
|
||||||
int event_priority_set(struct event *, int);
|
int event_priority_set(struct event *, int);
|
||||||
|
|
||||||
/* These functions deal with buffering input and output */
|
/* These functions deal with buffering input and output */
|
||||||
|
@ -562,7 +562,7 @@ test_priorities(int npriorities)
|
|||||||
snprintf(buf, sizeof(buf), "Priorities %d: ", npriorities);
|
snprintf(buf, sizeof(buf), "Priorities %d: ", npriorities);
|
||||||
setup_test(buf);
|
setup_test(buf);
|
||||||
|
|
||||||
event_priority_init(event_base, npriorities);
|
event_base_priority_init(event_base, npriorities);
|
||||||
|
|
||||||
memset(&one, 0, sizeof(one));
|
memset(&one, 0, sizeof(one));
|
||||||
memset(&two, 0, sizeof(two));
|
memset(&two, 0, sizeof(two));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user