跳到主内容
paste
bin
.ca
type · paste · share
⌘
K
文档
登录
?
← 返回文本
›
编辑 / 分支
无标题文本
#9NzSPMQ6dX
public / public
新版本
由 @slepp
已创建 2 days ago
永不过期
1.3 KB
语法:
hew
你的更改会创建一个链接到此文本的新文本 — 原始文本不变。
新版本
你的更改会创建一个链接到此文本的新文本 — 原始文本不变。
标题(可选)
文件名
语法
hew
text
bash
c
cpp
css
diff
dockerfile
go
html
ini
java
javascript
json
kotlin
lua
makefile
markdown
nginx
php
python
ruby
rust
shellscript
sql
swift
toml
typescript
xml
yaml
可见性
公开动态
访问
public
过期
7 天
10 分钟
1 小时
1 天
7 天
30 天
90 天
自定义…
自定义过期
变更备注
(可选)
此文本会显示在公开动态中。如果只想通过链接分享,请更改可见性。
创建新版本
取消
粘贴或输入…
// Structured concurrency in Hew: a scope owns its child tasks and joins them // all before the scope expression returns. Tasks are forked with `fork { ... }` // and run on real OS threads; the enclosing `scope { }` is the join boundary. // // Constraints in this build: spawning happens inside an actor handler (which // carries the execution context); each forked function is a zero-argument, // unit-returning free function. Nested scopes compose, and an empty // `after(d) {}` arms a cancellation deadline on the surrounding scope. fn fetch_orders() { println("fetched orders"); } fn fetch_inventory() { println("fetched inventory"); } fn settle() { println("reconciled"); } actor _Pipeline { receive fn run() -> i64 { // Outer scope: two siblings fork concurrently and BOTH join here. scope { after(5s) {} fork { fetch_orders(); } fork { fetch_inventory(); } // Nested scope: its own child joins before the outer scope drains. scope { fork { settle(); } }; }; 0 } } fn main() -> i64 { let p = spawn _Pipeline; match await p.run() { Ok(code) => code, Err(_e) => 1, } }