libev + libevent1.4

libev

libev - a high performance full-featured event loop written in C

 

A full-featured and high-performance (see benchmark) event loop that is loosely modelled after libevent, but without its limitations and bugs. It is used in GNU Virtual Private Ethernet, rxvt-unicode, auditd, the Deliantra MORPG Server and Client, and many other programs.

 

libev tutorial

 

Additional Documents

README

ev.pod

 

http://dist.schmorp.de/libev/

http://dist.schmorp.de/libev/README

 

 

 

 

1.libev 编译安装 (可参考http://www.cnblogs.com/coding-my-life/p/3720619.html)

  1>sh autogen.sh  或./configure 任选一个 

  2>make

  3>sudo make install  成功的话,你可以在/usr/local/lib 找到libev.a  libev.so libev.*等等  /usr/local/include 找到c的ev.h c++版本ev

2.编译demo 

gcc -o libevTest libevTest.c -lev 

注意:没有指定库的路径的话,编译成功,执行会提示 ./libevTest :error while loading shared libraries:libev.so.4 :cannot open shared object file:No such file or directory

所以需要指定些执行的路径 gcc -o libevTest libevTest.c -L/usr/local/lib -lev -Wl,--rpath=/usr/local/lib

makefile 写法 >>gcc -o foo foo.c -L(prefix)/liblfooWl,rpath=(prefix)/lib

 

当然也可以直接把库放在当前目录下(编译就是这样的>> gcc -o libevTest libevTest.c -L. -lev -Wl,--rpath=.)

 

=======================

其他帖子

使用 libevent 和 libev 提高网络应用性能

事件库之Libev(一)

事件库之Libev(二)

事件库之Libev(三)

事件库之Libev(四)

事件库之Libev(五)

 

https://stacklet.com/

 

 

http://www.cnblogs.com/lexus/archive/2011/11/12/2246400.html

 

===================

 

 

 

 

libevent

记得我还编译过arm版本的libevent2  是在github上找的(可用于ios/android), 但是libuv原生就支持andriod/ios/mac os/ windows/linux/AIX  etc...

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 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.

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, Libeventallows 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 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.

 

 

 

 

==============

 

 

 

python网络库gevent

作者 评论 libev与libevent1.4的对比

 

gevent   A coroutine-based network library for Python

gevent is a coroutine-based Python networking library that uses greenlet to provide a high-level synchronous API on top of the libev event loop.

gevent程序员指南(中文)

http://xlambda.com/gevent-tutorial/

github

https://github.com/gevent/gevent

http://sdiehl.github.io/gevent-tutorial/

 

 

http://blog.gevent.org/2011/04/28/libev-and-libevent/

上面blog说明了gevent作者当初为什么放弃libevent改用libev,而libevnent-dns各种问题,比如其中gethostbyname就是阻塞的(其实2.0之后就改用了非阻塞的了)

改用 c-ares library (used by curl, among others)

 

 

http://blog.gevent.org/2011/04/28/libev-and-libevent/

时常被墙(国内转载 地址 http://www.cnblogs.com/inteliot/archive/2012/04/17/2454315.html )

 

greenlet implemenation

greenlet是一个python coroutine库, 可以提供比thread更加细粒度的并发控制。由于thread通常是一个内核对象,而coroutine通常只是工作在用户模式下,所以不存在线程切换 时的开销。当使用coroutine和thread来实现并发时,将会得到更大的并发度。因为thread虽然比起process而言已经十分轻量,但是 毕竟还是有开销的,当系统中有太多的thread在运行,也会拖累系统的运行速度,因为操作系统忙于执行context switch。

在python中,我们从thread中说获得并发度要比想象的低很多,因为thread其实不是完全并发执行的,这其中涉及到一个GIL(Global Interpreter Lock)的问题。关于GIL的问题,可以参考Understanding the Python GIL

 

posted @   scott_h  阅读(553)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示