#define evtimer_new(b, cb, arg)        event_new((b), -1, 0, (cb), (arg))
#include <cstdio>
#include <errno.h>
#include <sys/types.h>
#include <event.h>
#include <event2/event.h>
#include <event2/event_struct.h>
#include <event2/event-config.h>
#include <event2/util.h> void do_timeout(evutil_socket_t fd, short event, void *arg)
{
printf("do timeout (time: %ld)!\n", time(NULL));
} void create_timeout_event(struct event_base *base)
{
struct event *ev;
struct timeval timeout;
  
//将事件和event_base绑定
ev = event_new(base, -1, EV_PERSIST, do_timeout, NULL);
if (ev) {
timeout.tv_sec = 5;
timeout.tv_usec = 0;
event_add(ev, &timeout);
}
} int
main(int argc, char **argv)
{
struct event_base *base; base = event_base_new(); if (!base) {
printf("Error: Create an event base error!\n");
return -1;
} create_timeout_event(base);
event_base_dispatch(base); return (0);
}

最新文章

  1. SignalR入门之Hub
  2. Authcode()
  3. Sublime Text 3 个人开发习惯
  4. 利用Aspose.Pdf将扫描的电子书修改为适合在kindle上查看
  5. 数据结构算法C语言实现(八)--- 3.2栈的应用举例:迷宫求解与表达式求值
  6. mysql 关于日期时间的字段类型
  7. VS在Release模式下,难道还可以Debug?
  8. C/C++常用算法【C语言顺序查找(随机数)】【1】
  9. android 休眠唤醒机制分析(一) — wake_lock
  10. Vim 命令 【转】
  11. 201521123024《Java程序设计》第7周学习总结
  12. 后台模拟请求 HttpHelper 序列化 MD5 时间戳
  13. Java学习笔记(四)——好记性不如烂键盘(答答租车)
  14. [转帖]关于网络编程中MTU、TCP、UDP优化配置的一些总结
  15. oftype 指的是集合的类型
  16. Atitit &#160;技术经理职责与流程表总结
  17. LoadRunner录制脚本-基础
  18. js判断checkbox是否选中
  19. Java-JUC(六):创建线程的4种方式
  20. 五毛党可能要失业了,因为AI水军来了

热门文章

  1. ActiveMQ JMX使用
  2. jvm对象内存分配
  3. 三段式有限状态机Verilog代码
  4. Spring 梳理-Spring配置文件 -&lt;context:annotation-config/&gt;和&lt;context:component-scan base-package=&quot;&quot;/&gt;和&lt;mvc:annotation-driven /&gt; 的区别
  5. Android测试环境配置
  6. thymeleaf 语法
  7. iSCSI 网关管理 - Storage6
  8. Python爬虫(二):Requests库
  9. 夯实Java基础系列17:一文搞懂Java多线程使用方式、实现原理以及常见面试题
  10. 文本数据IO操作--字符流