lxdlam 最近的时间轴更新
lxdlam's repos on GitHub
CSS · 2 人关注
hitwh-2018-newbie
HIT@WH 2018 Newbie Contest Materials
HTML · 2 人关注
lxdlam.github.io
C++ · 1 人关注
CP-Answers
My own competitive programming answers
1 人关注
kilo-tutorial
build your own text editor
HTML · 0 人关注
attractors
prototypin' shtuff
C++ · 0 人关注
banshao
WIP
Python · 0 人关注
BigBedBot
hmmm
C · 0 人关注
BuildLisp
A Lisp implemention based on http://buildyourownlisp.com/contents
0 人关注
cf-tool
:bar_chart: Codeforces Tool (Submit, Parse, Test, Watch, Pull, etc.). Provide executable files (Win, macOS, Linux, about 6 MB).
JavaScript · 0 人关注
cheerio
Fast, flexible, and lean implementation of core jQuery designed specifically for the server.
0 人关注
chinese-independent-blogs
中文独立博客列表
JavaScript · 0 人关注
crowds
The Wisdom and/or Madness of the Crowds
0 人关注
dot-files
My own dot configs
0 人关注
dotfiles
0 人关注
elixir-lang.github.com
Website for Elixir
C++ · 0 人关注
GAC
Implement algorithms in "GrokkingAlgorithms" using C++ \ 《算法图解》C++实现
0 人关注
GitLearnInPractice
qwe
0 人关注
go
The Go programming language
0 人关注
goenums
Type Safe Enum generator for Go
0 人关注
gol-rust
A Conway's Game of Life implementation in vanilla Rust
JavaScript · 0 人关注
hackergame2021-writeups
中国科学技术大学第八届信息安全大赛的官方与非官方题解
0 人关注
hackergame2022-writeups
中国科学技术大学第九届信息安全大赛的官方与非官方题解
CSS · 0 人关注
hugo-theme-even
🚀 A super concise theme for Hugo https://blog.olowolo.com/example-site/
C · 0 人关注
Judger
Online judge sandbox based on seccomp | 需要Java JNI和php C extension集成,欢迎contribute
Python · 0 人关注
JudgeServer
Python · 0 人关注
langmanus
A community-driven AI automation framework that builds upon the incredible work of the open source community. Our goal is to combine language models with specialized tools for tasks like web search, crawling, and Python code execution, while giving back to the community that made this possible.
Vue · 0 人关注
lightblog
Python · 0 人关注
LPTHW
the answers and exercises of Learn Python the HARD WAY, based on the THIRD EDITION of chinese.
0 人关注
lxdlam
Self-introduction
lxdlam

lxdlam

Stay hungry, stay foolish
V2EX 第 91515 号会员,加入于 2015-01-13 12:44:59 +08:00
今日活跃度排名 15718
根据 lxdlam 的设置,主题列表被隐藏
二手交易 相关的信息,包括已关闭的交易,不会被隐藏
lxdlam 最近回复了
37 天前
回复了 HikariLan 创建的主题 Linux 从进程到协程:计算机的并发编程之路
async/await 真正的含义并不是“显式切换上下文”,如此说来为何 goroutine 也需要 "go func()" 才能启动并发调度?这难道不是一种类似于 "yield something" 的显式切换上下文吗?

从 Delimited Continuation 的角度说,async/await 是 F#/C# 发明出来用来模仿 Delimited Continuation 的 shift/reset, prompt/control 算子的,这一定程度上解释了函数染色问题从何而来:我们需要显式标记哪些部分能够被编译期改写,这样才能准确地把 k : Continuation 传到这些部分。与之相对的是 Scheme 的 continuation ,任何 continuation 都是无界的,也就是说会捕获到整个 runtime ,这对一个**后续接入** continuation 的语言实现有巨大的 breaking change (在 chez 中执行 `(call/cc (lambda (cc) (cc cc)))`,你会得到 `#<system continuation in new-cafe>`)。

而这样说有一些吊书袋,我们不妨简单思考一下所谓的 coroutine 是怎么编译的?

当我们遇到一个类似于如下的代码

```
let coro = async { time.sleep(5000) }

// some busywork

await coro
```
时,我们单纯从语法考虑,我们如何将 coro 正确编译成我们想要的结构呢?我们自然能想到很多种做法,至少我们可以为 coro 创建一个简单的 reference object ,去轮询来看它是否完成,并把 await 自动重写成 while not coro.ref.isFinished() {} 的一个 busyloop 就可以了(对于有栈来说可以是用户态的 uthread.join(),对于无栈来说可以是 state in [Done, Exception])。

所以,本质来说,async/await 是定界,界定了到底哪些代码需要被识别成一个 remote track 的对象,并正确插入调度代码。

这个的后续遗留了更多好玩的问题,感兴趣的朋友可以从这些起点思考:
1. 根据前文描述,"go func()" 某种程度也是定界,那跟 async/await 的核心区别是什么?这将为你导向有栈和无栈最核心的区别,究竟“栈”如何让 goroutine 不需要考虑函数染色问题?
2. 如何实现一个可用级别的编译器,编译我们的协程?他们的底层模型其实很相似,但是要搞懂无栈协程的编译难度比较大,你可能需要真的理解 continuation 和 cps conversion 才能明白看似简单的东西背后有多少篇 paper 和大佬支撑。
52 天前
回复了 lxdlam 创建的主题 职场话题 关于捐赠“抵扣”个税的经济账
@ltyj2003 是的,这个应该是主要动机。
在 GF(2) 域上解线性方程组。
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1535 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 16:57 · PVG 00:57 · LAX 09:57 · JFK 12:57
Developed with CodeLauncher
♥ Do have faith in what you're doing.