libevent 2.1.13 Event notification library

Loading...
Searching...
No Matches
event_compat.h File Reference

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

`#include <event2/visibility.h>`
`#include <event2/event-config.h>`
`#include <event2/util.h>`

Go to the source code of this file.

## Macros
#define | EVENT_FD(ev)
#define | EVENT_SIGNAL(ev)
#define | evsignal_set(ev, x, cb, arg)
#define | evtimer_set(ev, cb, arg)
timeout_* macros
Deprecated These macros are deprecated because their naming is inconsistent with the rest of Libevent. Use the evtimer_* macros instead.
#define | timeout_add(ev, tv)
#define | timeout_del(ev)
#define | timeout_initialized(ev)
#define | timeout_pending(ev, tv)
#define | timeout_set(ev, cb, arg)
signal_* macros
Deprecated These macros are deprecated because their naming is inconsistent with the rest of Libevent. Use the evsignal_* macros instead.
#define | signal_add(ev, tv)
#define | signal_del(ev)
#define | signal_initialized(ev)
#define | signal_pending(ev, tv)
#define | signal_set(ev, x, cb, arg)

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

## Detailed Description

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

In the oldest versions of Libevent, event_base was not a first-class structure. Instead, there was a single event base that every function manipulated. Later, when separate event bases were added, the old functions that didn't take an event_base argument needed to work by manipulating the "current" event base. This could lead to thread-safety issues, and obscure, hard-to-diagnose bugs.

Deprecated
  All functions in this file are by definition deprecated.

## Macro Definition Documentation

## ◆ EVENT_FD

#define EVENT_FD | ( |  | ev | ) |

Value:
((int)event_get_fd(ev))
event_get_fd
EVENT2_EXPORT_SYMBOL evutil_socket_t event_get_fd(const struct event *ev)
Get the socket or signal assigned to an event, or -1 if the event has no socket.

## ◆ EVENT_SIGNAL

#define EVENT_SIGNAL | ( |  | ev | ) |

Value:
event_get_signal(ev)
event_get_signal
#define event_get_signal(ev)
Get the signal number assigned to a signal event.
Definition event.h:1339

## ◆ evsignal_set

#define evsignal_set | ( |  | ev,
|  |  | x,
|  |  | cb,
|  |  | arg )

Value:
event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
EV_PERSIST
#define EV_PERSIST
Persistent event: won't get removed automatically when activated.
Definition event.h:934
EV_SIGNAL
#define EV_SIGNAL
Wait for a POSIX signal to be raised.
Definition event.h:927
event_set
EVENT2_EXPORT_SYMBOL void event_set(struct event *, evutil_socket_t, short, void(*)(evutil_socket_t, short, void *), void *)
Prepare an event structure to be added.

## ◆ evtimer_set

#define evtimer_set | ( |  | ev,
|  |  | cb,
|  |  | arg )

Value:
event_set((ev), -1, 0, (cb), (arg))

## ◆ signal_add

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

Value:
event_add((ev), (tv))
event_add
EVENT2_EXPORT_SYMBOL int event_add(struct event *ev, const struct timeval *timeout)
Add an event to the set of pending events.

## ◆ signal_del

#define signal_del | ( |  | ev | ) |

Value:
event_del(ev)
event_del
EVENT2_EXPORT_SYMBOL int event_del(struct event *)
Remove an event from the set of monitored events.

## ◆ signal_initialized

#define signal_initialized | ( |  | ev | ) |

Value:
event_initialized(ev)
event_initialized
EVENT2_EXPORT_SYMBOL int event_initialized(const struct event *ev)
Test if an event structure might be initialized.

## ◆ signal_pending

#define signal_pending | ( |  | ev,
|  |  | tv )

Value:
event_pending((ev), EV_SIGNAL, (tv))
event_pending
EVENT2_EXPORT_SYMBOL int event_pending(const struct event *ev, short events, struct timeval *tv)
Checks if a specific event is pending or scheduled.

## ◆ signal_set

#define signal_set | ( |  | ev,
|  |  | x,
|  |  | cb,
|  |  | arg )

Value:
event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))

## ◆ timeout_add

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

Value:
event_add((ev), (tv))

## ◆ timeout_del

#define timeout_del | ( |  | ev | ) |

Value:
event_del(ev)

## ◆ timeout_initialized

#define timeout_initialized | ( |  | ev | ) |

Value:
event_initialized(ev)

## ◆ timeout_pending

#define timeout_pending | ( |  | ev,
|  |  | tv )

Value:
event_pending((ev), EV_TIMEOUT, (tv))
EV_TIMEOUT
#define EV_TIMEOUT
Indicates that a timeout has occurred.
Definition event.h:921

## ◆ timeout_set

#define timeout_set | ( |  | ev,
|  |  | cb,
|  |  | arg )

Value:
event_set((ev), -1, 0, (cb), (arg))

## Function Documentation

## ◆ event_dispatch()

EVENT2_EXPORT_SYMBOL int event_dispatch | ( | void |  | ) |

Loop to process events.

Like event_base_dispatch(), but uses the "current" base.

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(), event_init()

## ◆ event_get_method()

EVENT2_EXPORT_SYMBOL const char * event_get_method | ( | void |  | ) |

Get the kernel event notification mechanism used by Libevent.

Deprecated
  This function is obsolete, and has been replaced by event_base_get_method(). Its use is deprecated because it relies on the "current" base configured by event_init().

See also
  event_base_get_method()

## ◆ event_init()

EVENT2_EXPORT_SYMBOL struct event_base * event_init | ( | void |  | ) |

Initialize the event API.

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

Deprecated
  This function is deprecated because it replaces 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()

## ◆ event_loop()

EVENT2_EXPORT_SYMBOL int event_loop | ( | int |  | ) |

Handle events.

This function behaves like event_base_loop(), but uses the "current" base

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().

See also
  event_base_loop(), event_init()

## ◆ event_loopbreak()

EVENT2_EXPORT_SYMBOL int event_loopbreak | ( | void |  | ) |

Abort the active event_loop() immediately.

This function behaves like event_base_loopbreakt(), except that it uses the "current" base.

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_loopbreak().

See also
  event_base_loopbreak(), event_init()

## ◆ event_loopexit()

EVENT2_EXPORT_SYMBOL int event_loopexit | ( | const struct timeval * |  | ) |

Exit the event loop after the specified time.

This function behaves like event_base_loopexit(), except that it uses the "current" base.

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_loopexit().

See also
  event_init, event_base_loopexit()

## ◆ event_once()

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

Schedule a one-time event to occur.

Deprecated
  This function is obsolete, and has been replaced by event_base_once(). Its use is deprecated because it relies on the "current" base configured by event_init().

See also
  event_base_once()

## ◆ event_priority_init()

EVENT2_EXPORT_SYMBOL int event_priority_init | ( | int |  | ) |

Set the number of different event priorities.

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().

See also
  event_base_priority_init()

## ◆ event_set()

EVENT2_EXPORT_SYMBOL void event_set | ( | struct event * | ,
|  | evutil_socket_t | ,
|  | short | ,
|  | void(* | )(evutil_socket_t, short, void *),
|  | void * | )

Prepare an event structure to be added.

Deprecated
  event_set() is not recommended for new code, because it requires a subsequent call to event_base_set() to be safe under most circumstances. Use event_assign() or event_new() instead.