Cooperative concurrency
mu ships with deterministic, cooperative tasks and channels.
Tasks and channels
fn worker(out, n) {
i := 1
total := 0
while i <= n {
total = total + i
i = i + 1
}
send(out, total)
}
ch := chan()
task(worker, ch, 10)
println(recv(ch))
Semantics
- Tasks yield at blocking operations (
send,recv,wait,sleep, I/O). - FIFO scheduling keeps execution deterministic.
- Channels support buffered and unbuffered modes.
pollandpushprovide non-blocking operations.
See docs/Specification.md for the full contract.
Next steps
- Learn the execution model in the runtime guide.
- Explore core syntax in the language tour.
- See the standard library for task and channel helpers.