一、01_intro.html

Example:A low-level ROT13 server with Libevent

这是一个利用event实现的server实例

Example:A simpler ROT13 server with Libevent

这是一个利用bufferevent实现的server实例

二、Ref0_meta.html

1.libevent设计目标:

Portability(可移植)、Speed(速度)、Scalability(可扩展性)、Convenience(便捷)

2.The bufferevent interface also has multiple backends, so thatit can take advantage of systems that provide faster ways to do nonblocking IO, such as the Windows IOCP API.

三、Ref1_libsetup.html

1.Log message in Libevent

2.Handling fatal errors

3.Memory management

You can have Libevent use another memory manager by providing your own replacements for malloc, realloc, and free.

4.Locks and threading

To get locking in Libevent, you must tell Libevent which locking functions to use. You need to do this before you call any Libevent function that allocates a structure that needs to be shared between threads.If you are using the pthreads library, or the native Windows threading code, you’re in luck. There are pre-defined functions that will set Libevent up to use the right pthreads or Windows functions for you.

四、Ref2_eventbase.html

1.Creating an event_base

If an event_base is set up to use locking, it is safe to access it between multiple threads. Its loop can only be run in a single thread, however. If you want to have multiple threads polling for IO, you need to have an event_base for each thread.

2.Setting up a default event_base

Interface:

struct event_base *event_base_new(void);

3.Setting up a complicated event_base

Interface:

struct event_config *event_config_new(void);
struct event_base *event_base_new_with_config(const struct event_config *cfg);
void event_config_free(struct event_config *cfg);
int event_config_avoid_method(struct event_config *cfg, const char *method);

enum event_method_feature {
    EV_FEATURE_ET = 0x01,
    EV_FEATURE_O1 = 0x02,
    EV_FEATURE_FDS = 0x04,
};
int event_config_require_features(struct event_config *cfg,
                                  enum event_method_feature feature);

enum event_base_config_flag {
    EVENT_BASE_FLAG_NOLOCK = 0x01,
    EVENT_BASE_FLAG_IGNORE_ENV = 0x02,
    EVENT_BASE_FLAG_STARTUP_IOCP = 0x04,
    EVENT_BASE_FLAG_NO_CACHE_TIME = 0x08,
    EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST = 0x10,
    EVENT_BASE_FLAG_PRECISE_TIMER = 0x20
};
int event_config_set_flag(struct event_config *cfg,
    enum event_base_config_flag flag);
int event_config_set_num_cpus_hint(struct event_config *cfg, int cpus)

4.Examining an event_base's backend method

Sometimes you want to see which features are actually available in an event_base, or which method it’s using.

Interface:

const char **event_get_supported_methods(void);
const char *event_base_get_method(const struct event_base *base);
enum event_method_feature event_base_get_features(const struct event_base *base);

5.Deallocating an event_base

Interface:

void event_base_free(struct event_base *base); 

五、Ref3_eventloop.html

1.Running the loop

Interface:

#define EVLOOP_ONCE             0x01
#define EVLOOP_NONBLOCK         0x02
#define EVLOOP_NO_EXIT_ON_EMPTY 0x04

int event_base_loop(struct event_base *base, int flags);
int event_base_dispatch(struct event_base *base);
int event_base_loopexit(struct event_base *base, const struct timeval *tv);
int event_base_loopbreak(struct event_base *base);

2.Checking the internal time cache

Interface:

int event_base_gettimeofday_cached(struct event_base *base,
    struct timeval *tv_out);
int event_base_update_cache_time(struct event_base *base);

3.Running a function over every event in an event_base

Interface:

typedef int (*event_base_foreach_event_cb)(const struct event_base *,
    const struct event *, void *);

int event_base_foreach_event(struct event_base *base,
                             event_base_foreach_event_cb fn,
                             void *arg);

六、Ref4_event.html

Libevent’s basic unit of operation is the event. Every event represents a set of conditions, including:

  • A file descriptor being ready to read from or write to.

  • A file descriptor becoming ready to read from or write to (Edge-triggered IO only).

  • A timeout expiring.

  • A signal occurring.

  • A user-triggered event.

1.Constructing event objects

Interface:

#define EV_TIMEOUT      0x01
#define EV_READ         0x02
#define EV_WRITE        0x04
#define EV_SIGNAL       0x08
#define EV_PERSIST      0x10
#define EV_ET           0x20

typedef void (*event_callback_fn)(evutil_socket_t, short, void *);

struct event *event_new(struct event_base *base, evutil_socket_t fd,
    short what, event_callback_fn cb,
    void *arg);

void event_free(struct event *event);

2.Creating an event as its own callback argument

Interface:

void *event_self_cbarg();

The event_self_cbarg() function returns a "magic" pointer which, when passed as an event callback argument, tells event_new() to create an event receiving itself as its callback argument.

3.Making events pending and non-pending

Interface:

int event_add(struct event *ev, const struct timeval *tv);
int event_del(struct event *ev);

4.Configuring one-off events

If you don’t need to add an event more than once, or delete it once it has been added, and it doesn’t have to be persistent, you can use event_base_once()

Interface:

int event_base_once(struct event_base *, evutil_socket_t, short,
  void (*)(evutil_socket_t, short, void *), void *, const struct timeval *);

5.Manually activating an event

Rarely, you may want to make an event active even though its conditions have not triggered.

Interface:

void event_active(struct event *ev, int what, short ncalls);

七、Ref5_evutil.html

1.Basic types

evutil_socket_t

2.Timer portability functions

3.

libeventReferenceManual阅读笔记的更多相关文章

  1. 阅读笔记 1 火球 UML大战需求分析

    伴随着七天国庆的结束,紧张的学习生活也开始了,首先声明,阅读笔记随着我不断地阅读进度会慢慢更新,而不是一次性的写完,所以会重复的编辑.对于我选的这本   <火球 UML大战需求分析>,首先 ...

  2. [阅读笔记]Software optimization resources

    http://www.agner.org/optimize/#manuals 阅读笔记Optimizing software in C++   7. The efficiency of differe ...

  3. 《uml大战需求分析》阅读笔记05

    <uml大战需求分析>阅读笔记05 这次我主要阅读了这本书的第九十章,通过看这章的知识了解了不少的知识开发某系统的重要前提是:这个系统有谁在用?这些人通过这个系统能做什么事? 一般搞清楚这 ...

  4. <<UML大战需求分析>>阅读笔记(2)

    <<UML大战需求分析>>阅读笔记(2)> 此次读了uml大战需求分析的第三四章,我发现这本书讲的特别的好,由于这学期正在学习设计模式这本书,这本书就讲究对uml图的利用 ...

  5. uml大战需求分析阅读笔记01

    <<UML大战需求分析>>阅读笔记(1) 刚读了uml大战需求分析的第一二章,读了这些内容之后,令我深有感触.以前学习uml这门课的时候,并没有好好学,那时我认为这门课并没有什 ...

  6. Hadoop阅读笔记(七)——代理模式

    关于Hadoop已经小记了六篇,<Hadoop实战>也已经翻完7章.仔细想想,这么好的一个框架,不能只是流于应用层面,跑跑数据排序.单表链接等,想得其精髓,还需深入内部. 按照<Ha ...

  7. Hadoop阅读笔记(六)——洞悉Hadoop序列化机制Writable

    酒,是个好东西,前提要适量.今天参加了公司的年会,主题就是吃.喝.吹,除了那些天生话唠外,大部分人需要加点酒来作催化剂,让一个平时沉默寡言的码农也能成为一个喷子!在大家推杯换盏之际,难免一些画面浮现脑 ...

  8. Hadoop阅读笔记(五)——重返Hadoop目录结构

    常言道:男人是视觉动物.我觉得不完全对,我的理解是范围再扩大点,不管男人女人都是视觉动物.某些场合(比如面试.初次见面等),别人没有那么多的闲暇时间听你诉说过往以塑立一个关于你的完整模型.所以,第一眼 ...

  9. Hadoop阅读笔记(四)——一幅图看透MapReduce机制

    时至今日,已然看到第十章,似乎越是焦躁什么时候能翻完这本圣经的时候也让自己变得更加浮躁,想想后面还有一半的行程没走,我觉得这样“有口无心”的学习方式是不奏效的,或者是收效甚微的.如果有幸能有大牛路过, ...

随机推荐

  1. Nginx负载均衡实践之一:基本实现

    由于现在的网站架构越来越大,基于互联网的用户也是日渐增长,所以传统的单机版服务器已经渐渐不能适应时代发展的需要.最近在和其他企业接触的过程中,发现对于互联网的经验尤为看重,所谓的互联网经验,其实就是指 ...

  2. knockoutJS学习笔记06:ko数组与模板绑定

    前面已经介绍了基本的绑定和模板相关知识,接下来就看ko里的数组和模板绑定,数组和模板绑定应该是实际项目中用得比较多的,ko提供了很好的支持. 一.observaleArray 前面的监控属性都是单个对 ...

  3. 聊聊 Web 项目二维码生成的最佳姿势

    在设计和实现的过程之后,你永远不知道部署上去的程序会已什么样的姿势运行. 本篇借一次生成二维码逻辑的不同实现,阐述 Web 项目中二维码生成的正确姿势. 文中如有批量,欢迎各位看客老爷拍砖.试运行前5 ...

  4. hibernate与ibatis比较

    hibernate 是当前最流行的o/r mapping框架,它出身于sf.net,现在已经成为jboss的一部分了. ibatis 是另外一种优秀的o/r mapping框架,目前属于apache的 ...

  5. Cache,MemCache,Application,Cookie等其它缓存汇总

    为了提高网页运行速度我们用到了各种缓存技术,今天就来汇总下,相信聪明的你也一定会有所收获的o(^▽^)o 1.Cache(PS:看见一个博客介绍的不错,我就直接Copy了) Cache 即高速缓存.那 ...

  6. MySQL架构优化实战系列1:数据类型与索引调优全解析

    一.数据类型优化 数据类型 整数   数字类型:整数和实数 tinyint(8).smallint(16).mediuint(24).int(32).bigint(64) 数字表示对应最大存储位数,如 ...

  7. 链队列java实现

    public class LinkHeap<T> { class Node<T> { T data; Node<T> next; Node(T data) { th ...

  8. TortoiseGit的使用教程(转)

    1.windows安装TortoiseGit详细使用教程[基础篇] http://www.mamicode.com/info-detail-423481.html 2.Windows下Git与Tort ...

  9. Java面试题总结(一)

    Java面试总结 面向对象编程(OOP) Java是一个支持并发.基于类和面向对象的计算机编程语言.下面列出了面向对象软件开发的优点: 代码开发模块化,更易维护和修改. 代码复用. 增强代码的可靠性和 ...

  10. Eclipse使用快捷键代码格式化有时失效解决办法

    今天写代码的时候发现使用快捷键格式化代码没用了. 首先,先看看自己手动格式化是否还行 右键 - Source - Format 结果:正常! 既然手动正常的话那就可能是这个快捷键的热键被占用了,然后我 ...