メインコンテンツへスキップ
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, } }