diff options
Diffstat (limited to 'tests/actor/accept')
| -rw-r--r-- | tests/actor/accept/drop_closes.zc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/actor/accept/drop_closes.zc b/tests/actor/accept/drop_closes.zc new file mode 100644 index 0000000..08fd02c --- /dev/null +++ b/tests/actor/accept/drop_closes.zc @@ -0,0 +1,25 @@ +// destructors: an actor's drop waits for the replies its receiver is owed, then closes the endpoint, so the worker is gone when the owner's block ends; a struct that declares its own drop keeps it +namespace; +include rt, actor; +actor Echo { int total; int handle(int x) { return x; } } +int closed; +actor Mine { int total; int handle(int x) { return x; } void drop() { closed++; } } +fn main() { + int before = rt.syscall(55, 0, 0, 0); + { + Echo* e = rt.new(Echo); + e.spawn(); + rt.put_n(rt.syscall(55, 0, 0, 0) - before); rt.put_c(32); + } + rt.put_n(rt.syscall(55, 0, 0, 0) - before); rt.put_c(32); + let total = 0; + { + Echo* f = rt.new(Echo); + f.spawn(); f.recv(fn(int n) { total += n; return 0; }); f.send(5); f.send(6); + } + rt.put_n(total); rt.put_c(32); + rt.put_n(rt.syscall(55, 0, 0, 0) - before); rt.put_c(32); + { Mine* m = rt.new(Mine); } + rt.put_n(closed); rt.put_c(10); + return 0; +} |
