What's New In Libevent 2.0 so far:
1. Meta-issues
1.1. About this document
This document describes the key differences between Libevent 1.4 and
Libevent 2.0, from a user's point of view. It was most recently
updated based on features in git master as of August 2010.
NOTE: I am very sure that I missed some thing on this list. Caveat
haxxor.
1.2. Better documentation
There is now a book-in-progress that explains how to use Libevent and its
growing pile of APIs. As of this writing, it covers everything except the
http and rpc code. Check out the latest draft at
http://www.wangafu.net/~nickm/libevent-book/ .
2. New and Improved Event APIs
Many APIs are improved, refactored, or deprecated in Libevent 2.0.
COMPATIBILITY:
Nearly all existing code that worked with should Libevent 1.4 should still
work correctly with Libevent 2.0. However, if you are writing new code,
or if you want to port old code, we strongly recommend using the new APIs
and avoiding deprecated APIs as much as possible.
Binaries linked against Libevent 1.4 will need to be recompiled to link
against Libevent 2.0. This is nothing new; we have never been good at
preserving binary compatibility between releases. We'll try harder in the
future, though: see 2.1 below.
2.1. New header layout for improved forward-compatibility
Libevent 2.0 has a new header layout to make it easier for programmers to
write good, well-supported libevent code. The new headers are divided
into three types.
There are *regular headers*, like event2/event.h. These headers contain
the functions that most programmers will want to use.
There are *backward compatibility headers*, like event2/event_compat.h.
These headers contain declarations for deprecated functions from older
versions of Libevent. Documentation in these headers should suggest what's
wrong with the old functions, and what functions you want to start using
instead of the old ones. Some of these functions might be removed in a
future release. New programs should generally not include these headers.
Finally, there are *structure headers*, like event2/event_struct.h.
These headers contain definitions of some structures that Libevent has
historically exposed. Exposing them caused problems in the past,
since programs that were compiled to work with one version of Libevent
would often stop working with another version that changed the size or
layout of some object. We've moving them into separate headers so
that programmers can know that their code is not depending on any
unstable aspect of the Libvent ABI. New programs should generally not
include these headers unless they really know what they are doing, are
willing to rebuild their software whenever they want to link it
against a new version of Libevent, and are willing to risk their code
breaking if and when data structures change.
Functionality that once was located in event.h is now more subdivided.
The core event logic is now in event2/event.h. The "evbuffer" functions
for low-level buffer manipulation are in event2/buffer.h. The
"bufferevent" functions for higher-level buffered IO are in
event2/bufferevent.h.
COMPATIBILITY:
All of the old headers (event.h, evdns.h, evhttp.h, evrpc.h, and
evutil.h) will continue to work by including the corresponding new
headers. Old code should not be broken by this change.
2.2. New thread-safe, binary-compatible, harder-to-mess-up APIs
Some aspects of the historical Libevent API have encouraged
non-threadsafe code, or forced code built against one version of Libevent
to no longer build with another. The problems with now-deprecated APIs
fell into two categories:
1) Dependence on the "current" event_base. In an application with
multiple event_bases, Libevent previously had a notion of the
"current" event_base. New events were linked to this base, and
the caller needed to explicitly reattach them to another base.
This was horribly error-prone.
Functions like "event_set" that worked with the "current" event_base
are now deprecated but still available (see 2.1). There are new
functions like "event_assign" that take an explicit event_base
argument when setting up a structure. Using these functions will help
prevent errors in your applications, and to be more threadsafe.
2) Structure dependence. Applications needed to allocate 'struct
event' themselves, since there was no function in Libevent to do it
for them. But since the size and contents of struct event can
change between libevent versions, this created binary-compatibility
nightmares. All structures of this kind are now isolated in
_struct.h header (see 2.1), and there are new allocate-and-
initialize functions you can use instead of the old initialize-only
functions. For example, instead of malloc and event_set, you
can use event_new().
(For people who do really want to allocate a struct event on the
stack, or put one inside another structure, you can still use
event2/event_compat.h.)
So in the case where old code would look like this:
#include <event.h>
...
struct event *ev = malloc(sizeof(struct event));
/* This call will cause a buffer overrun if you compile with one version
of Libevent and link dynamically against another. */
event_set(ev, fd, EV_READ, cb, NULL);
/* If you forget this call, your code will break in hard-to-diagnose
ways in the presence of multiple event bases. */
event_set_base(ev, base);
New code will look more like this:
#include <event2/event.h>
...
struct event *ev;
ev = event_new(base, fd, EV_READ, cb, NULL);
2.3. Overrideable allocation functions
If you want to override the allocation functions used by libevent
(for example, to use a specialized allocator, or debug memory
issues, or so on), you can replace them by calling
event_set_mem_functions. It takes replacements for malloc(),
free(), and realloc().
If you're going to use this facility, you need to call it _before_
Libevent does any memory allocation; otherwise, Libevent may allocate some
memory with malloc(), and free it with the free() function you provide.
You can disable this feature when you are building Libevent by passing
the --disable-malloc-replacement argument to configure.
2.4. Configurable event_base creation
Older versions of Libevent would always got the fastest backend
available, unless you reconfigured their behavior with the environment
variables EVENT_NOSELECT, EVENT_NOPOLL, and so forth. This was annoying
to programmers who wanted to pick a backend explicitly without messing
with the environment.
Also, despite our best efforts, not every backend supports every
operation we might like. Some features (like edge-triggered events, or
working with non-socket file descriptors) only work with some operating
systems' fast backends. Previously, programmers who cared about this
needed to know which backends supported what. This tended to get quite
ungainly.
There is now an API to choose backends, either by name or by feature.
Here is an example:
struct event_config_t *config;
struct event_base *base;
/* Create a new configuration object. */
config = event_config_new();
/* We don't want to use the "select" method. */
event_config_avoid_method(config, "select");
/* We want a method that can work with non-socket file descriptors */
event_config_require_features(config, EV_FEATURE_FDS);
base = event_base_new_with_config(config);
if (!base) {
/* There is no backend method that does what we want. */
exit(1);
}
event_config_free(config);
Supported features are documented i
没有合适的资源?快使用搜索试试~ 我知道了~
使用nmake或vs2008集成环境编译libevent-2.0.11-stable
共297个文件
h:157个
c:69个
obj:21个
5星 · 超过95%的资源 需积分: 12 98 下载量 102 浏览量
2011-05-18
09:19:05
上传
评论
收藏 1.75MB RAR 举报
温馨提示
1.使用VS2008自带nmake编译libevent-2.0.11-stable (1)修改event_iocp.c、evthread_win32.c、listener.c三个文件,在文件开头分别加上一行: #define _WIN32_WINNT 0x0500 (2)打开Visual Studio 2008 命令提示 (3)切换到libevent-2.0.11-stable目录 (4)执行nmake /f Makefile.nmake 2.直接使用我已经建立好在VS2008下的编译工程,如果不熟悉上面的nmake编译方法, 直接编译libevent-2.0.11工程即可生成这个三个库文件。Debug和Release版本都有效。 以上两种编译方法都会将三个文件libevent_core.lib、libevent_extras.lib和libevent.lib 生成到lib目录下。 如果有问题联系FLxyzsby@163.com
资源推荐
资源详情
资源评论
收起资源包目录
使用nmake或vs2008集成环境编译libevent-2.0.11-stable (297个子文件)
Makefile.am 7KB
Makefile.am 3KB
Makefile.am 1KB
Makefile.am 648B
libevent-2.0.11.aps 33KB
evdns.c 121KB
http.c 107KB
regress_http.c 93KB
event.c 70KB
buffer.c 69KB
evutil.c 57KB
regress.c 50KB
regress_dns.c 48KB
regress_buffer.c 44KB
bufferevent_openssl.c 34KB
evrpc.c 29KB
regress_util.c 27KB
regress.gen.c 27KB
bufferevent_ratelim.c 26KB
regress_bufferevent.c 22KB
bufferevent.c 22KB
listener.c 20KB
regress_rpc.c 19KB
evmap.c 19KB
bufferevent_async.c 17KB
bufferevent_sock.c 17KB
bufferevent_filter.c 15KB
event_tagging.c 14KB
epoll.c 13KB
regress_thread.c 13KB
regress_ssl.c 12KB
arc4random.c 12KB
test-ratelim.c 12KB
evport.c 12KB
signal.c 12KB
kqueue.c 10KB
win32select.c 10KB
regress_main.c 10KB
http-server.c 10KB
tinytest.c 10KB
regress_iocp.c 9KB
evthread.c 9KB
bufferevent_pair.c 9KB
buffer_iocp.c 8KB
evthread_win32.c 8KB
select.c 8KB
regress_zlib.c 8KB
poll.c 8KB
devpoll.c 8KB
event_iocp.c 7KB
le-proxy.c 7KB
regress_listener.c 6KB
dns-example.c 6KB
bench_httpclient.c 6KB
regress_et.c 5KB
regress_testutils.c 5KB
log.c 5KB
evthread_pthread.c 5KB
bench.c 5KB
bench_http.c 4KB
test-changelist.c 4KB
bench_cascade.c 4KB
evutil_rand.c 4KB
hello-world.c 3KB
regress_minheap.c 3KB
event-test.c 3KB
strlcpy.c 2KB
time-test.c 2KB
epoll_sub.c 2KB
test-eof.c 2KB
test-weof.c 2KB
test-time.c 1KB
signal-test.c 1KB
test-init.c 723B
ChangeLog 71KB
configure 460KB
depcomp 18KB
Doxyfile 10KB
regress.exe 791KB
test-changelist.exe 146KB
test-eof.exe 145KB
test-weof.exe 145KB
test-init.exe 145KB
test-time.exe 145KB
config.guess 44KB
safestack.h 173KB
obj_mac.h 129KB
ssl.h 91KB
asn1.h 51KB
evp.h 48KB
tree.h 44KB
tree.h 44KB
x509.h 43KB
ec.h 43KB
engine.h 39KB
objects.h 36KB
bn.h 34KB
x509v3.h 32KB
http.h 31KB
ts.h 30KB
共 297 条
- 1
- 2
- 3
FLxyzsby
- 粉丝: 38
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页