标签:
Libevent is a library for writing fast portable nonblocking IO.
libevent是一个为编写快速可移植的非阻塞IO程序而设计的。
libevent包括了以下组件:
1. evutil
Generic functionality to abstract out the differences between different platforms‘ networking implementations.
用于抽象不同平台网络实现差异的通用功能。
2. event & event_base
This is the heart of Libevent. It provides an abstract API to the various platform-specific, event-based nonblocking IO backends. It can let you know when sockets are ready to read or write, do basic timeout functionality, and detect OS signals.
libevent的核心,为各种平台特定的、基于事件的非阻塞IO后端(backend,即epoll、select等)提供抽象API。它们能够通知应用套接字是否已经准备好读或者写,并具备处理超时的基本功能,且能够检测操作系统信号。
3. bufferevent
These functions provide a more convenient wrapper around Libevent’s event-based core. They let your application request buffered reads and writes, and rather than informing you when sockets are ready to do, they let you know when IO has actually occurred.
(The bufferevent interface also has multiple backends, so that it can take advantage of systems that provide faster ways to do nonblocking IO, such as the Windows IOCP API.)
bufferevent中的函数为libevent基于事件的核心提供了使用更方便的封装。它们使得我们的应用可以请求已经缓冲的读写操作。另外,它们让我们知道IO读写已经真正发生,而不是当套接字准备好读或写就通知我们。
(bufferevent接口有多个后端,它可以采用系统提供的更快的非阻塞IO后端,例如Windows中的IOCP API。)
4. evbuffer
This module implements the buffers underlying bufferevents, and provides functions for efficient and/or convenient access.
在bufferevent层之下实现了缓冲功能,并且提供了方便有效的访问函数。
5. evhttp
A simple HTTP client/server implementation.
一个简单的HTTP客户端/服务器实现。
6. evdns
A simple DNS client/server implementation.
一个简单的DNS客户端/服务器实现。
7. evrpc
A simple RPC implementation.
一个简单的RPC实现。
1. event_core
All core event and buffer functionality. This library contains all the event_base, evbuffer, bufferevent, and utility functions.
该库包含了所有核心的事件和缓冲功能,包含了所有的event_base、evbuffer、bufferevent和辅助(utility)函数。
2. event_extra
This library defines protocol-specific functionality that you may or may not want for your application, including HTTP, DNS, and RPC.
该库定义了程序可能需要,也可能不需要的协议特定功能,包括HTTP、DNS和RPC。
3. event
This library exists for historical reasons; it contains the contents of both libevent_core and libevent_extra. You shouldn’t use it; it may go away in a future version of Libevent.
这个库因为历史原因而存在,它包含了libevent_core和libevent_extra的内容。我们不应该使用这个库。未来版本的libevent可能去掉这个库。
某些平台上可能安装下列库:
4. event_pthreads
This library adds threading and locking implementations based on the pthreads portable threading library. It is separated from libevent_core so that you don’t need to link against pthreads to use Libevent unless you are actually using Libevent in a multithreaded way.
该库添加了基于pthread可移植线程库的线程和锁实现。它独立于libevent_core,这样程序使用libevent时就不需要链接到pthread,除非是以多线程方式使用libevent。
5. event_openssl
This library provides support for encrypted communications using bufferevents and the OpenSSL library. It is separated from libevent_core so that you don’t need to link against OpenSSL to use Libevent unless you are actually using encrypted connections.
该库为使用bufferevent和OpenSSL的加密通信提供支持。它独立于libevent_core,这样程序使用libevent时就不需要链接到OpenSSL,除非是进行加密通信。
All current public Libevent headers are installed under the event2 directory. Headers fall into three broad classes:
libevent公用头文件都安装在event2目录中。头文件可以大概分为三类:
1. API headers
An API header is one that defines current public interfaces to Libevent. These headers have no special suffix.
定义libevent公用接口。这类头文件没有特定后缀。
2. Compatibility headers
A compatibility header includes definitions for deprecated functions. You shouldn’t include it unless you’re porting a program from an older version of Libevent.
为已废弃的函数提供兼容。不应该使用这类头文件,除飞要移植使用较老版本libevent的程序。
3. Structure headers
These headers define structures with relatively volatile layouts. Some of these are exposed in case you need fast access to structure component; some are exposed for historical reasons. Relying on any of the structures in headers directly can break your program’s binary compatibility with other versions of Libevent, sometimes in hard-to-debug ways. These headers have the suffix "_struct.h"
这类头文件以相对不稳定的布局定义各种结构体。这些结构体中的一些是为了提供快速访问而暴露;一些是因为历史原因而暴露。直接依赖这类头文件中的任何结构体都会破坏程序对其他版本libevent的二进制兼容性。这些问题有时候是以非常难以调试的方式出现。这类头文件具有后缀“_struct.h”。
libevent 2.0以更合理的、不易出错的方式修正了API。如果可能,编写新程序时应该使用libevent 2.0。但是有时候可能需要使用较老的API,例如在升级已存的应用时,或者支持因为某些原因不能安装2.0或者更新版本libevent的环境时。较老版本的libevent头文件较少,也不安装在event2目录中。
在2.0以及以后版本的libevent中,老的头文件仍然会作为新头文件的封装而存在。
其他关于使用较老版本的提示:
参考资料
The Libevent Reference Manual: Preliminaries
标签:
原文地址:http://www.cnblogs.com/xiehongfeng100/p/4692819.html