make "fountain" test optionally terminate

any characters typed as an argument after "fountain" will cause
it to terminate in 10 iterations
This commit is contained in:
bunnie 2022-05-13 14:50:29 +08:00
parent b470588285
commit 6f1597b1e7

View file

@ -139,7 +139,6 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
let bi = boot_instant.clone();
move || {
handle_connection(stream, bi);
log::info!("connection closed");
}
});
}
@ -150,7 +149,10 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
write!(ret, "TCP listener started on port 80").unwrap();
}
"fountain" => {
// anything typed after fountain will cause this to be a short test
let short_test = tokens.next().is_some();
thread::spawn({
let short_test = short_test.clone();
move || {
let tp = threadpool::ThreadPool::new(4);
loop {
@ -180,7 +182,7 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
_ => {}
}
count += 1;
if count == 10 {
if count == 10 && short_test {
stream.flush().unwrap();
break;
}
@ -538,7 +540,7 @@ impl Worker {
match message {
Message::NewJob(job) => {
log::info!("Worker {} got a job; executing.", id);
log::debug!("Worker {} got a job; executing.", id);
job();
}