libev笔记
static void stdin_readable_cb (struct ev_loop *loop, ev_io *w, int revents) { ev_io_stop (loop, w); .. read from stdin here (or from w->fd) and handle any I/O errors } ... struct ev_loop *loop = ev_default_init (0); ev_io stdin_readable; ev_io_init (&stdin_readable, stdin_readable_cb, STDIN_FILENO, EV_READ); ev_io_start (loop, &stdin_readable); ev_run (loop, 0);
ev_timer
static void one_minute_cb (struct ev_loop *loop, ev_timer *w, int revents) { .. one minute over, w is actually stopped right here } ev_timer mytimer; ev_timer_init (&mytimer, one_minute_cb, 60., 0.); ev_timer_start (loop, &mytimer);
static void timeout_cb (struct ev_loop *loop, ev_timer *w, int revents) { .. ten seconds without any activity } ev_timer mytimer; ev_timer_init (&mytimer, timeout_cb, 0., 10.); /* note, only repeat used */ ev_timer_again (&mytimer); /* start timer */ ev_run (loop, 0); // and in some piece of code that gets executed on any "activity": // reset the timeout to start ticking again at 10 seconds ev_timer_again (&mytimer);
ev_signal
static void sigint_cb (struct ev_loop *loop, ev_signal *w, int revents) { ev_break (loop, EVBREAK_ALL); } ev_signal signal_watcher; ev_signal_init (&signal_watcher, sigint_cb, SIGINT); ev_signal_start (loop, &signal_watcher);
关键代码分析
libev笔记的更多相关文章
- libev事件库学习笔记
一.libev库的安装 因为个人的学习环境是在ubuntu 12.04上进行的,所以本节仅介绍该OS下的安装步骤. 使用系统工具自动化安装: sudo apt-get install libev-de ...
- Libev学习笔记4
这一节首先分析Libev的定时器部分,然后分析signal部分. 对定时器的使用主要有两个函数: ev_timer_init (&timeout_watcher, timeout_cb, .) ...
- Libev学习笔记3
设置完需要监听的事件之后,就开始event loop了.在Libev中,该工作由ev_run函数完成.它的大致流程如下: int ev_run (EV_P_ int flags) { do { /* ...
- Libev学习笔记2
这一节根据官方文档给出的简单示例,深入代码内部,了解其实现机制.示例代码如下: int main (void) { struct ev_loop *loop = EV_DEFAULT; ev_io_i ...
- Libev学习笔记1
和Libevent相似,Libev是一个高性事件驱动框架,据说性能比Libevent要高,bug比Libevent要少.Libev只是一个事件驱动框架,不是网络库,因为它的内部并没有任何socket编 ...
- libev事件库使用笔记
源码下载地址:http://dist.schmorp.de/libev/ libev是一个高性能的事件循环库,比libevent库的性能要好. 安装: tar -zxf libev-4.15.tar. ...
- libev学习笔记
转 libev的使用--结合Socket编程 作者:cxy450019566 之前自己学过一些libev编程的基础,这次写压测刚好用上了,才算真正动手写了些东西,在这里做一些总结.写这篇文章是为了用浅 ...
- blfs(systemv版本)学习笔记-编译安装i3-wm平铺式窗口管理器
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! i3-wm项目的官网:https://i3wm.org/ 首先需要lfs基础上编译安装完整的xorg服务 我的xorg服务编译安 ...
- libev 学习使用
libev 简单的I/O库. a high performance full featured event loop written in c libev 的大小也比 libevent 小得多并且自 ...
随机推荐
- 【英语】Bingo口语笔记(1) - Hold
how are you holding up? 你还撑得住吧?你还好吧?撑住太不容易了吧!
- ios ble 参考
About Core Bluetooth https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Con ...
- mysql 添加索引后 在查询的时候是mysql就自动从索引里面查询了。还是查询的时候有单 独的参数查询索引?
MYSQL在创建索引后对索引的使用方式分为两种:1 由数据库的查询优化器自动判断是否使用索引:2 用户可在写SQL语句时强制使用索引 下面就两种索引使用方式进行说明第一种,自动使用索引.数据库在收到查 ...
- Arduino开发常见错误
使用Ethernet时需要指定访问服务器的ip,我用的是本机做服务器.但是有一天重启了路由器,ip地址就变了!程序得跟着改! Arduino突然烧写不了程序:可能是正在运行的程序让arduino死机了 ...
- 纠结的ARC
xcode不断进步,在xcode4中引入了ARC的概念.您用或者不用它就在那里,于是有了本文:如何在未使用arc的工程中引入一个使用了arc特性的文件,如何在arc工程中引用未使用arc的文件.其实说 ...
- 解决 winform 界面对不齐 z
一个winform的程序,本机上界面对得很齐,到一到客户的机器上就惨不忍睹,一番研究后搞定: 1. AutoScaleMode = None 2. BackgroundImageLayout = No ...
- python+selenium环境搭建
这里主要基于windows平台. 下载python.http://python.org/getit/ 下载setuptools [python的基础包工具].http://pypi.python.or ...
- When not to automate 什么时候不进行自动化
The cornerstone of test automation is the premise that the expected application behavior is known. W ...
- uoj #58. 【WC2013】糖果公园(树上莫队算法+修改操作)
[题目链接] http://uoj.ac/problem/58 [题意] 有一棵树,结点有自己的颜色,若干询问:u,v路径上的获益,并提供修改颜色的操作. 其中获益定义为Vc*W1+Vc*W2+…+V ...
- IOS 异步加载图片
#import <Foundation/Foundation.h> #import "StringUtils.h" @interface ImageManager : ...