#![cfg(all(feature = "parallel", feature = "ledger"))]
use std::num::NonZeroUsize;
use threadteam::{Exec, Pool};
#[test]
fn global_pool_is_never_started() {
let nz = NonZeroUsize::MIN;
Exec::serial().fork(4, |_, child| child.for_ranges(8, nz, |_| {}));
Exec::serial().for_ranges(16, nz, |_| {});
Exec::serial().broadcast(|_| {}).unwrap();
let pool = Pool::builder().threads(3).build().unwrap();
assert!(pool.width().get() >= 1);
let mut exec = Exec::new(&pool, 3).unwrap();
exec.reborrow()
.fork(5, |_, child| child.for_ranges(32, nz, |_| {}));
exec.reborrow().for_ranges(100, nz, |_| {});
exec.reborrow().broadcast(|_| {}).unwrap();
exec.reborrow().external(|width| width.get());
Exec::new(&pool, 1).unwrap().fork(3, |_, _| {});
Exec::new(&pool, 2).unwrap().fork(2, |_, _| {
Exec::new(&pool, 2).unwrap().for_ranges(8, nz, |_| {});
});
assert!(
threadteam::ledger::global_pool_unstarted(),
"the global pool was started by threadteam"
);
}