libevent is a
software library
In computer science, a library is a collection of non-volatile resources used by computer programs, often for software development. These may include configuration data, documentation, help data, message templates, pre-written code and sub ...
that provides asynchronous event notification. The libevent
API
An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
provides a mechanism to execute a
callback
Callback may refer to:
* Callback (comedy), a joke which refers to one previously told
* Callback (computer programming), executable code that is passed as a parameter to other code
* Callback (telecommunications), the telecommunications event tha ...
function when a specific event occurs on a
file descriptor
In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier ( handle) for a file or other input/output resource, such as a pipe or network socket.
File descriptors typically ...
or after a
timeout
Time-out, Time Out, or timeout may refer to:
Time
* Time-out (sport), in various sports, a break in play, called by a team
* Television timeout, a break in sporting action so that a commercial break may be taken
* Timeout (computing), an engine ...
has been reached. libevent also supports callbacks triggered by
signals and regular timeouts.
libevent is meant to replace the
event loop In computer science, the event loop is a programming construct or design pattern that waits for and dispatches events or messages in a program. The event loop works by making a request to some internal or external "event provider" (that generally ...
found in event-driven
network servers. An application can just call
event_dispatch()
and then add or remove events dynamically without having to change the event loop.
Currently, libevent supports
/dev/poll
,
kqueue(2)
, POSIX
select(2)
, Windows
IOCP
Input/output completion port (IOCP) is an API for performing multiple simultaneous asynchronous input/output operations in Windows NT versions 3.5 and later, AIX and on Solaris 10 and later. An input/output completion port object is created and as ...
,
poll(2)
,
epoll(7)
and
Solaris event ports. It also has experimental support for real-time signals. The exposed event API is uniform over all of the supported platforms. As a result, libevent allows for
portable
Portable may refer to:
General
* Portable building, a manufactured structure that is built off site and moved in upon completion of site and utility work
* Portable classroom, a temporary building installed on the grounds of a school to provide a ...
application development and provides "the most
scalable
Scalability is the property of a system to handle a growing amount of work by adding resources to the system.
In an economic context, a scalable business model implies that a company can increase sales given increased resources. For example, a ...
event notification mechanism available on an operating system".
Using callbacks on signals, libevent makes it possible to write "secure" signal handlers as none of the user supplied signal handling code runs in the signal's
context
Context may refer to:
* Context (language use), the relevant constraints of the communicative situation that influence language use, language variation, and discourse summary
Computing
* Context (computing), the virtual environment required to s ...
.
libevent was created by
Niels Provos
Niels Provos is a German-American researcher in security engineering, malware, and cryptography. He received a PhD in computer science from the University of Michigan. From 2003 to 2018, he worked at Google as a Distinguished Engineer on security ...
and is maintained primarily by Azat Khuzhin. It is released under a
BSD license
BSD licenses are a family of permissive free software licenses, imposing minimal restrictions on the use and distribution of covered software. This is in contrast to copyleft licenses, which have share-alike requirements. The original BSD li ...
.
Notable applications
Some of the notable applications that take advantage of libevent are:
*
Google Chrome
Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macO ...
: Google's web browser (Mac and Linux versions)
*
Memcached
Memcached (pronounced variously ''mem-cash-dee'' or ''mem-cashed'') is a general-purpose distributed memory caching, memory-caching system. It is often used to speed up dynamic database-driven websites by caching data and Object (computer science) ...
: a high-performance, distributed memory object caching system
*
Transmission
Transmission may refer to:
Medicine, science and technology
* Power transmission
** Electric power transmission
** Propulsion transmission, technology allowing controlled application of power
*** Automatic transmission
*** Manual transmission
** ...
: an open-source BitTorrent client
*
ntpd
The Network Time Protocol daemon (ntpd) is an operating system program that maintains the system time in synchronization with time servers using the Network Time Protocol (NTP).
Description
The ntpd program is an operating-system daemon that ...
: the Network Time Protocol
daemon
Daimon or Daemon (Ancient Greek: , "god", "godlike", "power", "fate") originally referred to a lesser deity or guiding spirit such as the daimons of ancient Greek religion and mythology and of later Hellenistic religion and philosophy.
The wo ...
*
Tor: an anonymous Internet communication system
*
tmux
tmux is an open-source terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window. It is useful for running more than one command-line program at the same ti ...
: a terminal multiplexer
Alternatives
libev*
libuv
libuv is a multi-platform C library that provides support for asynchronous I/O based on event loops. It supports epoll(4), kqueue(2), Windows IOCP, and Solaris event ports. It is primarily designed for use in Node.js but it is also used ...
*
FAM
Boost Asio
Major version releases
*libevent 2.1 was released on April 3, 2012.
*libevent 2.0 was released on April 17, 2009.
*libevent 1.4 was released on November 11, 2007.
*libevent 1.3 was released on February 15, 2007.
*libevent 1.2 was released on October 15, 2006.
*libevent 1.1 was released on May 14, 2005.
References
External links
{{Portal, Free and open-source software
Libevent web pageLibevent github repositoryLibevent 2.0 book
C (programming language) libraries
Events (computing)
Free computer libraries
Software using the BSD license