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)
print(recv(ch))

Semantics

Backend support

Concurrency is part of the runtime contract, not a Go-host-only experiment. It runs through the Go bytecode VM, the Go native backend, the self-hosted VM, and the self-hosted native backend on that backend’s supported targets.

The native runtimes also park tasks around blocking system calls such as read, write, accept, connect, recvfrom, sendto, and nanosleep, so one blocked task does not stop the whole process.

See docs/Specification.md for the full contract.

Next steps