-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
协程的一些想法 #124
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
无栈协程的方案之一 -- 达夫设备 ( 从语言的角度来看 )
前置的一些文章 ( 建议看一下 )
深入理解达夫设备
Coroutines in C
达夫设备的出现是个十分偶然的"故事",但是这个"故事"却比较好的给出了一个在栈中捕获状态机的方案, 即无栈协程的方案: 在栈中利用
switch
(in C++),loop
(Rust) . 前者Boost(v1.66)已经有相关的设计实现,其源码在boost/asio/coroutine.hpp
和boost/asio/yield.hpp
,中, 后者则是自己偶然的一个Rust尝试,见如下代码:协程是为了更好复用线程资源.对于有栈线程,代码工作者,往往需要自行设计合适的异步结构,同步结构的存储队列,唤醒机构和执行机构,工作的难度主要也来自前述的四个方面,需要应对不同的现实环境组织四个方面的"交互".而无栈的协程,从代码上看,虽然没有有栈的复杂,但也需要控制好相应的状态转换,无栈的方案(达夫设备)依赖语言设计者或无意或有意留下的"语言缺口".
The text was updated successfully, but these errors were encountered: