- 授权协议: Apache
- 开发语言: C/C++
- 操作系统: Linux
- 软件首页: https://github.com/tencent-wechat/libco
- 软件文档: https://github.com/tencent-wechat/libco
软件介绍
libco 是腾讯开源的一个有趣的协程基础库,仅有的几个函数接口 co_create/co_resume/co_yield 再配合 co_poll, 可以支持同步或者异步的写法,如线程库一样轻松,库里面提供了socket族函数的hook,
包含如下内容:
pthread风格的coroutine接口封装
事件循环以及超时机制
基于glibc-2.17源码修改的一个swapcontext高性能汇编版本
socket函数的coroutine hook,阻塞式的socket调用会直接切换为异步调用
适用场景:已有大量的同步调用网络库,例如HttpGet/Memcache_cli/..., 并基于这些函数实现了大量复杂的业务逻辑,它们跑在多进程或者多线程环境下,希望改造为异步服务
改造方法:在进程/线程内创建多个coroutine( 使用co_create ),每个routine内部enable_sys_hook, 业务逻辑代码移到routine里面执行,那你所有的同步代码立即自动切换为异步调用~
Head First Design Patterns
Elisabeth Freeman、Eric Freeman、Bert Bates、Kathy Sierra、Elisabeth Robson / O'Reilly Media / 2004-11-1 / USD 49.99
You're not alone. At any given moment, somewhere in the world someone struggles with the same software design problems you have. You know you don't want to reinvent the wheel (or worse, a flat tire),......一起来看看 《Head First Design Patterns》 这本书的介绍吧!
