include/event2/event_compat.h File Reference

Potentially non-threadsafe versions of the functions in event.h: provided only for backwards compatibility. More...

#include <event-config.h>
#include <sys/types.h>
#include <sys/time.h>
#include <event2/util.h>

Go to the source code of this file.

Defines

#define signal_add(ev, tv)   event_add(ev, tv)
#define signal_assign(ev, b, x, cb, arg)   event_assign(ev, b, x, EV_SIGNAL|EV_PERSIST, cb, arg)
#define signal_del(ev)   event_del(ev)
#define signal_initialized(ev)   _event_initialized((ev), 0)
#define signal_new(b, x, cb, arg)   event_new(b, x, EV_SIGNAL|EV_PERSIST, cb, arg)
#define signal_pending(ev, tv)   event_pending(ev, EV_SIGNAL, tv)
#define signal_set(ev, x, cb, arg)   event_set(ev, x, EV_SIGNAL|EV_PERSIST, cb, arg)
#define timeout_add(ev, tv)   event_add(ev, tv)
 Add a timeout event.
#define timeout_del(ev)   event_del(ev)
 Disable a timeout event.
#define timeout_initialized(ev)   _event_initialized((ev), 0)
#define timeout_pending(ev, tv)   event_pending(ev, EV_TIMEOUT, tv)
#define timeout_set(ev, cb, arg)   event_set(ev, -1, 0, cb, arg)
 Define a timeout event.

Functions

int event_dispatch (void)
 Loop to process events.
const char * event_get_method (void)
 Get the kernel event notification mechanism used by libevent.
struct event_base * event_init (void)
 Initialize the event API.
int event_loop (int)
 Handle events.
int event_loopbreak (void)
 Abort the active event_loop() immediately.
int event_loopexit (const struct timeval *)
 Exit the event loop after the specified time.
int event_once (evutil_socket_t, short, void(*)(evutil_socket_t, short, void *), void *, const struct timeval *)
 Schedule a one-time event to occur.
int event_priority_init (int)
 Set the number of different event priorities.


Detailed Description

Potentially non-threadsafe versions of the functions in event.h: provided only for backwards compatibility.


Define Documentation

#define signal_add ( ev,
tv   )     event_add(ev, tv)

Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evsignal_add().

#define signal_assign ( ev,
b,
x,
cb,
arg   )     event_assign(ev, b, x, EV_SIGNAL|EV_PERSIST, cb, arg)

Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evsignal_assign().

#define signal_del ( ev   )     event_del(ev)

Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evsignal_del().

#define signal_initialized ( ev   )     _event_initialized((ev), 0)

Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evsignal_initialized().

#define signal_new ( b,
x,
cb,
arg   )     event_new(b, x, EV_SIGNAL|EV_PERSIST, cb, arg)

Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evsignal_new().

#define signal_pending ( ev,
tv   )     event_pending(ev, EV_SIGNAL, tv)

Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evsignal_pending().

#define signal_set ( ev,
x,
cb,
arg   )     event_set(ev, x, EV_SIGNAL|EV_PERSIST, cb, arg)

Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evsignal_set().

#define timeout_add ( ev,
tv   )     event_add(ev, tv)

Add a timeout event.

Parameters:
ev the event struct to be disabled
tv the timeout value, in seconds
Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evtimer_add().

#define timeout_del ( ev   )     event_del(ev)

Disable a timeout event.

Parameters:
ev the timeout event to be disabled
Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evtimer_del().

#define timeout_initialized ( ev   )     _event_initialized((ev), 0)

Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evtimer_initialized().

#define timeout_pending ( ev,
tv   )     event_pending(ev, EV_TIMEOUT, tv)

Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evtimer_pending().

#define timeout_set ( ev,
cb,
arg   )     event_set(ev, -1, 0, cb, arg)

Define a timeout event.

Parameters:
ev the event struct to be defined
cb the callback to be invoked when the timeout expires
arg the argument to be passed to the callback
Deprecated:
This macro is deprecated because its naming is inconsistent. The recommend macro is evtimer_set().


Function Documentation

int event_dispatch ( void   ) 

Loop to process events.

In order to process events, an application needs to call event_dispatch(). This function only returns on error, and should replace the event core of the application program.

Deprecated:
This function is deprecated because it is easily confused by multiple calls to event_init(), and because it is not safe for multithreaded use. The replacement is event_base_dispatch().
See also:
event_base_dispatch()

const char* event_get_method ( void   ) 

Get the kernel event notification mechanism used by libevent.

Returns:
a string identifying the kernel event mechanism (kqueue, epoll, etc.)
Deprecated:
This function is deprecated because it is easily confused by multiple calls to event_init(), and because it is not safe for multithreaded use. The replacement is event_base_get_method().

struct event_base* event_init ( void   )  [read]

Initialize the event API.

The event API needs to be initialized with event_init() before it can be used. Sets the current_base global representing the default base for events that have no base associated with them.

Deprecated:
This function is deprecated because it relaces the "current" event_base, and is totally unsafe for multithreaded use. The replacement is event_base_new().
See also:
event_base_set(), event_base_new()

int event_loop ( int   ) 

Handle events.

This is a more flexible version of event_dispatch().

Deprecated:
This function is deprecated because it uses the event base from the last call to event_init, and is therefore not safe for multithreaded use. The replacement is event_base_loop().
Parameters:
flags any combination of EVLOOP_ONCE | EVLOOP_NONBLOCK
Returns:
0 if successful, -1 if an error occurred, or 1 if no events were registered.
See also:
event_base_loopexit(), event_base_loop()

int event_loopbreak ( void   ) 

Abort the active event_loop() immediately.

event_loop() will abort the loop after the next event is completed; event_loopbreak() is typically invoked from this event's callback. This behavior is analogous to the "break;" statement.

Subsequent invocations of event_loop() will proceed normally.

Deprecated:
This function is deprecated because it is easily confused by multiple calls to event_init(), and because it is not safe for multithreaded use. The replacement is event_base_loopbreak().
Returns:
0 if successful, or -1 if an error occurred
See also:
event_base_loopbreak(), event_loopexit()

int event_loopexit ( const struct timeval *   ) 

Exit the event loop after the specified time.

The next event_loop() iteration after the given timer expires will complete normally (handling all queued events) then exit without blocking for events again.

Subsequent invocations of event_loop() will proceed normally.

Deprecated:
This function is deprecated because it is easily confused by multiple calls to event_init(), and because it is not safe for multithreaded use. The replacement is event_base_loopexit().
Parameters:
tv the amount of time after which the loop should terminate.
Returns:
0 if successful, or -1 if an error occurred
See also:
event_loop(), event_base_loop(), event_base_loopexit()

int event_once ( evutil_socket_t  ,
short  ,
void(*)(evutil_socket_t, short, void *)  ,
void *  ,
const struct timeval *   
)

Schedule a one-time event to occur.

The function event_once() is similar to event_set(). However, it schedules a callback to be called exactly once and does not require the caller to prepare an event structure.

Deprecated:
This function is deprecated because it is easily confused by multiple calls to event_init(), and because it is not safe for multithreaded use. The replacement is event_base_once().
Parameters:
fd a file descriptor to monitor
events event(s) to monitor; can be any of EV_TIMEOUT | EV_READ | EV_WRITE
callback callback function to be invoked when the event occurs
arg an argument to be passed to the callback function
timeout the maximum amount of time to wait for the event, or NULL to wait forever
Returns:
0 if successful, or -1 if an error occurred
See also:
event_set()

int event_priority_init ( int   ) 

Set the number of different event priorities.

By default libevent schedules all active events with the same priority. However, some time it is desirable to process some events with a higher priority than others. For that reason, libevent supports strict priority queues. Active events with a lower priority are always processed before events with a higher priority.

The number of different priorities can be set initially with the event_priority_init() function. This function should be called before the first call to event_dispatch(). The event_priority_set() function can be used to assign a priority to an event. By default, libevent assigns the middle priority to all events unless their priority is explicitly set.

Deprecated:
This function is deprecated because it is easily confused by multiple calls to event_init(), and because it is not safe for multithreaded use. The replacement is event_base_priority_init().
Parameters:
npriorities the maximum number of priorities
Returns:
0 if successful, or -1 if an error occurred
See also:
event_base_priority_init(), event_priority_set()


Generated on Fri Apr 17 21:33:56 2009 for libevent by  doxygen 1.5.7