saltar al contenido principal
paste
bin
.ca
type · paste · share
⌘
K
Docs
Iniciar sesión
?
← volver a la publicación
›
Editar / bifurcar
Publicación sin título
#9NzSPMQ6dX
public / public
nueva versión
por @slepp
creado 2 days ago
sin caducidad
1.3 KB
sintaxis:
hew
Tus cambios crean una nueva publicación enlazada a esta — la original no se toca.
nueva versión
Tus cambios crean una nueva publicación enlazada a esta — la original no se toca.
Título (opcional)
Nombre de archivo
Sintaxis
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
Visibilidad
Feed público
Acceso
public
Caduca
7 días
10 min
1 hora
1 día
7 días
30 días
90 días
personalizada…
Caducidad personalizada
Nota de cambio
(opcional)
Esta publicación aparecerá en el feed público. Cambia Visibilidad si solo quieres compartirla por enlace.
Crear nueva versión
Cancelar
Pegar o escribir…
// 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, } }