Rust tasks do not support being killed at arbitrary points. You'll have to arrange ahead of time for a "please die" message to be sent a long a channel, or a similar scheme for transmitting this information.
On Wed, Jun 4, 2014 at 9:33 AM, Aravinda VK <hallimanearav...@gmail.com> wrote: > Hi, > > I am trying different alternative to kill a task from parent, But I didn't > get any ways to kill a task from its parent. > > In the following approach I started worker2 inside worker1 and worker1 from > main. After 1000 miliseconds worker1 dies, but worker2 still continues. > > use std::io::timer::sleep; > > fn worker1(){ > spawn(proc() { > worker2(); > }); > println!("worker 1"); > sleep(1000); > fail!("I am done"); > } > > fn worker2(){ > loop{ > println!("worker 2"); > } > } > > fn main(){ > spawn(proc() { > worker1(); > }); > } > Any suggestions? > > -- > Regards > Aravinda | ಅರವಿಂದ > http://aravindavk.in > > _______________________________________________ > Rust-dev mailing list > Rust-dev@mozilla.org > https://mail.mozilla.org/listinfo/rust-dev > _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev