lib事件 --- libevent(https://libevent.org/)
libevent/libevent: Event notification library(https://github.com/libevent/libevent)
The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Furthermore, libevent also support callbacks due to signals or regular timeouts.
libevent API 提供了一种机制,用于在文件描述符上发生特定事件或达到超时后执行回调函数。此外,libevent 还支持由于信号或常规超时而导致的回调。
libevent is meant to replace the event loop found in event driven network servers. An application just needs to call event_dispatch() and then add or remove events dynamically without having to change the event loop.
libEvent 旨在替换事件驱动网络服务器中的事件循环。应用程序只需要调用 event_dispatch(),然后动态添加或删除事件,而无需更改事件循环。
Currently, libevent supports /dev/poll, kqueue(2), event ports, POSIX select(2), Windows select(), poll(2), and epoll(4). The internal event mechanism is completely independent of the exposed event API, and a simple update of libevent can provide new functionality without having to redesign the applications. As a result, Libevent allows for portable application development and provides the most scalable event notification mechanism available on an operating system. Libevent can also be used for multi-threaded applications, either by isolating each event_base so that only a single thread accesses it, or by locked access to a single shared event_base. Libevent should compile on Linux, *BSD, Mac OS X, Solaris, Windows, and more.
目前,libevent 支持 /dev/poll、*kqueue(2)、*事件端口、POSIX select(2)、Windows select()、poll(2) 和 epoll(4)。内部事件机制完全独立于公开的事件 API,并且只需更新 libevent 即可提供新功能,而无需重新设计应用程序。因此,Libevent 允许进行可移植的应用程序开发,并提供操作系统上可用的最具可扩展性的事件通知机制。Libevent 还可用于多线程应用程序,通过隔离每个event_base以便只有一个线程访问它,或者通过锁定对单个共享event_base的访问。Libevent 应该可以在 Linux、*BSD、Mac OS X、Solaris、Windows 等平台上编译。
Libevent additionally provides a sophisticated framework for buffered network IO, with support for sockets, filters, rate-limiting, SSL, zero-copy file transmission, and IOCP. Libevent includes support for several useful protocols, including DNS, HTTP, and a minimal RPC framework.
Libevent 还为缓冲网络 IO 提供了一个复杂的框架,支持套接字、过滤器、速率限制、SSL、零拷贝文件传输和 IOCP。Libevent 包括对多种有用协议的支持,包括 DNS、HTTP 和最小的 RPC 框架。
More information about event notification mechanisms for network servers can be found on Dan Kegel's "The C10K problem" web page.
有关网络服务器事件通知机制的更多信息,请参见 Dan Kegel 的“The C10K problem”网页。
发表评论