aboutsummaryrefslogtreecommitdiff
path: root/src/test/run-pass/obj-dtor.rs
blob: 616278279dfaed0a6bc722b95372fb34ed416b07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// xfail-stage0
// xfail-stage1
// xfail-stage2
obj worker(chan[int] c) {
  drop {
    log "in dtor";
    c <| 10;
  }
}

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;
  }
}

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";
  assert (i == 10);
  log "int is OK, child-dtor ran as expected";
}