From d5ca076379a82677d7148456e975bcb2f9f1b4b5 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sat, 2 May 2009 16:23:29 +0000 Subject: [PATCH] Move event_set() and friends to event2/event_compat.h. These functions are deprecated in favor of event_assign(). svn:r1267 --- ChangeLog | 2 ++ include/event2/event.h | 41 +---------------------------------- include/event2/event_compat.h | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 02360b5b..34e52c6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,8 @@ Changes in 2.0.2-alpha: o Do not use vararg macros for accessing evrpc structures; this is not backwards compatible, but we did not promise any backwards compatibility for the rpc code. o Actually define the event_config_set_flag() function. o Try harder to compile with Visual C++. + o Move event_set() and its allies to event2/event_compat.h where they belong. + Changes in 2.0.1-alpha: o free minheap on event_base_free(); from Christopher Layne diff --git a/include/event2/event.h b/include/event2/event.h index 5a0028a9..dc802ef7 100644 --- a/include/event2/event.h +++ b/include/event2/event.h @@ -316,10 +316,10 @@ int event_base_loopbreak(struct event_base *); Define a timer event. @param ev event struct to be modified + @param b an event_base @param cb callback function @param arg argument that will be passed to the callback function */ -#define evtimer_set(ev, cb, arg) event_set(ev, -1, 0, cb, arg) #define evtimer_assign(ev, b, cb, arg) event_assign(ev, b, -1, 0, cb, arg) #define evtimer_new(b, cb, arg) event_new(b, -1, 0, cb, arg) @@ -341,8 +341,6 @@ int event_base_loopbreak(struct event_base *); #define evtimer_initialized(ev) _event_initialized((ev), 0) #define evsignal_add(ev, tv) event_add(ev, tv) -#define evsignal_set(ev, x, cb, arg) \ - event_set(ev, x, EV_SIGNAL|EV_PERSIST, cb, arg) #define evsignal_assign(ev, b, x, cb, arg) \ event_assign(ev, b, x, EV_SIGNAL|EV_PERSIST, cb, arg) #define evsignal_new(b, x, cb, arg) \ @@ -351,43 +349,6 @@ int event_base_loopbreak(struct event_base *); #define evsignal_pending(ev, tv) event_pending(ev, EV_SIGNAL, tv) #define evsignal_initialized(ev) _event_initialized((ev), 0) -/** - Prepare an event structure to be added. - - The function event_set() prepares the event structure ev to be used in - future calls to event_add() and event_del(). The event will be prepared to - call the function specified by the fn argument with an int argument - indicating the file descriptor, a short argument indicating the type of - event, and a void * argument given in the arg argument. The fd indicates - the file descriptor that should be monitored for events. The events can be - either EV_READ, EV_WRITE, or both. Indicating that an application can read - or write from the file descriptor respectively without blocking. - - The function fn will be called with the file descriptor that triggered the - event and the type of event which will be either EV_TIMEOUT, EV_SIGNAL, - EV_READ, or EV_WRITE. The additional flag EV_PERSIST makes an event_add() - persistent until event_del() has been called. - - For read and write events, edge-triggered behavior can be requested - with the EV_ET flag. Not all backends support edge-triggered - behavior. When an edge-triggered event is activated, the EV_ET flag - is added to its events argument. - - @param ev an event struct to be modified - @param fd the file descriptor to be monitored - @param event desired events to monitor; can be EV_READ and/or EV_WRITE - @param fn callback function to be invoked when the event occurs - @param arg an argument to be passed to the callback function - - @see event_add(), event_del(), event_once() - - @deprecated event_set() is not recommended for new code, because it requires - a subsequent call to event_base_set() to be safe under many circumstances. - Use event_assign() or event_new() instead. - */ -void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *); - - /** Prepare an event structure to be added. diff --git a/include/event2/event_compat.h b/include/event2/event_compat.h index 31ada6a6..b59f9f9c 100644 --- a/include/event2/event_compat.h +++ b/include/event2/event_compat.h @@ -204,6 +204,46 @@ const char *event_get_method(void); */ int event_priority_init(int); +/** + Prepare an event structure to be added. + + The function event_set() prepares the event structure ev to be used in + future calls to event_add() and event_del(). The event will be prepared to + call the function specified by the fn argument with an int argument + indicating the file descriptor, a short argument indicating the type of + event, and a void * argument given in the arg argument. The fd indicates + the file descriptor that should be monitored for events. The events can be + either EV_READ, EV_WRITE, or both. Indicating that an application can read + or write from the file descriptor respectively without blocking. + + The function fn will be called with the file descriptor that triggered the + event and the type of event which will be either EV_TIMEOUT, EV_SIGNAL, + EV_READ, or EV_WRITE. The additional flag EV_PERSIST makes an event_add() + persistent until event_del() has been called. + + For read and write events, edge-triggered behavior can be requested + with the EV_ET flag. Not all backends support edge-triggered + behavior. When an edge-triggered event is activated, the EV_ET flag + is added to its events argument. + + @param ev an event struct to be modified + @param fd the file descriptor to be monitored + @param event desired events to monitor; can be EV_READ and/or EV_WRITE + @param fn callback function to be invoked when the event occurs + @param arg an argument to be passed to the callback function + + @see event_add(), event_del(), event_once() + + @deprecated event_set() is not recommended for new code, because it requires + a subsequent call to event_base_set() to be safe under many circumstances. + Use event_assign() or event_new() instead. + */ +void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *); + +#define evtimer_set(ev, cb, arg) event_set(ev, -1, 0, cb, arg) +#define evsignal_set(ev, x, cb, arg) \ + event_set(ev, x, EV_SIGNAL|EV_PERSIST, cb, arg) + /** * Add a timeout event. -- 2.40.0