diff options
| author | Graydon Hoare <[email protected]> | 2010-06-23 21:03:09 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-06-23 21:03:09 -0700 |
| commit | d6b7c96c3eb29b9244ece0c046d3f372ff432d04 (patch) | |
| tree | b425187e232966063ffc2f0d14c04a55d8f004ef /src/test/run-pass/obj-dtor.rs | |
| parent | Initial git commit. (diff) | |
| download | rust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.tar.xz rust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.zip | |
Populate tree.
Diffstat (limited to 'src/test/run-pass/obj-dtor.rs')
| -rw-r--r-- | src/test/run-pass/obj-dtor.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/run-pass/obj-dtor.rs b/src/test/run-pass/obj-dtor.rs new file mode 100644 index 00000000..8b79047b --- /dev/null +++ b/src/test/run-pass/obj-dtor.rs @@ -0,0 +1,33 @@ +obj worker(chan[int] c) { + drop { + log "in dtor"; + c <| 10; + } +} + +io fn do_work(chan[int] c) { + log "in child task"; + { + let worker w = worker(c); + log "constructed worker"; + } + log "destructed worker"; + while(true) { + // Deadlock-condition not handled properly yet, need to avoid + // exiting the child early. + c <| 11; + yield; + } +} + +io fn main() { + let port[int] p = port(); + log "spawning worker"; + auto w = spawn do_work(chan(p)); + let int i; + log "parent waiting for shutdown"; + i <- p; + log "received int"; + check (i == 10); + log "int is OK, child-dtor ran as expected"; +}
\ No newline at end of file |