c/c++ coroutine

1.实现机制

1.1. switch-case
Protothread
最轻,但受限最大

1.2. setjmp/longjmp
StateThread采用这种方式

1.3. ucontext

1.4. boost::context

针对不同的arch用汇编实现的

http://www.boost.org/doc/libs/1_59_0/libs/context/doc/html/index.html

2.C的coroutine库

Cgreenlet
coroutine
boost.coroutine
Protothreads
orchid
Statethread
Libco
coroutine_event
libconcurrency
setjmp-longjmp-ucontext-snippets
libcilkrts
libgo
libtask

3.cgreenlet

https://github.com/geertj/cgreenlet
cross-platfrm coroutine library for C/C++

cgreenlet introduce
https://github.com/geertj/cgreenlet/blob/master/doc/intro.txt

4.coroutine
https://github.com/cloudwu/coroutine/

5.protothread
http://dunkels.com/adam/pt/

6.coroutine_event
coroutine_event –它基于libevent,提供了基于协程的并发模型
在libevent的基础上提供同步的接口,在获得异步效率的同时提供更方便的编程方式
https://github.com/colaghost/coroutine_event

7.orchid

https://github.com/ioriiod0/orchid
orchid是一个构建于boost库基础上的C++库,为用户提供基于协程的并发模型

8.Libco

libco是一个有趣的协程基础库,仅有的几个函数接口 co_create/co_resume/co_yield 再配合 co_poll,可以支持同步或者异步的写法,如线程库一样轻松,库里面提供了socket族函数的hook,使得后台逻辑服务几乎不用修改逻辑代码就可以完成异步化改造。

http://code.tencent.com/libco.html
https://code.csdn.net/Tencent/libco

9.Statethread

The State Threads Library is a small application library which provides a foundation for writing fast and highly scalable Internet applications (such as web servers, proxy servers, mail transfer agents, and so on, really any network-data-driven application) on UNIX-like platforms. It combines the simplicity of the multithreaded programming paradigm, in which one thread supports each simultaneous connection, with the performance and scalability of an event-driven state machine architecture. In other words, this library offers a threading API for structuring an Internet application as a state machine.

http://state-threads.sourceforge.net/
http://sourceforge.net/projects/state-threads/

10.libconcurrency
https://code.google.com/p/libconcurrency/

11.setjmp-longjmp-ucontext-snippets
https://github.com/danluu/setjmp-longjmp-ucontext-snippets

12.libtask
http://swtch.com/libtask/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值