2025-01-23 17:18:15 +08:00
|
|
|
//@ check-pass
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2014-12-14 00:05:32 -08:00
|
|
|
use std::thread::Builder;
|
2014-02-07 20:08:32 +01:00
|
|
|
|
2025-01-23 17:18:15 +08:00
|
|
|
static GENERATIONS: usize = 1024+256+128+49;
|
2012-11-15 12:30:04 -08:00
|
|
|
|
2019-05-28 14:47:21 -04:00
|
|
|
fn spawn(mut f: Box<dyn FnMut() + 'static + Send>) {
|
2025-01-23 17:18:15 +08:00
|
|
|
Builder::new().stack_size(32 * 1024).spawn(move || f());
|
2014-02-21 15:41:51 -08:00
|
|
|
}
|
|
|
|
|
|
2019-05-28 14:47:21 -04:00
|
|
|
fn child_no(x: usize) -> Box<dyn FnMut() + 'static + Send> {
|
2025-01-23 17:18:15 +08:00
|
|
|
Box::new(move || {
|
|
|
|
|
if x < GENERATIONS {
|
2014-02-21 15:41:51 -08:00
|
|
|
spawn(child_no(x+1));
|
2012-11-15 12:30:04 -08:00
|
|
|
}
|
2014-11-26 08:12:18 -05:00
|
|
|
})
|
2012-11-15 12:30:04 -08:00
|
|
|
}
|
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2014-02-21 15:41:51 -08:00
|
|
|
spawn(child_no(0));
|
2012-11-15 12:30:04 -08:00
|
|
|
}
|