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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Hexagen: True coroutines for Swift

47 点作者 glittershark大约 10 年前

2 条评论

Sidnicious大约 10 年前
Wouldn&#x27;t it be possible to implement all of the same semantics in pure Swift using a concurrent dispatch queue and some semaphores? I tried making a generator like the one in Hexagen:<p><a href="https://gist.github.com/Sidnicious/8e57892b14629c5ec740" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;Sidnicious&#x2F;8e57892b14629c5ec740</a><p>I understand the main benefits of coroutines as:<p>- Cheap creation<p>- Cheap context switching<p>- Predictable context switching<p>…and I don&#x27;t know the performance characteristics of Grand Central Dispatch. Could someone who&#x27;s more familiar with GCD explain why using it for this kind of concurrency is an okay&#x2F;bad idea and how it compares to coroutines?<p>(FWIW I&#x27;m a huge fan of hacking async semantics into languages and made a thing like this for C++: <a href="https://github.com/Sidnicious/team" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Sidnicious&#x2F;team</a>)
评论 #9188628 未加载
puls大约 10 年前
Previously on HN: <a href="https://news.ycombinator.com/item?id=9132385" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9132385</a>