TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

C++ Coroutine Theory (2017)

190 点作者 squiguy7超过 7 年前

7 条评论

pokoleo超过 7 年前
Waterloo&#x27;s CS 343 (concurrency) course uses coroutines as a stepping block towards understanding concurrent programming.<p>Notes from the course are fantastic, coroutines start here: <a href="https:&#x2F;&#x2F;www.student.cs.uwaterloo.ca&#x2F;~cs343&#x2F;documents&#x2F;notes.pdf#page=33" rel="nofollow">https:&#x2F;&#x2F;www.student.cs.uwaterloo.ca&#x2F;~cs343&#x2F;documents&#x2F;notes.p...</a>
评论 #16320317 未加载
psyc超过 7 年前
Do C++ coroutines give you a sane call stack when chained? I’ve only worked with proprietary implementations that do not, and it is an utter catastrophe for maintenance once they have infested a large code base.
评论 #16318535 未加载
评论 #16320901 未加载
评论 #16318533 未加载
评论 #16318746 未加载
评论 #16318485 未加载
KeepFlying超过 7 年前
Dumb question, but is this something that a dev would expect the compiler to do for us automatically depending on what is deemed most efficient or is this something that a developer can write directly into the code to make it work this way?<p>I want to be sure I understand what is going on here to be sure.<p>Can someone offer an example of where this ability would be particularly useful?
评论 #16319175 未加载
评论 #16318752 未加载
评论 #16326791 未加载
RajuVarghese超过 7 年前
Modula-2, one of the early languages with coroutines, had a pretty simple implementation. With NEWCOROUTINE a new coroutine was created (including the heap memory that would function as a workspace for that coroutine), TRANSFER to transfer control from one coroutine to another and IOTRANSFER to do the same but for interrupts. With these one could design a scheduler and off you went!<p>I had built a coroutine system for a Pascal environment by implementing NEWCOROUTINE and TRANSFER. Both turned out to be pretty simple in assembly language. The workspace contained an area for the CPU registers and the stack. So TRANSFER involved saving the registers of one coroutine in the workspace and restoring the registers from the second.
steveklabnik超过 7 年前
The visualization here is excellent; exactly the kind of thing I&#x27;ve been meaning to look up.
eptcyka超过 7 年前
Seems like this would be more like tokio for Rust rather than Go&#x27;s goroutines.
评论 #16319143 未加载
jnordwick超过 7 年前
Does anybody know if there has been some research and experimentation with inlining? It is probably the most important part of an optimizing compiler, and coroutines would seem to make that very difficult or impossible.
评论 #16323445 未加载