Prism’s async model is small on purpose: async fn calls are awaited automatically, and
spawn starts work without blocking. No threads to park, no fork-join ceremony.
async / await
async fn fetch_page(url: str) -> str {
return "content of " + url
}
Calls to an async fn are awaited automatically — no await keyword needed. The compiler
transforms the function into a state machine, so no thread is blocked while waiting.
Multiple calls
Async calls compose inline; each one is awaited in turn:
async fn fetch_page(url: str) -> str {
return "content of " + url
}
fn main() {
let a = fetch_page("https://a.example")
let b = fetch_page("https://b.example")
println(a)
println(b)
}
A structured join() for fan-out is not in v0.1.0.
spawn is fire-and-forget — it starts a function without waiting for it:
async fn background_job() -> int {
return 42
}
fn main() {
spawn background_job()
println("spawned")
}
Cancellation
select and cancellation scopes are not in v0.1.0. The closest pattern is an async call whose
result you check:
async fn compute_intensive() -> int {
return 6 * 7
}
fn main() {
let value = compute_intensive()
println(value)
}
Threads and channels
Channels and spawn_thread are not in v0.1.0. For CPU-bound work, call the async function
directly — it is awaited automatically.
The rules
- No blocking.
spawnstarts a function without blocking;async fncalls are awaited automatically. - No thread blocking in async code. Blocking I/O has its own runtime; an awaited call never parks an OS thread.
- Signals cross boundaries safely. A signal
emitfrom any thread schedules handlers on the right owner thread.
Note: for most programs this is all you need. The standard library also exposes low-level primitives —
Mutex,RwLock, atomics — for the cases where the automatic model does not fit.