blob: aa09ce1e597f1b52b5dd93ba84fe5069880260d8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
|
namespace;
include rt, actor;
typecheck on;
int work(int n) { rt.syscall(48, 500, 0, 0); return n + 1; }
fn main() {
let n = 10, i = 0, sum = 0;
actor.Actor<int, int>*[101] as;
while (i < n) { as[i] = rt.new(actor.Actor<int, int>); as[i].spawn(work); as[i].recv(fn(int v) { sum = sum + v; return 0; }); as[i].send(i); i++; }
i = 0; while (i < n) { as[i].await(); as[i].close(); i++; }
rt.put_n(sum); rt.put_c(10); return 0;
}
|