I. Overview
1. Catalogue classification:
- Header files: divided into header files for external use and header files for internal use.
- reactor framework: Including event definition, event monitoring and triggering, and timer functions.
- io multiplexing package: including select, poll, epoll, iocp, kqueue, etc.
- Socket, receiving and sending buffer package: network buffer evbuffer is realized, bufferevent manages socket and network buffer.
- Basic data structure: linked list, minimum heap, red-black tree, hash table, etc.
- dns, http library: based on libevent.
- Other: auxiliary function function, log.
2. Specific file description
1) External header files
Including the discarded header files in the root directory and the new version header files in event2.
2) Internal header files
All internal header files in the root directory, the format is xxx-internal.h.
3) The reactor framework
includes event.c, evmap.c, etc.
4) io multiplexing package
including select.c, win32select.c, poll.c, epoll.c, kqueue.c, devpoll.c, evport.c, signal.c, etc.
5) Socket and buffer package
include buffer.c, bufferevent.c, bufferevent_xxx.c, listener.c, etc.
6) Basic data structure
including compat/sys/queue.h, minheap-internal., WIN32-Code/tree.hh, ht-internal.h, etc.
7) http and dns libraries
including http.c, evrpc.c, evdns.c, etc.
8) Others
including evutil.c, evutil_rand.c, strlcpy.c, log.c, etc.
Second, the detailed directory structure
event.h //包含了主要的头文件,已废弃。新的头文件在event2/event*.h, event2/buffer*.h, event2/bufferevent*.h,
evutil.h //已废弃的头文件,新的头文件在event2/util*.h
evhttp.h //废弃的文件头,新的在event2/http*.h
evdns.h //废弃的文件头,新的头文件在event2/dns*.h
event-internal.h event_base结构体定义,一些常量和配置定义,还有一些函数接口
evmap-internal.h //evmap相关接口声明
evbuffer-internal.h //evbuffer结构体定义和接口声明
bufferevent-internal.h bufferevent相关的结构体定义和接口声明
iocp-internal.h //iocp封装相关的接口声明
evsignal-internal.h //signal相关的接口声明
evthread-internal.h //线程及同步相关的接口声明
changelist-internal.h //event_changelist相关的接口声明
defer-internal.h //延迟回调相关的接口声明
evrpc-internal.h 包含了rpc相关的头文件
http-internal.h //http相关接口声明
ipv6-internal.h //ipv6相关结构体定义
util-internal.h 对一些网络、文件io,时间等的跨平台封装(libevent内部使用的,放这里)
minheap-internal.h 最小堆的实现,用于定时器
ht-internal.h hashtable实现,用于evmap管理event_io_map
strlcpy-internal.h 定义了strlcpy
log-internal.h 日志相关的接口定义
event.c //event、event_base相关函数定义
event_iocp.c //iocp相关函数定义
evmap.c 实现了event_io_map、event_signal_map,元素是evmap_io、evmap_signal,每个evmap_io管理一个fd上监听的事件和回调
select.c 封装POSIX的select
win32select.c 封装Win的select
poll.c 封装poll
epoll.c 封装epoll,在linux、unix下使用
epoll_sub.c 封装了epoll_create, epoll_ctl, epoll_wait接口
kqueue.c 封装kqueue,在Mac OS下使用
devpoll.c 封装了dev/poll,在Solaris下使用
evport.c 封装了evport,在Solaris下使用
signal.c 封装了signal
buffer.c evbuffer网络缓冲区
buffer_iocp.c //evbuffer的iocp相关接口
event_tagging.c //提供了一些往evbuffer里写入和读写基本类型的函数
bufferevent.c //bufferevent包含了evbuffer、bufferevent_ops,定义了一些bufferevent通用方法
bufferevent_filter.c //带filter功能的bufferevent
bufferevent_openssl.c //带openssl加密的bufferevent
bufferevent_pair.c //两个socket的bufferevent
bufferevent_ratelim.c //流量控制算法,采用经典的令牌桶算法
bufferevent_sock.c //socket的bufferevent
bufferevent_async.c //bufferevent的iocp相关接
listener.c //对socket监听相关的操作做了封装
evthread.c //通过设置锁、条件变量的分配、释放、锁、解锁等接口,实现了跨平台的锁和条件变量封装。
evthread_pthread.c //pthread相关的锁、条件变量接口封装,并设置了evthread提供的回调上去。
evthread_win32.c //win32相关的锁、条件变量接口封装,并设置了evthread提供的回调上去。
evutil.c 对一些网络、文件io,时间等的跨平台封装
evutil_rand.c 伪随机数生成算法
strlcpy.c 实现了strlcpy
log.c //实现了不同级别的打印日志接口,可设置日志的回调函数,自定义输出
http.c //实现了http服务
evrpc.c //基于http的rpc实现
evdns.c //实现了dns服务
include
event2
buffer.h //evbuffer相关结构体定义和evbuffer相关接口声明
buffer_compat.h //evbuffer相关的扩展接口声明
bufferevent.h //bufferevent相关接口声明
bufferevent_compat.h //bufferevent的兼容性接口声明
bufferevent_ssl.h //ssl相关的bufferevent接口声明
bufferevent_struct.h //bufferevent结构体声明
event.h //event、event_base相关接口声明
event_compat.h //event、event_base相关的兼容性接口声明
event_struct.h /event结构体定义
http.h //http接口声明
http_compat.h //http兼容性接口声明
http_struct.h //http相关结构体定义
rpc.h //rpc相关的声明
rpc_compat.h //rpc兼容性声明
rpc_struct.h //rpc结构体定义
dns.h //dns接口声明
dns_compat.h //dns兼容性接口声明
dns_struct.h //dns相关结构体定义
keyvalq_struct.h
util.h //对一些网络、文件io,时间等的跨平台封装(libevent内部使用的,放这里)
listener.h //evconnlistener相关的接口声明
tag.h //evbuffer里读写基本类型的相关接口声明
tag_compat.h //evbuffer里读写基本类型的兼容性接口声明
thread.h //evthread相关的锁、条件变量接口声明
WIN32-Code
tree.h //红黑树实现
event2
event-config.h //包含一些宏定义,windows下用
compat //为了兼容,定义的类
sys
queue.h //windows下没有<sys/queue.h>,自己定义一个,包含链表,双向链表,队列等定义
sample 使用样例
...
test 测试用例
...