aboutsummaryrefslogtreecommitdiff
path: root/tests/actor/accept/declaration.zc
blob: 099c0eba68300b2d09c69425a2dfc24ed7221583 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
namespace;
include rt, actor;
typecheck on;
actor Counter { int total; int handle(int value) { this.total += value; return this.total; } }
fn main() {
 Counter* a = rt.new(Counter), b = rt.new(Counter); let left = 0, right = 0;
 a.spawn(); b.spawn(); a.recv(fn(int n) { left = n; return 0; }); b.recv(fn(int n) { right = n; return 0; });
 a.send(2); a.send(3); b.send(7); a.await(); b.await();
 rt.put_n(left); rt.put_c(' '); rt.put_n(right); rt.put_c(' '); rt.put_n(a.total); rt.put_c(' '); rt.put_n(b.total); rt.put_c(10);
 a.close(); b.close(); return 0;
}