libevent读书笔记
来源:互联网 发布:无限极会员展示php 编辑:程序博客网 时间:2024/06/05 10:15
1.libevent使用回调可以让用户自定义log和内存分配,回调的威力
2.libevent的替换内存分配过程中使用了一个union,赶脚很霸气
/* This union's purpose is to be as big as the largest of all the * types it contains. */union alignment { size_t sz; void *ptr; double dbl;};/* We need to make sure that everything we return is on the right alignment to hold anything, including a double. */#define ALIGNMENT sizeof(union alignment)注释写的很明显了。
3.调试锁 (Debugging lock usage)
实在没有想到会有这样的方法,值得借鉴。可检测出来的问题包括:
(1)unlocking a lock that we don’t actually hold
(2)re-locking a non-recursive lock
方法:
void evthread_enable_lock_debugging(void);
#define evthread_enable_lock_debuging() evthread_enable_lock_debugging()
note :This function MUST be called before any locks are created or used. To be safe, call it just after you set your threading functions
有意思的是这个evthread_enable_lock_debuging()在之前的版本是有个拼写错误的:P
看了看内容发现自己功力不够 :( 读不懂... ...5555555,果断跳过。
4.调试事件(Debugging event usage)
(1)Treating an uninitialized struct event as though it were initialized.
(2)Try to reinitialize a pending struct event.
由于是要花费额外的内存和cpu,所以就是为了排错才会用到专门的调试函数
void event_enable_debug_mode(void);
This function must only be called before any event_base is created.
- libevent读书笔记
- libevent 读书笔记
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- libevent
- python中List的sort方法(或者sorted内建函数)的用法
- requestDisallowInterceptTouchEvent
- Win32消息检索
- gen 文件夹报错解决方法
- JS中数组Array的用法
- libevent读书笔记
- artDialog
- An existing PostgreSql installation has been found... 的解决
- lambada学习
- 消息的概念
- ZZY的宠物解题报告
- 定时器TIMER
- IOS开发之—绘图 CGContext
- Java 位运算(移位、位与、或、异或、非) -- Demo