root/opal/mca/event/libevent2022/libevent/include/event2/event_compat.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
   3  * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  * 1. Redistributions of source code must retain the above copyright
   9  *    notice, this list of conditions and the following disclaimer.
  10  * 2. Redistributions in binary form must reproduce the above copyright
  11  *    notice, this list of conditions and the following disclaimer in the
  12  *    documentation and/or other materials provided with the distribution.
  13  * 3. The name of the author may not be used to endorse or promote products
  14  *    derived from this software without specific prior written permission.
  15  *
  16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26  */
  27 #ifndef _EVENT2_EVENT_COMPAT_H_
  28 #define _EVENT2_EVENT_COMPAT_H_
  29 
  30 /** @file event2/event_compat.h
  31 
  32   Potentially non-threadsafe versions of the functions in event.h: provided
  33   only for backwards compatibility.
  34 
  35   In the oldest versions of Libevent, event_base was not a first-class
  36   structure.  Instead, there was a single event base that every function
  37   manipulated.  Later, when separate event bases were added, the old functions
  38   that didn't take an event_base argument needed to work by manipulating the
  39   "current" event base.  This could lead to thread-safety issues, and obscure,
  40   hard-to-diagnose bugs.
  41 
  42   @deprecated All functions in this file are by definition deprecated.
  43  */
  44 
  45 #ifdef __cplusplus
  46 extern "C" {
  47 #endif
  48 
  49 #include <event2/event-config.h>
  50 #ifdef _EVENT_HAVE_SYS_TYPES_H
  51 #include <sys/types.h>
  52 #endif
  53 #ifdef _EVENT_HAVE_SYS_TIME_H
  54 #include <sys/time.h>
  55 #endif
  56 
  57 /* For int types. */
  58 #include <event2/util.h>
  59 
  60 /**
  61   Initialize the event API.
  62 
  63   The event API needs to be initialized with event_init() before it can be
  64   used.  Sets the global current base that gets used for events that have no
  65   base associated with them.
  66 
  67   @deprecated This function is deprecated because it replaces the "current"
  68     event_base, and is totally unsafe for multithreaded use.  The replacement
  69     is event_base_new().
  70 
  71   @see event_base_set(), event_base_new()
  72  */
  73 struct event_base *event_init(void);
  74 
  75 /**
  76   Loop to process events.
  77 
  78   Like event_base_dispatch(), but uses the "current" base.
  79 
  80   @deprecated This function is deprecated because it is easily confused by
  81     multiple calls to event_init(), and because it is not safe for
  82     multithreaded use.  The replacement is event_base_dispatch().
  83 
  84   @see event_base_dispatch(), event_init()
  85  */
  86 int event_dispatch(void);
  87 
  88 /**
  89   Handle events.
  90 
  91   This function behaves like event_base_loop(), but uses the "current" base
  92 
  93   @deprecated This function is deprecated because it uses the event base from
  94     the last call to event_init, and is therefore not safe for multithreaded
  95     use.  The replacement is event_base_loop().
  96 
  97   @see event_base_loop(), event_init()
  98 */
  99 int event_loop(int);
 100 
 101 
 102 /**
 103   Exit the event loop after the specified time.
 104 
 105   This function behaves like event_base_loopexit(), except that it uses the
 106   "current" base.
 107 
 108   @deprecated This function is deprecated because it uses the event base from
 109     the last call to event_init, and is therefore not safe for multithreaded
 110     use.  The replacement is event_base_loopexit().
 111 
 112   @see event_init, event_base_loopexit()
 113   */
 114 int event_loopexit(const struct timeval *);
 115 
 116 
 117 /**
 118   Abort the active event_loop() immediately.
 119 
 120   This function behaves like event_base_loopbreakt(), except that it uses the
 121   "current" base.
 122 
 123   @deprecated This function is deprecated because it uses the event base from
 124     the last call to event_init, and is therefore not safe for multithreaded
 125     use.  The replacement is event_base_loopbreak().
 126 
 127   @see event_base_loopbreak(), event_init()
 128  */
 129 int event_loopbreak(void);
 130 
 131 /**
 132   Schedule a one-time event to occur.
 133 
 134   @deprecated This function is obsolete, and has been replaced by
 135     event_base_once(). Its use is deprecated because it relies on the
 136     "current" base configured by event_init().
 137 
 138   @see event_base_once()
 139  */
 140 int event_once(evutil_socket_t , short,
 141     void (*)(evutil_socket_t, short, void *), void *, const struct timeval *);
 142 
 143 
 144 /**
 145   Get the kernel event notification mechanism used by Libevent.
 146 
 147   @deprecated This function is obsolete, and has been replaced by
 148     event_base_get_method(). Its use is deprecated because it relies on the
 149     "current" base configured by event_init().
 150 
 151   @see event_base_get_method()
 152  */
 153 const char *event_get_method(void);
 154 
 155 
 156 /**
 157   Set the number of different event priorities.
 158 
 159   @deprecated This function is deprecated because it is easily confused by
 160     multiple calls to event_init(), and because it is not safe for
 161     multithreaded use.  The replacement is event_base_priority_init().
 162 
 163   @see event_base_priority_init()
 164  */
 165 int     event_priority_init(int);
 166 
 167 /**
 168   Prepare an event structure to be added.
 169 
 170   @deprecated event_set() is not recommended for new code, because it requires
 171      a subsequent call to event_base_set() to be safe under most circumstances.
 172      Use event_assign() or event_new() instead.
 173  */
 174 void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
 175 
 176 #define evtimer_set(ev, cb, arg)        event_set((ev), -1, 0, (cb), (arg))
 177 #define evsignal_set(ev, x, cb, arg)    \
 178         event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
 179 
 180 
 181 /**
 182    @name timeout_* macros
 183 
 184    @deprecated These macros are deprecated because their naming is inconsistent
 185      with the rest of Libevent.  Use the evtimer_* macros instead.
 186    @{
 187  */
 188 #define timeout_add(ev, tv)             event_add((ev), (tv))
 189 #define timeout_set(ev, cb, arg)        event_set((ev), -1, 0, (cb), (arg))
 190 #define timeout_del(ev)                 event_del(ev)
 191 #define timeout_pending(ev, tv)         event_pending((ev), EV_TIMEOUT, (tv))
 192 #define timeout_initialized(ev)         event_initialized(ev)
 193 /**@}*/
 194 
 195 /**
 196    @name signal_* macros
 197 
 198    @deprecated These macros are deprecated because their naming is inconsistent
 199      with the rest of Libevent.  Use the evsignal_* macros instead.
 200    @{
 201  */
 202 #define signal_add(ev, tv)              event_add((ev), (tv))
 203 #define signal_set(ev, x, cb, arg)                              \
 204         event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
 205 #define signal_del(ev)                  event_del(ev)
 206 #define signal_pending(ev, tv)          event_pending((ev), EV_SIGNAL, (tv))
 207 #define signal_initialized(ev)          event_initialized(ev)
 208 /**@}*/
 209 
 210 #ifndef EVENT_FD
 211 /* These macros are obsolete; use event_get_fd and event_get_signal instead. */
 212 #define EVENT_FD(ev)            ((int)event_get_fd(ev))
 213 #define EVENT_SIGNAL(ev)        event_get_signal(ev)
 214 #endif
 215 
 216 #ifdef __cplusplus
 217 }
 218 #endif
 219 
 220 #endif /* _EVENT2_EVENT_COMPAT_H_ */

/* [<][>][^][v][top][bottom][index][help] */