3 #include <event2/event.h> 15 short ret_eveflag=EV_PERSIST;
44 return event_base_new();
50 struct event_base * base = (
struct event_base *)
this;
54 if(!instance)
return NULL;
59 if(!instance->
event) {
64 if(event_add(instance->
event, NULL) == -1) {
71 if(instance->
event) event_free(instance->
event);
78 struct event_base * event_base = (
struct event_base *)
this;
88 event_base_loopcontinue(event_base);
96 event_del(instance->
event);
97 event_free(instance->
event);
103 return event_get_fd(instance->
event);
108 event_base_dispatch((
struct event_base *)
this);
114 event_base_loopbreak((
struct event_base *)
this);
119 struct event_base * base = (
struct event_base *)
this;
120 if(event_base_got_break(base)) {
121 event_base_loopbreak(base);
127 event_base_free((
struct event_base *)
this);
struct event_libevent_handler_t * EventLibeventHandler
EventHandler event_if_add(EventInstance this, EventSubscriber subscriber, void *arg)
add new event
static void event_if_libevent_callback(evutil_socket_t fd, short eventflag, void *arg)
void event_if_del(EventInstance this, EventHandler handler)
delete event
static int convert_etpoll_own2eveid(short eventflag)
void(* free)(EventInstance this)
void event_if_loopbreak(EventInstance this)
break event
static short convert_etpoll_eveid2own(int eventflag)
void(* event_callback)(int socketfd, int eventflag, void *event_arg)
void * EventHandler
Event handler related to fd.
EventSubscriber class instance definition, this is storaged in any threads.
event_subscriber_t subscriber
int eventflag
OR value of EV_TPOOL_XXX definition.
int fd
file descripter of this subscriber
void * EventInstance
Event management instance which get from event_if_new.
void event_if_exit(EventInstance this)
exit after main loop
void * event_if_update(EventInstance this, EventHandler handler, EventSubscriber subscriber, void *arg)
update registered event
int event_if_getfd(EventHandler handler)
get fd related to handler
#define DEBUG_ERRPRINT(...)
EventInstance event_if_new(void)
event new
int event_if_loop(EventInstance this)
main loop of this event
void event_if_free(EventInstance this)
free event if instance