协程基础库 Libco

码农软件 · 软件分类 · 高性能网络开发库 · 2019-09-01 13:26:55

软件介绍

libco 是腾讯开源的一个有趣的协程基础库,仅有的几个函数接口  co_create/co_resume/co_yield  再配合 co_poll, 可以支持同步或者异步的写法,如线程库一样轻松,库里面提供了socket族函数的hook,

包含如下内容:

  1. pthread风格的coroutine接口封装

  2. 事件循环以及超时机制

  3. 基于glibc-2.17源码修改的一个swapcontext高性能汇编版本

  4. socket函数的coroutine hook,阻塞式的socket调用会直接切换为异步调用

适用场景:已有大量的同步调用网络库,例如HttpGet/Memcache_cli/..., 并基于这些函数实现了大量复杂的业务逻辑,它们跑在多进程或者多线程环境下,希望改造为异步服务

改造方法:在进程/线程内创建多个coroutine( 使用co_create ),每个routine内部enable_sys_hook, 业务逻辑代码移到routine里面执行,那你所有的同步代码立即自动切换为异步调用~

本文地址:https://codercto.com/soft/d/13642.html

Head First Design Patterns

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》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具